Commits

Shlomi Fish committed b0009d1

Add the <img tag.

Comments (0)

Files changed (8)

perl/modules/XML-Grammar-Fiction/Changes

 Revision history for XML-Grammar-Fiction.
 
+    * Add the <img tag to the Screenplay.
+
 0.10.0      Sun 13 Jan 08:32:43 IST 2013
     * Add more links to the XML::Grammar::Fiction's perldoc.
     * Convert from Mouse to Moo, MooX and "use MooX 'late'".

perl/modules/XML-Grammar-Fiction/MANIFEST

 t/screenplay/data/proto-text/with-dialogue.txt
 t/screenplay/data/proto-text/with-entities.txt
 t/screenplay/data/proto-text/with-i-element-inside-paragraphs.txt
+t/screenplay/data/proto-text/with-img-element-inside-paragraphs.txt
 t/screenplay/data/proto-text/with-internal-description-at-start-of-line.txt
 t/screenplay/data/proto-text/with-internal-description.txt
 t/screenplay/data/proto-text/with-multi-line-comments.txt
 t/screenplay/data/xml/with-dialogue.xml
 t/screenplay/data/xml/with-entities.xml
 t/screenplay/data/xml/with-i-element-inside-paragraphs.xml
+t/screenplay/data/xml/with-img-element-inside-paragraphs.xml
 t/screenplay/data/xml/with-internal-description-at-start-of-line.xml
 t/screenplay/data/xml/with-internal-description.xml
 t/screenplay/data/xml/with-multi-line-comments.xml

perl/modules/XML-Grammar-Fiction/TODO

+Pressing:
+---------
+
+* Finish implementing the <image /> tag in the ::Screenplay.
+
+Long term:
+----------
+
+
 * Add a test script to test for trailing space and get rid of trailing space.
 
 * ::Fiction: Implement the correct handling of leading special characters in

perl/modules/XML-Grammar-Fiction/extradata/screenplay-xml.rng

             <ref name="ulink"/>
             <ref name="bold"/>
             <ref name="italics"/>
+            <ref name="image"/>
         </choice>
     </define>
     <define name="scene">
             <text />
         </element>
     </define>
+    <define name="image">
+        <element name="sp:image">
+            <attribute name="url">
+                <text/>
+            </attribute>
+            <attribute name="alt">
+                <text/>
+            </attribute>
+            <attribute name="title">
+                <text/>
+            </attribute>
+        </element>
+    </define>
     <define name="italics">
         <element name="sp:italics">
             <text />

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

     return "para";
 }
 
+sub _handle_elem_of_name_img
+{
+    my ($self, $elem) = @_;
+
+    $self->_output_tag_with_childs(
+        {
+            start => [
+                "image",
+                "url" => $elem->lookup_attr("src"),
+                "alt" => $elem->lookup_attr("alt"),
+                "title" => $elem->lookup_attr("title"),
+            ],
+            elem => $elem,
+        }
+    );
+
+    return;
+}
+
 sub _handle_elem_of_name_a
 {
     my ($self, $elem) = @_;

perl/modules/XML-Grammar-Fiction/t/screenplay/data/proto-text/with-img-element-inside-paragraphs.txt

+<s id="top">
+
+<s id="david_and_goliath">
+
+[David and <a href="http://en.wikipedia.org/wiki/Goliath">Goliath</a> are
+standing by each other.]
+
+David: I will kill you.
+
+Goliath: no way, you little idiot!
+
+David: yes way!
+
+++++: In the name of <a href="http://real-allah.tld/">Allah, the
+<i>merciful</i>, real merciful</a>, I will show you the power of my sling.
+
+++: I shall sling you and bing you till infinity.
+
+[David takes his sling. <img src="sling.png" alt="a sling" title="Photo of David’s sling." /> . ]
+
+Goliath: I'm still <a href="http://wait.tld/">waiting</a>.
+
+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-img-element-inside-paragraphs.xml

+<?xml version='1.0' encoding='utf-8'?>
+<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
+                <ulink url="http://en.wikipedia.org/wiki/Goliath">Goliath</ulink>
+                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 <ulink url="http://real-allah.tld/">Allah, the <italics>merciful</italics>, real merciful</ulink>, 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. <image url="sling.png" alt="a sling" title="Photo of David’s sling." /> .
+            </para>
+        </description>
+    <saying character="Goliath">
+        <para>
+            I'm still <ulink url="http://wait.tld/">waiting</ulink>.
+        </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 => 51;
+use Test::XML tests => 54;
 
 use XML::LibXML;
 
         with-description
         with-tags-inside-paragraphs
         with-i-element-inside-paragraphs
+        with-img-element-inside-paragraphs
         with-internal-description
         with-comments
         with-multi-para-desc
         with-numeric-entities
     ));
 
-# TEST:$num_texts=17
+# TEST:$num_texts=18
 
 my $grammar = XML::Grammar::Screenplay::FromProto->new({
         parser_class => "XML::Grammar::Screenplay::FromProto::Parser::QnD",