Commits

Anonymous committed 5e52237

Fix a colon (":") inside a description ("[…]").

Comments (0)

Files changed (6)

perl/modules/XML-Grammar-Fiction/Changes

         - they cancelled each other most of the time except for in this 
         case.
 
+        - Screenplay: fix a colon inside a description that broke the 
+        proto-text. (E.g: "[David turns towards Goliath and says:]").
+
 0.1.3       Fri Dec 17 19:38:45 IST 2010
         - Moved some unused source files to the rejects directory.
         - Convert to the new XML-Grammar-Fiction-Builder which uses

perl/modules/XML-Grammar-Fiction/MANIFEST

 t/screenplay/data/proto-text/scenes-with-titles.txt
 t/screenplay/data/proto-text/two-nested-s.txt
 t/screenplay/data/proto-text/with-brs.txt
+t/screenplay/data/proto-text/with-colon-in-description.txt
 t/screenplay/data/proto-text/with-comments.txt
 t/screenplay/data/proto-text/with-description.txt
 t/screenplay/data/proto-text/with-dialogue.txt
 t/screenplay/data/xml/scenes-with-titles.xml
 t/screenplay/data/xml/two-nested-s.xml
 t/screenplay/data/xml/with-brs.xml
+t/screenplay/data/xml/with-colon-in-description.xml
 t/screenplay/data/xml/with-comments.xml
 t/screenplay/data/xml/with-description.xml
 t/screenplay/data/xml/with-dialogue.xml

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

 
     my $l = $self->curr_line_ref();
 
-    if ((pos($$l) == 0) && ($$l =~ m{\A[^\[<][^:]*:}))
+    if ((pos($$l) == 0) && ($$l =~ m{\A[^\[<][^:]*:})
+        && (! $self->_is_in_desc)
+    )
     {
         return $self->_parse_speech_unit();
     }
     return [qw(para saying)];
 }
 
+sub _is_in_desc {
+    my $self = shift;
+
+    return $self->_top_tag()->name() eq "desc";
+}
+
 after '_handle_open_tag' => sub {
     my $self = shift;
 
-    if ($self->_top_tag()->name() eq "desc")
+    if ($self->_is_in_desc)
     {
         $self->_start_para();
     }

perl/modules/XML-Grammar-Fiction/t/screenplay/data/proto-text/with-colon-in-description.txt

+<s id="top">
+
+<s id="david_and_goliath">
+
+[David and Goliath are standing by each other. David addresses Goliath:
+]
+
+David: I will kill you.
+
+Goliath: no way, you little idiot!
+
+David: yes way!
+
+++++: In the name of Allah, the merciful, I will show you the power of my
+sling.
+
+++++: I shall sling you and bing you till infinity.
+
+[David takes his sling.]
+
+Goliath: I'm still waiting.
+
+David: so you are.
+
+[David puts a stone in his sling and shoots Goliath. He hits.]
+
+</s>
+
+</s>

perl/modules/XML-Grammar-Fiction/t/screenplay/data/xml/with-colon-in-description.xml

+<?xml version='1.0' encoding='utf-8'?>
+<!DOCTYPE document SYSTEM "screenplay-xml.dtd">
+<document xmlns="http://web-cpan.berlios.de/modules/XML-Grammar-Screenplay/screenplay-xml-0.2/">
+    <head>
+    </head>
+    <body id="index">
+<scene id="top">
+    <scene id="david_and_goliath">
+        <description>
+            <para>
+            David and Goliath are standing by each other. David addresses Goliath:
+            </para>
+        </description>
+        <saying character="David">
+            <para>
+                I will kill you.
+            </para>
+        </saying>
+        <saying character="Goliath">
+            <para>
+                no way, you little idiot!
+            </para>
+        </saying>
+        <saying character="David">
+            <para>
+                yes way!
+            </para>
+            <para>
+                In the name of Allah, the merciful, I will show you the power 
+                of my sling.
+            </para>
+            <para>
+                I shall sling you and bing you till infinity.
+            </para>
+        </saying>
+        <description>
+            <para>
+                David takes his sling.
+            </para>
+        </description>
+    <saying character="Goliath">
+        <para>
+            I'm still waiting.
+        </para>
+    </saying>
+    <saying character="David">
+        <para>
+            so you are.
+        </para>
+    </saying>
+    <description>
+        <para>
+            David puts a stone in his sling and shoots Goliath. He hits.
+        </para>
+    </description>
+</scene>
+</scene>
+</body>
+</document>

perl/modules/XML-Grammar-Fiction/t/screenplay/proto-text-to-xml-using-custom-parser.t

 
 use Test::More;
 
-use Test::XML tests => 28;
+use Test::XML tests => 30;
 
 use XML::LibXML;
 
         with-entities
         with-brs
         with-internal-description-at-start-of-line
+        with-colon-in-description
     ));
 
-# TEST:$num_texts=14
+# TEST:$num_texts=15
 
 my $grammar = XML::Grammar::Screenplay::FromProto->new({
         parser_class => "XML::Grammar::Screenplay::FromProto::Parser::QnD",
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.