#!/usr/bin/perl -w # # : Mike Burns : netgeek@downcity.net : http://micron999.com : # # Converts ROTFL to a WWW format # (HTML+CSS). I'll try to keep it HTML 4.0 Strict plus CSS2. I may have to # go transitional, though. # # Some problems: # The table of contents isn't working. # Multiple records are on one page. # Support for overlined text is unavailable in Netscape 4.x and below. # Double under- or overlining isn't supported in CSS/HTML. # # I am not a Perl wizard - this isn't even my native programming language. # It's just best for what I need. Fix my errors as needed. # # Written for ROTFL 0.6.2. # # The tags: # R == # H == # # == # c == ... # l ==
  • ...
  • # o == ... # r == ... # u == ... # A ==
    ...
    # D ==
    ...
    # I ==             # L == # L # ==
      ...
    # O == ... # T == ...

    ...

    # U == ... # V == ignore for now, possible checking for later? # use strict; # Versioning information. my $major=0; my $minor=2; my $patch=0; my $center=''; my $litem=''; my $overline=''; my $right=''; my $underline=''; my $author=''; my $date=''; my $indent=''; my $title=''; my $para=''; my $comment=''; my $TAGS='cloruADHILORTUV#'; my $ltype=0; my $record=0; my $rotfl; my $htmlIn; my $tag; $rotfl=$ARGV[0]; $htmlIn=$rotfl.".html" unless $htmlIn=$ARGV[1]; if($rotfl=~/-h/ || $rotfl=~/--help/) { help(); } elsif($rotfl=~/-v/ || $rotfl=~/--version/) { print "ROTFL to HTML/CSS converter "; print "version ${major}.${minor}.${patch} "; print "for ROTFL version 0.6.2\n"; exit; } open(ROTFL, "$rotfl") || die "Cannot read $rotfl.\n"; open(HTML, ">$htmlIn") || die "Cannot write $htmlIn.\n"; while() { if(/^\.[\[\]][$TAGS]/) { if(/\.[\[\]]#/) { ($tag, $comment)=(split(/^\.\[# /, $_)); chomp($comment); print HTML "\n"; } if(/^\.\[R/) { print HTML "\n\n"; print HTML "\n"; } if(/^\.\[H/) { print HTML "\t\n"; } if(/^\.[\[\]]T/) { ($tag, $title)=(split(/^\.\[T /, $_)); chomp($title); print HTML "\t\t".$title."\n"; } if(/^\.[\[\]]A/) { ($tag, $author)=(split(/^\.\[A /, $_)); chomp($author); print HTML "\t\t\n"; } if(/^\.[\[\]]D/) { ($tag, $date)=(split(/^\.\[D /, $_)); chomp($date); print HTML "\t\t\n"; } if(/^\.\]H/) { print HTML "\t\n"; print HTML "\t\n"; if($title) { print HTML "\t\t

    ".$title."

    \n"; } } if(/^\.\[L #/) { print HTML "\t\t
      \n"; $ltype=2; } elsif(/^\.\[L/) { print HTML "\t\t
        \n"; $ltype=1; } if(/^\.[\[\]]l/) { ($tag, $litem)=(split(/^\.\[l /, $_)); chomp($litem); print HTML "\t\t\t
      • ".$litem."
      • \n"; } if(/^\.\]L/) { if($ltype==1) { print HTML "\t\t
      \n"; $ltype=0; } elsif($ltype==2) { print HTML "\t\t
    \n"; $ltype=0; } } if(/^\.[\[\]]I/) { ($tag, $indent)=(split(/^\.\[I /, $_)); chomp($indent); print HTML "\t\t

            "; print HTML "    ".$indent."

    \n"; } if(/^\.[\[\]]c/) { ($tag, $center)=(split(/^\.\[c /, $_)); chomp($center); print HTML "\t\t

    "; print HTML $center."

    \n"; } if(/^\.[\[\]]o/ || /^\.[\[\]]O/) { if(/^\.[\[\]]o/) { ($tag, $overline)=(split(/^\.\[o /, $_)); } if(/^\.[\[\]]O/) { ($tag, $overline)=(split(/^\.\[O /, $_)); } chomp($overline); print HTML "\t\t

    "; print HTML $overline."

    \n"; } if(/^\.[\[\]]r/) { ($tag, $right)=(split(/^\.\[r /, $_)); chomp($right); print HTML "\t\t

    "; print HTML $right."

    \n"; } if(/^\.[\[\]]u/ || /^\.[\[\]]U/) { if(/^\.[\[\]]u/) { ($tag, $underline)=(split(/^\.\[u /, $_)); } if(/^\.[\[\]]U/) { ($tag, $underline)=(split(/^\.\[U /, $_)); } chomp($underline); print HTML "\t\t

    "; print HTML $underline."

    \n"; } if(/^\.\]R/) { if($author || $date) { print HTML "\t\t
    "; } if($date) { print HTML $date." "; } if($author) { print HTML $author; } if($author || $date) { print HTML "
    \n"; } print HTML "\t\n"; print HTML "\n"; } } else { chomp($_); print HTML "\t\t

    ".$_."

    \n"; } } close(HTML); close(ROTFL); sub help { print "Use the source, Luke!\n"; print "Also, see\n * \n"; print " * .\n"; exit; }