Fix de errata reported by tonib in the forum (https://www.projectaon.org/es/foro3...
[project-aon.git] / common / scripts / frontfilter.pl
1 #!/usr/bin/perl
2
3 while( $ARGV[ 0 ] ) {
4     $infile = shift @ARGV;
5
6     @lines = ( );
7     open( INFILE, "<$infile" ) or die "Bad input file \"$infile.\": $!";
8     @lines = <INFILE>;
9     close INFILE;
10
11     foreach $line (@lines) {
12         my $oldline = $line;
13         $line =~ s/(\.\.\.|\.\s\.\s\.)/<ch.ellips\/>/g;
14         $line =~ tr/\t/ /;
15         $line =~ s/\s{2,}/ /g;
16         $line =~ s/\&\s/\&amp\; /g;
17         $line =~ tr/\"\`\222\221/\'/;
18         $line =~ s/(Random\sNumber\sTable)/<a idref=\"random\">$1<\/a>/gi;
19         $line =~ s/(COMBAT\sSKILL|CLOSE\sCOMBAT\sSKILL|ENDURANCE|WILLPOWER|\bCS\b|\bEP\b)([^<])/<typ class="attribute">$1<\/typ>$2/g;
20         $line =~ s/(Action\sCharts?)/<a idref=\"action\">$1<\/a>/gi;
21         # \222 and \221 are some form of funky right and
22         # left quotes not present in ascii (of course) 
23         $line =~ tr/\227/-/;
24         # \227 is an em or en dash
25
26         $line =~ s/^\s*(.*)\s*$/$1\n/;
27     }
28
29     print @lines;
30 }