Anonymous avatar Anonymous committed 7a673ef

Extract a base class method.

Comments (0)

Files changed (3)

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

     return qr{(?:\<|^\n?$)}ms;
 }
 
-sub _generate_text_unit_events
+sub _generate_non_tag_text_event
 {
     my $self = shift;
 
-    $self->skip_multiline_space();
+    my $is_para = ($self->curr_pos() == 0);
 
-    if (! $self->_generate_tag_event())
+    my $status = $self->_parse_non_tag_text_unit();
+    my $elem = $status->{'elem'};
+    my $is_para_end = $status->{'para_end'};
+
+    my $in_para = $self->_in_para();
+    if ($is_para && !$in_para)
     {
-        my $is_para = ($self->curr_pos() == 0);
+        $self->_enqueue_event({type => "open", tag => "para"});
+        $in_para = 1;
+    }
 
-        my $status = $self->_parse_non_tag_text_unit();
-        my $elem = $status->{'elem'};
-        my $is_para_end = $status->{'para_end'};
+    $self->_enqueue_event({type => "elem", elem => $elem});
 
-        my $in_para = $self->_in_para();
-        if ($is_para && !$in_para)
-        {
-            $self->_enqueue_event({type => "open", tag => "para"});
-            $in_para = 1;
-        }
+    if ($is_para_end && $in_para)
+    {
+        $self->_enqueue_event({ type => "close", tag => "para" });
+        $in_para = 0;
+    }
 
-        $self->_enqueue_event({type => "elem", elem => $elem});
-
-        if ($is_para_end && $in_para)
-        {
-            $self->_enqueue_event({ type => "close", tag => "para" });
-            $in_para = 0;
-        }
-    }
     return;
 }
 
+before '_generate_text_unit_events' => sub {
+    my $self = shift;
+
+    $self->skip_multiline_space() 
+};
+
 sub _handle_open_para
 {
     my ($self, $event) = @_;

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

     }
 }
 
+sub _generate_text_unit_events
+{
+    my $self = shift;
+    
+    # $self->skip_multiline_space();
+
+    if (! $self->_generate_tag_event())
+    {
+        $self->_generate_non_tag_text_event();
+    }
+
+    return;
+}
+
 sub _flush_ret_tag
 {
     my $self = shift;

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

     return (${$self->curr_line_ref()} =~ m{\G(</|\])});
 }
 
-
-sub _generate_text_unit_events
+sub _generate_non_tag_text_event
 {
     my $self = shift;
+    my $status = $self->_parse_non_tag_text_unit();
+
+    if (!defined($status))
+    {
+        return;
+    }
+
+    my $elem = $status->{'elem'};
+    my $is_para_end = $status->{'para_end'};
+    my $is_saying = $elem->isa("XML::Grammar::Fiction::FromProto::Node::Saying");
+    #my $is_para =
+    #    (($self->curr_pos() == 0) && 
+    #     (${$self->curr_line_ref()} =~ m{\G\n?\z})
+    #    );
+    # Trying out this one:
+    my $is_para = $elem->isa("XML::Grammar::Fiction::FromProto::Node::Paragraph");
+
+    my $in_para = $self->_in_para();
+    my $was_already_enqueued = 0;
+
+    if ( ($is_saying || $is_para) && $in_para)
+    {
+        $self->_enqueue_event({type => "close", tag => "para"});
+        $in_para = 0;
+    }
     
-    # $self->skip_multiline_space();
+    if ( $is_saying && $self->_in_saying())
+    {
+        $self->_enqueue_event({type => "close", tag => "saying"});
+    }
 
-    if (! $self->_generate_tag_event())
+    if ($is_saying)
     {
-        my $status = $self->_parse_non_tag_text_unit();
+        $self->_enqueue_event(
+            {type => "open", tag => "saying", _elem => $elem, },
+        );
+        $was_already_enqueued = 1;
 
-        if (!defined($status))
-        {
-            return;
-        }
+        $self->_enqueue_event({type => "open", tag => "para"});
+        $in_para = 1;
+    }
+    elsif ($is_para && !$in_para)
+    {
+        $self->_enqueue_event({type => "open", tag => "para"});
+        $in_para = 1;
+    }
 
-        my $elem = $status->{'elem'};
-        my $is_para_end = $status->{'para_end'};
-        my $is_saying = $elem->isa("XML::Grammar::Fiction::FromProto::Node::Saying");
-        #my $is_para =
-        #    (($self->curr_pos() == 0) && 
-        #     (${$self->curr_line_ref()} =~ m{\G\n?\z})
-        #    );
-        # Trying out this one:
-        my $is_para = $elem->isa("XML::Grammar::Fiction::FromProto::Node::Paragraph");
-
-        my $in_para = $self->_in_para();
-        my $was_already_enqueued = 0;
-
-        if ( ($is_saying || $is_para) && $in_para)
-        {
-            $self->_enqueue_event({type => "close", tag => "para"});
-            $in_para = 0;
-        }
-        
-        if ( $is_saying && $self->_in_saying())
-        {
-            $self->_enqueue_event({type => "close", tag => "saying"});
-        }
-
-        if ($is_saying)
-        {
-            $self->_enqueue_event(
-                {type => "open", tag => "saying", _elem => $elem, },
-            );
-            $was_already_enqueued = 1;
-
-            $self->_enqueue_event({type => "open", tag => "para"});
-            $in_para = 1;
-        }
-        elsif ($is_para && !$in_para)
+    if ($elem->isa("XML::Grammar::Fiction::FromProto::Node::Text") &&
+        !$was_already_enqueued)
+    {
+        if (!$in_para)
         {
             $self->_enqueue_event({type => "open", tag => "para"});
             $in_para = 1;
         }
+        $self->_enqueue_event({type => "elem", elem => $elem, });
+        $was_already_enqueued = 1;
+    }
 
-        if ($elem->isa("XML::Grammar::Fiction::FromProto::Node::Text") &&
-            !$was_already_enqueued)
-        {
-            if (!$in_para)
-            {
-                $self->_enqueue_event({type => "open", tag => "para"});
-                $in_para = 1;
-            }
-            $self->_enqueue_event({type => "elem", elem => $elem, });
-            $was_already_enqueued = 1;
-        }
-
-        return;
-    }
+    return;
 }
 
 sub _close_saying
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.