Commits

Shlomi Fish  committed 23b7e56

Move _write_scene() to the base class.

Extract a _write_scene_main() in each of X-G-Fiction-FromProto and
X-G-Screenplay-FromProto .

  • Participants
  • Parent commits e87da46

Comments (0)

Files changed (3)

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

     return ['List', @{$orig->($self)}];
 };
 
-sub _write_scene
+sub _write_scene_main
 {
-    my ($self, $args) = @_;
+    my ($self, $scene) = @_;
 
-    my $scene = $args->{scene};
-
-    my $tag = $scene->name;
-
-    if (($tag eq "s") || ($tag eq "scene"))
-    {
-        $self->_output_tag_with_childs_and_common_attributes(
-            $scene,
-            "section",
-            { missing_id_msg => "Unspecified id for scene!", },
-        );
-    }
-    else
-    {
-        confess "Improper scene tag - should be '<s>' or '<scene>'!";
-    }
+    $self->_output_tag_with_childs_and_common_attributes(
+        $scene,
+        "section",
+        { missing_id_msg => "Unspecified id for scene!", },
+    );
 
     return;
 }

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

     return $self->_parser->process_text($self->_read_file($filename));
 }
 
+sub _write_scene
+{
+    my ($self, $args) = @_;
+
+    my $scene = $args->{scene};
+
+    my $tag = $scene->name;
+
+    if (($tag eq "s") || ($tag eq "scene"))
+    {
+        $self->_write_scene_main($scene);
+    }
+    else
+    {
+        confess "Improper scene tag - should be '<s>' or '<scene>'!";
+    }
+
+    return;
+}
+
 =head2 $self->convert({ source => { file => $path_to_file } })
 
 Converts the file $path_to_file to XML and returns it. Throws an exception

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

     return "italics";
 }
 
-sub _write_scene
+sub _write_scene_main
 {
-    my ($self, $args) = @_;
+    my ($self, $scene) = @_;
 
-    my $scene = $args->{scene};
+    my $id = $scene->lookup_attr("id");
 
-    my $tag = $scene->name;
+    if (!defined($id))
+    {
+        Carp::confess("Unspecified id for scene!");
+    }
 
-    if (($tag eq "s") || ($tag eq "scene"))
-    {
-        my $id = $scene->lookup_attr("id");
+    my $title = $scene->lookup_attr("title");
+    my @t = (defined($title) ? (title => $title) : ());
 
-        if (!defined($id))
+    $self->_output_tag_with_childs(
         {
-            Carp::confess("Unspecified id for scene!");
+            'start' => ["scene", id => $id, @t],
+            elem => $scene,
         }
-
-        my $title = $scene->lookup_attr("title");
-        my @t = (defined($title) ? (title => $title) : ());
-
-        $self->_output_tag_with_childs(
-            {
-                'start' => ["scene", id => $id, @t],
-                elem => $scene,
-            }
-        );
-    }
-    else
-    {
-        confess "Improper scene tag - should be '<s>' or '<scene>'!";
-    }
+    );
 
     return;
 }