Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed c63f319

Merged _parse_non_tag_text_unit into XmlIterator.

  • Participants
  • Parent commits 9e904c4

Comments (0)

Files changed (3)

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

 
 our $VERSION = '0.0.4';
 
-sub _parse_non_tag_text_unit
-{
-    my $self = shift;
-
-    my $l = $self->curr_line_ref();
-
-    my $text = $self->consume_up_to(qr{(?:\<|^\n?$)}ms);
-
-    $l = $self->curr_line_ref();
-
-    my $ret_elem = $self->_new_text([$text]);
-    my $is_para_end = 0;
-
-    # Demote the cursor to before the < of the tag.
-    #
-    if (pos($$l) > 0)
-    {
-        pos($$l)--;
-        if (substr($$l, pos($$l), 1) eq "\n")
-        {
-            $is_para_end = 1;
-        }
-    }
-    else
-    {
-        $is_para_end = 1;
-    }
-
-    return
-    {
-        elem => $ret_elem,
-        para_end => $is_para_end,
-    };
+sub _non_tag_text_unit_consume_regex {
+    return qr{(?:\<|^\n?$)}ms;
 }
 
 sub _parse_text_unit

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

     }
 }
 
+sub _parse_non_tag_text_unit
+{
+    my $self = shift;
+
+    my $text = $self->consume_up_to($self->_non_tag_text_unit_consume_regex);
+
+    my $l = $self->curr_line_ref();
+
+    my $ret_elem = $self->_new_text([$text]);
+    my $is_para_end = 0;
+
+    # Demote the cursor to before the < of the tag.
+    #
+    if (pos($$l) > 0)
+    {
+        pos($$l)--;
+        if (substr($$l, pos($$l), 1) eq "\n")
+        {
+            $is_para_end = 1;
+        }
+    }
+    else
+    {
+        $is_para_end = 1;
+    }
+    
+    if ($text !~ /\S/)
+    {
+        return;
+    }
+    else
+    {
+        return
+        {
+            elem => $ret_elem,
+            para_end => $is_para_end,
+        };
+    }
+}
+
 sub _parse_text
 {
     my $self = shift;

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

     }
 }
 
-sub _parse_non_tag_text_unit
+sub _non_tag_text_unit_consume_regex
 {
-    my $self = shift;
+    return qr{(?:[\<\[\]\&]|^\n?$)}ms;
+}
+
+around '_parse_non_tag_text_unit' => sub {
+    my ($orig, $self) = @_;
 
     my $l = $self->curr_line_ref();
 
     {
         return $self->_parse_speech_unit();
     }
-
-    my $text = $self->consume_up_to(qr{(?:[\<\[\]\&]|^\n?$)}ms);
-
-    $l = $self->curr_line_ref();
-
-    my $ret_elem = $self->_new_text([$text]);
-    my $is_para_end = 0;
-
-    # Demote the cursor to before the < of the tag.
-    #
-    if (pos($$l) > 0)
-    {
-        pos($$l)--;
-        if (substr($$l, pos($$l), 1) eq "\n")
-        {
-            $is_para_end = 1;
-        }
-    }
     else
     {
-        $is_para_end = 1;
+        return $self->$orig();
     }
-
-    if ($text !~ /\S/)
-    {
-        return;
-    }
-    else
-    {
-        return
-        {
-            elem => $ret_elem,
-            para_end => $is_para_end,
-        };
-    }
-}
+};
 
 sub _parse_text_unit
 {