X-Git-Url: http://git.projectaon.org/?p=project-aon.git;a=blobdiff_plain;f=scripts%2Fcorrtohtml.pl;fp=scripts%2Fcorrtohtml.pl;h=0000000000000000000000000000000000000000;hp=2d64606e85289cde02616daf4302be05b4913a0e;hb=97545603aea8298f1eceb604ff65085cc7adfced;hpb=53d5f97cd1474231d3f343c70918a91ade6466e2 diff --git a/scripts/corrtohtml.pl b/scripts/corrtohtml.pl deleted file mode 100755 index 2d64606..0000000 --- a/scripts/corrtohtml.pl +++ /dev/null @@ -1,431 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -my $programName = 'corrtohtml'; -my $usage = "$programName [options] [inputFile [inputFile2 ...]]\n" . - "\t-b bookCode convert unspecified corrections to this book\n" . - "\t-o outputFile\n" . - "\t-i editorsInitials\n" . - - "\t-s strips book information\n" . - "\t-v verbose reporting\n"; - -my $optsProcessed = 0; -my $outFile = ""; -my $editorInitials = ""; -my $stripBookInfo = 0; -my $verbose = 0; -my $bookCode = ""; -my $bookCodeReport = ""; - -while( $#ARGV > -1 && not $optsProcessed ) { - my $commandLineItem = shift @ARGV; - if( $commandLineItem eq "-b" ) { - $bookCode = shift @ARGV or die $usage; - &validateBookCode( $bookCode ) or die( "Error ($programName): unrecognized bookcode on command line \"$bookCode\"" ); - } - elsif( $commandLineItem eq "-o" ) { - $outFile = shift @ARGV or die $usage; - } - elsif( $commandLineItem eq "-i" ) { - $editorInitials = shift @ARGV or die $usage; - } - elsif( $commandLineItem eq "-s" ) { - $stripBookInfo = 1; - } - elsif( $commandLineItem eq "-v" ) { - $verbose = 1; - } - elsif( $commandLineItem eq "--help" ) { - print $usage and exit; - } - else { - unshift @ARGV, $commandLineItem; - $optsProcessed = 1; - } -} - -my @lines = <>; -my $document = ""; -my %sectionDocLookup = ( - '_unknown' => '_unknown', - 'toc' => 'toc', - 'title' => 'title', - 'dedicate' => 'dedicate', - 'acknwldg' => 'acknwldg', - 'credits' => 'acknwldg', - 'coming' => 'coming', - 'tssf' => 'tssf', - 'gamerulz' => 'gamerulz', - 'discplnz' => 'discplnz', - 'camflage' => 'discplnz', - 'hunting' => 'discplnz', - 'sixthsns' => 'discplnz', - 'tracking' => 'discplnz', - 'healing' => 'discplnz', - 'wepnskll' => 'discplnz', - 'mndshld' => 'discplnz', - 'mndblst' => 'discplnz', - 'anmlknsp' => 'discplnz', - 'mindomtr' => 'discplnz', - 'mksumary' => 'discplnz', - 'anmlctrl' => 'discplnz', - 'curing' => 'discplnz', - 'invsblty' => 'discplnz', - 'psisurge' => 'discplnz', - 'psiscrn' => 'discplnz', - 'dvnation' => 'discplnz', - 'wpnmstry' => 'discplnz', - 'anmlmstr' => 'discplnz', - 'deliver' => 'discplnz', - 'assimila' => 'discplnz', - 'hntmstry' => 'discplnz', - 'pthmnshp' => 'discplnz', - 'kaisurge' => 'discplnz', - 'kaiscrn' => 'discplnz', - 'nexus' => 'discplnz', - 'gnosis' => 'discplnz', - 'magi' => 'discplnz', - 'kalchemy' => 'discplnz', - 'powers' => 'powers', - 'lessmcks' => 'powers', - 'alchemy' => 'powers', - 'sorcery' => 'powers', - 'enchant' => 'powers', - 'elementl' => 'powers', - 'prophecy' => 'powers', - 'psycmncy' => 'powers', - 'evcation' => 'powers', - 'highmcks' => 'powers', - 'thamtrgy' => 'powers', - 'telergy' => 'powers', - 'physirgy' => 'powers', - 'theurgy' => 'powers', - 'visionry' => 'powers', - 'necrmncy' => 'powers', - 'staff' => 'powers', - 'moonston' => 'powers', - 'equipmnt' => 'equipmnt', - 'howcarry' => 'equipmnt', - 'howmuch' => 'equipmnt', - 'howuse' => 'equipmnt', - 'cmbtrulz' => 'cmbtrulz', - 'evasion' => 'cmbtrulz', - 'lorecrcl' => 'lorecrcl', - 'lcbonus' => 'lorecrcl', - 'levels' => 'levels', - 'primate' => 'levels', - 'tutelary' => 'levels', - 'mentora' => 'levels', - 'scion' => 'levels', - 'archmstr' => 'levels', - 'prncpln' => 'levels', - 'imprvdsc' => 'imprvdsc', - 'guardian' => 'imprvdsc', - 'sunkght' => 'imprvdsc', - 'sunlord' => 'imprvdsc', - 'kaiwisdm' => 'kaiwisdm', - 'sage' => 'sage', - 'numbered' => 'numbered', - 'part1' => 'part1', - 'part2' => 'part2', - 'ill1' => 'ill1', - 'ill2' => 'ill2', - 'ill3' => 'ill3', - 'ill4' => 'ill4', - 'ill5' => 'ill5', - 'ill6' => 'ill6', - 'ill7' => 'ill7', - 'ill8' => 'ill8', - 'ill9' => 'ill9', - 'ill10' => 'ill10', - 'ill11' => 'ill11', - 'ill12' => 'ill12', - 'ill13' => 'ill13', - 'ill14' => 'ill14', - 'ill15' => 'ill15', - 'ill16' => 'ill16', - 'ill17' => 'ill17', - 'ill18' => 'ill18', - 'ill19' => 'ill19', - 'ill20' => 'ill20', - 'passing' => 'passing', - 'map' => 'map', - 'action' => 'action', - 'crsumary' => 'crsumary', - 'smevazn' => 'crsumary', - 'crtable' => 'crtable', - 'random' => 'random', - 'errata' => 'errata', - 'errintro' => 'errata', - 'errerr' => 'errata', - 'footnotz' => 'footnotz', - 'illstrat' => 'illstrat', - 'primill' => 'illstrat', - 'secill' => 'illstrat', - 'license' => 'license', - 'lic-pre' => 'license', - 'lic-1' => 'license', - 'lic-1-0' => 'license', - 'lic-1-1' => 'license', - 'lic-1-2' => 'license', - 'lic-1-3' => 'license', - 'lic-1-4' => 'license', - 'lic-1-5' => 'license', - 'lic-1-6' => 'license', - 'lic-1-7' => 'license', - 'lic-2' => 'license', - 'lic-2-0' => 'license', - 'lic-2-1' => 'license', - 'lic-2-2' => 'license', - 'lic-2-3' => 'license', - 'lic-2-4' => 'license', - 'lic-2-5' => 'license', - 'lic-3' => 'license', - 'lic-3-0' => 'license', - 'lic-3-1' => 'license', - 'lic-4' => 'license', - 'lic-4-0' => 'license', - 'lic-5' => 'license', - 'lic-5-0' => 'license', - 'lic-6' => 'license', - 'lic-6-0' => 'license', - 'lic-6-1' => 'license' -); - -my %sectionTitleLookup = ( - '_unknown' => '_unknown', - 'toc' => 'Table of Contents', - 'title' => 'Title Page', - 'dedicate' => 'Dedication', - 'acknwldg' => 'Acknowledgements', - 'coming' => 'Of the Coming of Grey Star', - 'tssf' => 'The Story So Far . . .', - 'gamerulz' => 'The Game Rules', - 'discplnz' => '. . . Disciplines', - 'powers' => 'Magical Powers', - 'equipmnt' => 'Equipment', - 'cmbtrulz' => 'Rules for Combat', - 'lorecrcl' => 'Lore-circles of the Magnakai', - 'levels' => 'Levels of . . . Mastery', - 'imprvdsc' => 'Improved . . . Disciplines', - 'kaiwisdm' => '. . . Wisdom', - 'sage' => 'Sage Advice', - 'numbered' => 'Numbered Sections', - 'part1' => 'Part I', - 'part2' => 'Part II', - 'ill1' => 'Illustration 1', - 'ill2' => 'Illustration 2', - 'ill3' => 'Illustration 3', - 'ill4' => 'Illustration 4', - 'ill5' => 'Illustration 5', - 'ill6' => 'Illustration 6', - 'ill7' => 'Illustration 7', - 'ill8' => 'Illustration 8', - 'ill9' => 'Illustration 9', - 'ill10' => 'Illustration 10', - 'ill11' => 'Illustration 11', - 'ill12' => 'Illustration 12', - 'ill13' => 'Illustration 13', - 'ill14' => 'Illustration 14', - 'ill15' => 'Illustration 15', - 'ill16' => 'Illustration 16', - 'ill17' => 'Illustration 17', - 'ill18' => 'Illustration 18', - 'ill19' => 'Illustration 19', - 'ill20' => 'Illustration 20', - 'passing' => 'Passing of the Shianti', - 'map' => 'map', - 'action' => 'Action Chart', - 'crsumary' => 'Combat Rules Summary', - 'crtable' => 'Combat Results Table', - 'random' => 'Random Number Table', - 'errata' => 'Errata', - 'footnotz' => 'Footnotes', - 'illstrat' => 'Table of Illustrations', - 'license' => 'Project Aon License' -); - -if( $bookCode ne "" ) { - $bookCodeReport = " [$bookCode]"; -} -################################################################################ -# Normalize Lines and Whitespace - -foreach my $line (@lines) { - $line =~ tr/\n\r/ /; - $document .= $line; -} -$document =~ s/[[:space:]]{2,}/ /g; # collapse spaces -$document =~ s/(\(er?\)|\(ne?\)|\(ft?\)|\(ce\)|\(cn\)|\(cf\)|\(re\)|\(rn\)|\(rf\)|\(\?\??\))/\n$1/g; # break lines -$document =~ s/^[[:space:]]*\n//g; # remove blank lines -@lines = split( m/ *\n/, $document ); - -################################################################################ -# Translate - -my $commentRegex = qr{\[[[:space:]]*(([^[:space:]:]*)[[:space:]]*:)?[[:space:]]*([^]]*)\]}; -my $sectionNumberRegex = qr{^\(([^)][^)])*\) # type: $1 - [[:space:]]* - ([[:digit:]]*[[:alpha:]]+[[:space:]]+)? # book: $2 - ([[:digit:]]+) # section: $3 - (?:[[:space:]]+ - \#([[:digit:]]+))? # issue: $4 - [[:space:]]*: - (.*?) # correction: $5 - [[:space:]]*$}x; -my $sectionIDRegex = qr{^\(([^)][^)])*\) # type: $1 - [[:space:]]* - ([[:digit:]]*[[:alpha:]]+[[:space:]]+)? # book: $2 - ([^:[:space:]]*) # section: $3 - (?:[[:space:]]+ - \#([[:digit:]]+))? # issue: $4 - [[:space:]]*: - (.*?) # correction: $5 - [[:space:]]*$}x; - -foreach my $line (@lines) { - $line =~ s{&} {&}g; # escape for HTML - $line =~ s{<} {<}g; # " - $line =~ s{>} {>}g; # " - - while( $line =~ m{$commentRegex} ) { - if( (not defined( $2 )) || $2 eq "" ) { - $line =~ s{$commentRegex}{