git.iko.soy/typeable/pandoc
on 1.0.0.1 help sign in
typeable/pandoc/web/mkdemos.pl
34 lines 982 B history raw
1#!/usr/bin/perl -w
2# first argument is input filename - a demo template.
3# second argument is output filename.
5my $infile=$ARGV[0];
6my $outfile=$ARGV[1];
8open( IN, "< $infile" );
9open( OUT, "> $outfile" );
11while (<IN>) {
13 my $line = $_;
14 my $firstchar = substr ($line,0,1);
15 if ( $firstchar eq '@' ) {
16 my $command = substr ($line,4);
17 my $commandExec = $command;
18 $commandExec =~ s/[#].*$//g; # strip off comments
19 $commandExec =~ s/@@//g; # strip off hotlink markers
20 print STDERR "$commandExec";
21 system "$commandExec";
22 $line = $command;
23 $line =~ s/-/\-/;
24 $line =~ s/@@([^@]*)@@/<a href="$1">$1<\/a>/g;
25 $line =~ s/-/\\-/g; # to prevent smart dashes!
26 $line =~ s/^(.*)$/ <pre><code>$1<\/code><\/pre>/g;
27 if ( $line =~ /(example\d+\.html)<\/a><\/code>/m ) {
28 $line .= "\n (View [`$1` as a web page]($1).)\n";
29 }
30 }
31 print OUT $line;