Commits

Shlomi Fish committed 56b9963

Extract _write_Element_Text .

This way - we have the same functionality only in one place.

Comments (0)

Files changed (3)

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto.pm

     return;
 }
 
+sub _write_Element_Text
+{
+    my ($self, $elem) = @_;
+
+    foreach my $child (@{$elem->_get_childs()})
+    {
+        $self->_write_elem({ elem => $child,},);
+    }
+
+    return;
+}
+
 around '_write_elem_obj' => sub {
     my $orig = shift;
     my $self = shift;
 
         return;
     }
-    elsif ($elem->_short_isa("Text"))
-    {
-        foreach my $child (@{$elem->_get_childs()})
-        {
-            $self->_write_elem({ elem => $child,},);
-        }
-
-        return;
-    }
     else
     {
         return $orig->($self, @_);

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/FictionBase/TagsTree2XML.pm

 
     my $elem = $args->{elem};
 
+    if ($elem->_short_isa("Text"))
+    {
+        $self->_write_Element_Text($elem);
+    }
     if ($elem->_short_isa("Paragraph"))
     {
         $self->_output_tag_with_childs(

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Screenplay/FromProto.pm

     return "para";
 }
 
-around '_write_elem_obj' => sub {
-    my $orig = shift;
-    my $self = shift;
-    my ($args) = @_;
+sub _write_Element_Text
+{
+    my ($self, $elem) = @_;
 
-    my $elem = $args->{elem};
-
-    if ($elem->_short_isa("Text"))
-    {
-        $self->_handle_text_start($elem);
-    }
-    else
-    {
-        return $orig->($self, @_);
-    }
-};
+    return $self->_handle_text_start($elem);
+}
 
 sub _handle_elem_of_name_img
 {