[MKDoc-commit] [1.8] factor out some duplicate code

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Wed Aug 24 17:48:38 BST 2005


Log Message:
-----------
[1.8] factor out some duplicate code

Modified Files:
--------------
    mkd/flo:
        Component.pm
    mkd/flo/editor:
        Html.pm
        Text.pm

-------------- next part --------------
Index: Component.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/Component.pm,v
retrieving revision 1.18
retrieving revision 1.19
diff -Lflo/Component.pm -Lflo/Component.pm -u -r1.18 -r1.19
--- flo/Component.pm
+++ flo/Component.pm
@@ -477,6 +477,27 @@
 
 
 ##
+# $self->links_for_tagger;
+# ------------------------
+#   Returns a list of links in a format suitable for tagging
+##
+sub links_for_tagger
+{
+    my $self = shift;
+    my @link = flo::Editor->links();
+    my @newl = ();
+    for (@link) {
+        my $new = { %{$_} };
+        $new->{_expr} = delete $new->{expr};
+        $new->{_tag}  = 'a';
+        $new->{title} = delete $new->{desc};
+        push @newl, $new;
+    }
+    return @newl;
+}
+
+
+##
 # $self->is_only_child;
 # ---------------------
 #   Returns TRUE if this component has no sibling components,
Index: Text.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/Text.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -Lflo/editor/Text.pm -Lflo/editor/Text.pm -u -r1.22 -r1.23
--- flo/editor/Text.pm
+++ flo/editor/Text.pm
@@ -72,16 +72,7 @@
     my $data = $self->{'data'};
     $data = MKDoc::Text::Structured::process ($data);
     
-    my @link = flo::Editor->links();
-    my @newl = ();
-    for (@link) {
-        my $new = { %{$_} };
-        $new->{_expr} = delete $new->{expr};
-        $new->{_tag}  = 'a';
-        $new->{title} = delete $new->{desc};
-        push @newl, $new;
-    }
-
+    my @newl = $self->links_for_tagger();
     return MKDoc::XML::Tagger::Preserve->process_data (['a'], $data, @newl);
 }
 
Index: Html.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/Html.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lflo/editor/Html.pm -Lflo/editor/Html.pm -u -r1.19 -r1.20
--- flo/editor/Html.pm
+++ flo/editor/Html.pm
@@ -115,16 +115,7 @@
     my $self = shift;
     my $data = $self->{data};
 
-    my @link = flo::Editor->links();
-    my @newl = ();
-    for (@link) {
-        my $new = { %{$_} };
-        $new->{_expr} = delete $new->{expr};
-        $new->{_tag}  = 'a';
-        $new->{title} = delete $new->{desc};
-        push @newl, $new;
-    }
-    
+    my @newl = $self->links_for_tagger();
     return MKDoc::XML::Tagger::Preserve->process_data (['a'], $data, @newl);
 }
 


More information about the MKDoc-commit mailing list