Commits

Anonymous committed e3313be

Fix handling of colon inside a top-level description.

Comments (0)

Files changed (6)

perl/modules/XML-Grammar-Fiction/Changes

 
     * Add the tag-release.pl script to tag a release using svn.berlios.de.
 
+    * Fix the handling of a colon (":") inside a top-level description
+    in XML-Grammar-Screenplay.
+
 0.1.4       Mon Apr  4 00:50:07 IDT 2011
     * ::Screenplay - Fix the innerdesc on the start of the line in the middle 
     of the paragraph. Like:

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-inside-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-inside-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

     return $self->_in_saying() && ($self->_top_tag->name() eq "saying");
 }
 
+sub _top_is_desc
+{
+    my $self = shift;
+
+    return ($self->_top_tag->name() eq "desc");
+}
+
 around '_pop_tag' => sub {
     my ($orig, $self) = @_;
 
 
     my $l = $self->curr_line_ref();
 
-    if ((pos($$l) == 0) && ($$l =~ m{\A[^\[<][^:]*:}))
+    if ((pos($$l) == 0) && (! $self->_top_is_desc()) && ($$l =~ m{\A[^\[<][^:]*:}))
     {
         return $self->_parse_speech_unit();
     }
 after '_handle_open_tag' => sub {
     my $self = shift;
 
-    if ($self->_top_tag()->name() eq "desc")
+    if ($self->_top_is_desc)
     {
         $self->_start_para();
     }

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

+<s id="top">
+
+<s id="david_and_goliath">
+
+[David and Goliath are standing by each other.]
+
+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.
+
+He looks around: there's no one there except Goliath and him.
+
+David opens the book "Slings: The Missing Manual".
+]
+
+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-inside-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.
+            </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>
+            <para>
+                He looks around: there's no one there except Goliath and him.
+            </para>
+            <para>
+                David opens the book "Slings: The Missing Manual".
+            </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 => 30;
+use Test::XML tests => 32;
 
 use XML::LibXML;
 
         with-entities
         with-brs
         with-internal-description-at-start-of-line
+        with-colon-inside-description
     ));
 
-# TEST:$num_texts=15
+# TEST:$num_texts=16
 
 my $grammar = XML::Grammar::Screenplay::FromProto->new({
         parser_class => "XML::Grammar::Screenplay::FromProto::Parser::QnD",