Anonymous avatar Anonymous committed 7ff27f3

Add the Screenplay-Text -> XHTML example .

Comments (0)

Files changed (5)

 	Humanity-Movie \
 	ae-interview \
 	hitchhikers-guide-to-star-trek-tng-hand-tweaked \
+	humanity-excerpt-for-X-G-Screenplay-demo \
 	star-trek--we-the-living-dead \
 	selena-mandrake-the-slayer \
 	sussman-interview \
 $(T2_DEST)/humour/TOWTF/TOW_Fountainhead_2.html: $(SCREENPLAY_XML_RENDERED_HTML_DIR)/TOW_Fountainhead_2.html
 $(T2_DEST)/open-source/interviews/adrian-ettlinger.html: $(SCREENPLAY_XML_RENDERED_HTML_DIR)/ae-interview.html
 $(T2_DEST)/open-source/interviews/sussman.html: $(SCREENPLAY_XML_RENDERED_HTML_DIR)/sussman-interview.html
+$(T2_DEST)/open-source/projects/XML-Grammar/Fiction/index.html: $(SCREENPLAY_XML_TXT_DIR)/humanity-excerpt-for-X-G-Screenplay-demo.txt
+$(T2_DEST)/open-source/projects/XML-Grammar/Fiction/index.html: $(SCREENPLAY_XML_RENDERED_HTML_DIR)/humanity-excerpt-for-X-G-Screenplay-demo.html
 
 # Rebuild the embedded docbook4 pages in the $(T2_DEST) after they are 
 # modified.
 $(T2_DEST)/open-source/interviews/sussman-interview.txt: $(SCREENPLAY_XML_TXT_DIR)/sussman-interview.txt
 	cp -f $< $@
 
+
 $(T2_DEST)/humour/Pope/The-Pope-Died-on-Sunday--Hebrew-Text.html: $(DOCBOOK5_RENDERED_DIR)/The-Pope-Died-on-Sunday-hebrew.xhtml
 
 $(T2_DEST)/humour/human-hacking/hebrew-v2.html: $(DOCBOOK5_RENDERED_DIR)/human-hacking-field-guide-hebrew-v2.xhtml
+package VimIface;
+
+use strict;
+use warnings;
+
+use Text::VimColor;
+
+sub is_newer
+{
+    my $file1 = shift;
+    my $file2 = shift;
+    my @stat1 = stat($file1);
+    my @stat2 = stat($file2);
+    if (! @stat2)
+    {
+        return 1;
+    }
+    return ($stat1[9] >= $stat2[9]);
+}
+
+sub get_syntax_highlighted_html_from_file
+{
+    my (%args) = (@_);
+
+    my $filename = $args{'filename'};
+    
+    my $html_filename = "$filename.html-for-quad-pres";
+
+    if (is_newer( $filename, $html_filename))
+    {
+        my $syntax = Text::VimColor->new(
+            file => $filename,
+            html_full_page => 1,
+            ($args{'filetype'} ? (filetype => $args{'filetype'}) : ()),
+        );
+
+        open my $out, ">", $html_filename
+            or die "Could not open HTML file '$html_filename' for output - $!";
+
+        print {$out} $syntax->html();
+        close($out);
+    }
+
+    open my $in, "<", $html_filename
+        or die "Could not open HTML file '$html_filename' for input - $!";
+    my $text = do { local $/; <$in> };
+    close($in);
+
+    $text =~ s{^.*<pre>[\s\n\r]*}{}s;
+    $text =~ s{[\s\n\r]*</pre>.*$}{}s;
+    $text =~ s{(class=")syn}{$1}g;
+
+    return $text;
+}
+
+1;
+

lib/screenplay-xml/txt/humanity-excerpt-for-X-G-Screenplay-demo.txt

+<s id="humanity" title="'Humanity' - The Movie">
+
+[Note: This screenplay was written by
+<a href="http://www.shlomifish.org/">Shlomi Fish</a>, and is original artwork.]
+
+<s id="the-well" title="The Well">
+
+[ The Well is shown. Several women are standing nearby with large pots near
+them. They are chatting. Three men approach. ]
+
+Man #1: OK. Let's move it.
+
+Man #2: You know, I heard of a guy called Moses who could move a stone like
+this all by himself.
+
+The Inventor's Voice from outside the frame: That's because he was using the 
+Mosesiom 3000!
+
+Man #3: I beg your pardon?
+
+[ The Inventor enters the frame with his invention that looks suspiciously
+like a lever. ]
+
+The Inventor: With this ingenious invention one man can move this stone
+all by himself. Wanna try?
+
+Man #1: OK. I'll try.
+
+The Inventor: OK. First we tie the stone to the ropes here. 
+
+[ He ties the stone]
+
+The Inventor: Now lift the other hand.
+
+Man #1: [After lifting the stone.] Wow, it's so easy, look I can move the
+stone here [moves it to the left], and here [ moves it to the right].
+
+The Inventor: No! No! Don't misuse it.
+
+[The stone falls down on the well, splits into two pieces which both fall down
+the well. The men are amazed. ]
+
+The Inventor: Don't worry, I can get down and tie the ropes to each stone and
+we can lift it up in a flash...
+
+Man #1: I'll get the ropes.
+
+Man #2: I'll get the horses.
+
+[ They leave the frame ]
+
+The Inventor: This is not my day.
+
+Woman #1: Who is John Galt?
+
+</s>
+
+</s>
+

lib/vim_include_code.wml

+<:{
+require VimIface;
+}:>
+<define-tag shlomif_code_block endtag="required" whitespace="delete">
+<div class="code_block">
+<pre>
+%body
+</pre>
+</div>
+</define-tag>
+
+<define-tag shlomif_include_colorized_file whitespace="delete">
+<preserve filename />
+<set-var %attributes />
+<:{
+print VimIface::get_syntax_highlighted_html_from_file('filename' => "<get-var filename />");
+}:>
+<restore filename />
+</define-tag>
+

t2/open-source/projects/XML-Grammar/Fiction/index.html.wml

 #include '../template.wml'
+#include "vim_include_code.wml"
 
 <set-var cpan_dist="XML-Grammar-Fiction" /> 
 
 <latemp_subject "<get-var cpan_dist /> - Markup Languages for Writing Prose" />
 
+<page_extra_head_elements>
+<link rel="stylesheet" href="$(ROOT)/screenplay.css" type="text/css" media="screen, projection" />
+</page_extra_head_elements>
+
 <p>
 <get-var cpan_dist /> provides <b>Fiction-Text</b>, a lightweight 
 plaintext-based markup language, which can be used to write such fiction as 
 
 </ul>
 
+<h2 id="demos">Demos</h2>
+
+<h3 id="demo-screenplay1">Screenplay Demo 1</h3>
+
+<p>
+If we have this sample screenplay:
+</p>
+
+<shlomif_code_block>
+<shlomif_include_colorized_file filename="../lib/screenplay-xml/txt/humanity-excerpt-for-X-G-Screenplay-demo.txt" />
+</shlomif_code_block>
+
+<p>
+Then after converting it to XML and then to XHTML we get this:
+</p>
+
+#include "screenplay-xml/rendered-html/humanity-excerpt-for-X-G-Screenplay-demo.html"
+
 <h2 id="similar">Similar Projects</h2>
 
 <ul>
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.