Commits

Anonymous committed 0f4c08c

Extract the _write_Element_elem method from both classes.

Comments (0)

Files changed (2)

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

     return "p";
 }
 
+sub _write_Element_elem
+{
+    my ($self, $elem) = @_;
+
+    if ($elem->name() eq "title")
+    {
+        # TODO :
+        # Eliminate the Law-of-Demeter-syndrome here.
+        my $list = $elem->_get_childs()->[0];
+        $self->_output_tag(
+            {
+                start => ["title"],
+                in => sub {
+                    $self->_write_elem(
+                        {
+                            elem => $list,
+                        }                            
+                    ),
+                },
+            },
+        );
+    }
+    elsif ($elem->name() eq "s")
+    {
+        $self->_write_scene({scene => $elem});
+    }
+    elsif ($elem->name() eq "a")
+    {
+        $self->_output_tag_with_childs(
+            {
+                start => ["ulink", "url" => $elem->lookup_attr("href")],
+                elem => $elem,
+            }
+        );
+    }
+    elsif ($elem->name() eq "b")
+    {
+        $self->_output_tag_with_childs(
+            {
+                start => ["b"],
+                elem => $elem,
+            }
+        );
+    }
+    elsif ($elem->name() eq "i")
+    {
+        $self->_output_tag_with_childs(
+            {
+                start => ["i"],
+                elem => $elem,
+            }
+        );
+    }        
+    elsif ($elem->name() eq "br")
+    {
+        $self->_writer->emptyTag("br");
+    }
+    elsif ($elem->_short_isa("InnerDesc"))
+    {
+        $self->_output_tag_with_childs(
+            {
+                start => ["inlinedesc"],
+                elem => $elem,
+            }
+        );
+    }
+
+    return;
+}
+
 sub _write_elem
 {
     my ($self, $args) = @_;
     }
     elsif ($elem->_short_isa("Element"))
     {
-        if ($elem->name() eq "title")
-        {
-            # TODO :
-            # Eliminate the Law-of-Demeter-syndrome here.
-            my $list = $elem->_get_childs()->[0];
-            $self->_output_tag(
-                {
-                    start => ["title"],
-                    in => sub {
-                        $self->_write_elem(
-                            {
-                                elem => $list,
-                            }                            
-                        ),
-                    },
-                },
-            );
-        }
-        elsif ($elem->name() eq "s")
-        {
-            $self->_write_scene({scene => $elem});
-        }
-        elsif ($elem->name() eq "a")
-        {
-            $self->_output_tag_with_childs(
-                {
-                    start => ["ulink", "url" => $elem->lookup_attr("href")],
-                    elem => $elem,
-                }
-            );
-        }
-        elsif ($elem->name() eq "b")
-        {
-            $self->_output_tag_with_childs(
-                {
-                    start => ["b"],
-                    elem => $elem,
-                }
-            );
-        }
-        elsif ($elem->name() eq "i")
-        {
-            $self->_output_tag_with_childs(
-                {
-                    start => ["i"],
-                    elem => $elem,
-                }
-            );
-        }        
-        elsif ($elem->name() eq "br")
-        {
-            $self->_writer->emptyTag("br");
-        }
-        elsif ($elem->_short_isa("InnerDesc"))
-        {
-            $self->_output_tag_with_childs(
-                {
-                    start => ["inlinedesc"],
-                    elem => $elem,
-                }
-            );
-        }
+        $self->_write_Element_elem($elem);
     }
     elsif ($elem->_short_isa("Text"))
     {

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

     return "para";
 }
 
+sub _write_Element_elem
+{
+    my ($self, $elem) = @_;
+
+    if (($elem->name() eq "s") || ($elem->name() eq "section"))
+    {
+        $self->_write_scene({scene => $elem});
+    }
+    elsif ($elem->name() eq "a")
+    {
+        $self->_output_tag_with_childs(
+            {
+                start => ["ulink", "url" => $elem->lookup_attr("href")],
+                elem => $elem,
+            }
+        );
+    }
+    elsif ($elem->name() eq "b")
+    {
+        $self->_output_tag_with_childs(
+            {
+                start => ["bold"],
+                elem => $elem,
+            }
+        );
+    }
+    elsif ($elem->name() eq "br")
+    {
+        $self->_writer->emptyTag("br");
+    }
+    elsif ($elem->_short_isa("InnerDesc"))
+    {
+        $self->_output_tag_with_childs(
+            {
+                start => ["inlinedesc"],
+                elem => $elem,
+            }
+        );
+    }
+
+    return;
+}
+
 sub _write_elem
 {
     my ($self, $args) = @_;
     }
     elsif ($elem->_short_isa("Element"))
     {
-        if (($elem->name() eq "s") || ($elem->name() eq "section"))
-        {
-            $self->_write_scene({scene => $elem});
-        }
-        elsif ($elem->name() eq "a")
-        {
-            $self->_output_tag_with_childs(
-                {
-                    start => ["ulink", "url" => $elem->lookup_attr("href")],
-                    elem => $elem,
-                }
-            );
-        }
-        elsif ($elem->name() eq "b")
-        {
-            $self->_output_tag_with_childs(
-                {
-                    start => ["bold"],
-                    elem => $elem,
-                }
-            );
-        }
-        elsif ($elem->name() eq "br")
-        {
-            $self->_writer->emptyTag("br");
-        }
-        elsif ($elem->_short_isa("InnerDesc"))
-        {
-            $self->_output_tag_with_childs(
-                {
-                    start => ["inlinedesc"],
-                    elem => $elem,
-                }
-            );
-        }
+        $self->_write_Element_elem($elem);
     }
     elsif ($elem->_short_isa("Text"))
     {