#!/usr/local/bin/perl -w #When run at the command line, default is to hide [interludes], #[interludes2], and [whiz-games]. This can be overridden with: # '-i' (includes interludes as part of the running text), # '-i2' (includes interludes as the right column of a two-column table), and # '-w' (includes [whiz-games] as part of the running transcript). #Two other command line options are accepted, the first (required) used #as the name of the file to be converted, and the second (optional) used #as the name of the output file. Any other options are ignored. If the #output file is not provided, '.txt' will be stricken and '.html' appended #to the input filename, or if -i2 is on, '_int.html' appended. #A potential change is to hide 7th-sea related channels when -w is on. #Another feature of this script is that it auto-links URLs. In particular, #if the filename at the end of the URL can be found in the current directory, #the link is to the local copy of the file, not the given URL. Useful to make #sure game-specific supplementary materials are archived properly. Note that #this means you have to run the script from the directory the transcript #resides. use strict; my $inputfile=""; my $outputfile=""; my $interluded=0; my $whizgame=0; my $interlude_warn=0; my @mainchan = ("[7thsea]"); my @secondary = ("[aboveground]", "[belowground]", "[vodacce]", "[Castillian]", "[roguespace]", "[CoC]", "[colonial]", "[eisen]", "[nobilis]", "[D&D]", "[musketeers]", "[early_musketeers]", "[oneshot]", "[late_musketeers]", "[ussura]", "[shadowrun]"); my @snark = ("[Crows-Nest]"); #, "[peanut-gallery]"); my @whizgames = ("[whiz-games]"); my @interludes = ("[interludes]", "[interludes2]", "[cterlude]", "[backstage]"); my @interludes1 = ("[interludes]", "[cterlude]"); #Anything in interludes not in interludes1 is considered interludes2. my @spoilers = ("[spoilers]", "[Granolith]", "[duchess-escape]", "[ellric_fan]"); my @ignore = ("%", "[peanut-gallery]", "[rpg]"); #grep {$_ eq $foo} @bar foreach my $opt (@ARGV) { if ($opt eq "-i") { $interluded=1; print "Interludes included as part of regular transcript.\n"; } elsif ($opt eq "-i2") { $interluded=2; print "Interludes included as side-table.\n"; } elsif ($opt eq "-w") { $whizgame=1; print "Including [whiz-games].\n"; } elsif ($inputfile eq "") { $inputfile = $opt; } else { $outputfile = $opt; } } if ($interluded==0) { print "Hiding interludes.\n"; } if ($whizgame==0) { print "Hiding [whiz-games].\n"; } open(INPUT, "$inputfile") || die "cannot open $inputfile: $!"; if ($outputfile eq "") { $outputfile = $inputfile; $outputfile =~ s/\.txt//; if ($interluded==2) { $outputfile = $outputfile."_int.html"; } else { $outputfile = $outputfile.".html"; } } open(OUTPUT, ">$outputfile") || die "cannot open $outputfile: $!"; print OUTPUT "\n
\n| \n"; } while ((my $inputline = )) { $last_line = $interlude; my $firstword = $inputline; chomp($firstword); $firstword =~ s/\ .*//; if (($firstword =~ /<.*/)) { $inputline =~ s/</g; $inputline =~ s/>/>/g; $inputline = "$inputline<\/i>"; } else { $inputline =~ s/</g; $inputline =~ s/>/>/g; } if( $inputline =~ /\|/ && $inputline !~ /rolls/ && length($inputline)<100){ $preformat = $preformat + 1; } elsif ($preformat > 0) { print OUTPUT "\n"; $preformat = 0; } if (grep {$_ eq $firstword} @interludes) { if ($interluded==0) { $inputline = ""; $interlude_warn = 1; } else { $interlude = 1; if (grep {$_ eq $firstword} @interludes1) { $inputline = "$inputline"; } else { $inputline = "$inputline"; } } } else { $interlude = 0; if (grep {$_ eq $firstword} @mainchan) { $inputline = "$inputline"; } elsif (grep {$_ eq $firstword} @snark) { $inputline = "$inputline"; } elsif (grep {$_ eq $firstword} @secondary) { $inputline = "$inputline"; } elsif (grep {$_ eq $firstword} @whizgames) { if ($whizgame == 1) { $inputline = "$inputline"; } else { $inputline = ""; } } elsif (grep {$_ eq $firstword} @ignore) { $inputline = ""; } elsif (grep {$_ eq $firstword} @spoilers) { $inputline =~ s/\Q$firstword //; $inputline = "$firstword $inputline"; } elsif ($firstword =~ /\([Ff]rom/) { $inputline =~ s/(\([Ff]rom .*?\))/$1<\/i>/; } elsif ( $inputline =~ /\|/ && $inputline =~ /rolls/ ){ $inputline = "$inputline"; } else { if (!($inputline =~ //)) { $inputline =~ s/\Q$firstword\E//; $inputline = "$firstword$inputline"; } } } my ($filename, $url, $inputtest); $inputtest = $inputline; while ($inputtest =~ /http/) { #print "Input line = <$inputline>\n"; $url = $inputtest; $url =~ s!.*?(http://.*?)($|[ >)",\s]).*!$1!s; #"); $filename = $url; $filename =~ s|.*/(.*)|$1|; # $url = qq/$url/; print "URL = $url, filename = $filename\n"; if (-e $filename) { $inputline =~ s|\Q$url|$url|; } else { $inputline =~ s|\Q$url|$url|; #; } $inputtest =~ s/http//; } # $inputline =~ s|(http://.*?)($|[ >)"\n])|$1$2|g; #"); if ($interluded == 2) { if ($preformat == 1) { $inputline = "\n$inputline"; } if ($preformat > 1) { $inputline = "$inputline"; } if (($last_line eq 0) && ($interlude eq 0)) { $inputline = " | ||
| $inputline | "; } elsif (($last_line eq 0) && ($interlude eq 1)) { $inputline = "$inputline | |
| $inputline | "; } elsif (($last_line eq 1) && ($interlude eq 1)) { $inputline = "$inputline | |