plint

French poetry validator
git clone https://a3nm.net/git/plint/
Log | Files | Refs | README

commit 7bb331468d44193613b699fb1ec974fd409f4b8a
parent 3ed814b15a572a33330465dddaf3955f51666562
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Tue,  2 Aug 2011 14:11:28 -0400

add all the html generation code

Diffstat:
bottom.html | 3+++
make_poem.pl | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
make_poem.sh | 6++++++
top.html | 14++++++++++++++
4 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/bottom.html b/bottom.html @@ -0,0 +1,3 @@ + </div> + </body> +</html> diff --git a/make_poem.pl b/make_poem.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +use HTML::Entities; + +my $actor; +my $indent; +my $first = 1; +my %actions; + +while (<STDIN>) { + chop; + if (/^<([^>]*)> \/me (.*)$/) { + if ($1 ne $actor) { + $actions{$1} = $2; + } else { + my $did = encode_entities($2, '<>&"'); + print "</p>\n"; + print "<p class=\"did\">Il $did</p>\n"; + print "<p class=\"speech\">\n"; + } + } elsif (/^<([^>]*)> (.*)$/) { + if ($1 ne $actor) { + print "</p>\n" unless $first; + $first = 0; + $actor = $1; + my $eactor = encode_entities($actor, '<>&"'); + print "<p class=\"actor\"><span class=\"actor\">$eactor</span>"; + if (exists $actions{$1}) { + my $did = encode_entities($actions{$1}, '<>&"'); + print ", <span class=\"did\">$did</span>"; + delete $actions{$1}; + } + print "</p>\n"; + print "<p class=\"speech\">\n"; + } + my $rawverse = $2; + if ($2 =~ m/^ *\.\.\./) { + $indent++; + } else { + $indent = 0; + } + my $verse = encode_entities($rawverse, '<>&"'); + if ($indent) { + my $offset = 4 * $indent . "em"; + print "<span style=\"margin-left: $offset;\">$verse</span><br />\n"; + } else { + print "$verse<br />\n"; + } + } +} + +print "</p>\n" unless $first; diff --git a/make_poem.sh b/make_poem.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cat top.html > www/index.html +cat poem | ./make_poem.pl >> www/index.html +cat bottom.html >> www/index.html +cp style.css www/ diff --git a/top.html b/top.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html dir="ltr" xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>#alexandrins</title> + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + <meta name="author" content="a3_nm" /> + <meta name="description" content="Poèmes, par a3_nm" /> + <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> + </head> + <body> + <div id="container"> + <h1>#alexandrins</h1> + <hr id="top" /> +