#!/usr/ucb/perl5 $depth = 0; $section = 1; $note = 1; $abstract = 0; $current = fh000; $tag = "content000"; sub o2html { local($current) = @_; %content = (); print $fh < RogueRogue line: while (<$current>) { chop; # strip record separator if(!/^/\>/g; s%href="([^"]+")\s*([^\s]*)%$2%g; } if( (!/^\s/) && (!/^$/) && $pre) { print $fh "\n"; $pre = 0; } if (/^-*input: (.*)/) { $fdbase = $current; $fdbase ++; open($fdbase,"<$1"); push(@depend,$1); # print STDOUT "$1 "; do o2html($fdbase); next line; } if (/^-title:/) { $title = substr($_, 8, length($_) - 7); &title($title); next line; } if (/^-*comment-begin:/) { while (<$current>) { next line if (/^-*comment-end:/) ; } last line; } if (/^--*date:/) { for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) { ; } $tmp += 5; $day = substr($_, $tmp, length($_) - $tmp + 1); next line; } if (/^--*number:/) { for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) { ; } $tmp += 7; $number = substr($_, $tmp, length($_) - $tmp + 1); next line; } if (/^--*note:/) { $note = 2; printf $fh "\n"; next line; } if (/^--*author:/) { for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) { ; } $tmp += 7; $author = substr($_, $tmp, length($_) - $tmp + 1); printf $fh "$author\n"; next line; } if (/^--*abstract:/) { $abstract = 1; printf $fh "\n"; next line; } if (/^-/) { if ($abstract == 1) { printf $fh "\n"; $abstract = 0; } if ($note) { if ($note == 2) { printf $fh "\n"; $note = 0; } } for ($depth = 1; substr($_, $depth, 1) eq '-'; $depth++) { ; } $section_title = substr($_, $depth, length($_) - $depth + 1); if(! defined($title)) { &title($section_title); } print $fh "
\n"; print $fh "",$section_title, "\n"; $section++; $content{$tag} = " " x $depth . $section_title; $tag++; next line; } elsif (/^\s/) { if(! $pre) { print $fh "
\n";
	    $pre = 1;
	}
	$paragraph = 0;
	print $fh $_,"\n";
    } elsif (/^$/) {
	if(! $pre && ! $paragraph) {
	    print $fh $_,"

\n"; $paragraph = 1; } } elsif (!/^-/) { print $fh $_,"\n"; $paragraph = 0; } } if (defined $section_title) { print $fh "

Content

\n"; print $fh "
    \n"; for (sort keys %content ) { print $fh "
  1. ",$content{$_},"\n"; } print $fh "
\n"; } printf $fh "\n"; } foreach $arg (@ARGV) { $fdbase = $current; $fdbase ++; open($fdbase,"<$arg") || die("$arg cannot open"); $out = $arg; $out =~ s/\.ind$//; $out =~ s/\.index$//; $out .= ".html"; $fh = "out00"; if($arg eq $out) { $out .= ".html"; } open($fh,">$out"); do o2html($fdbase); } sub title { $title = $_[0]; print $fh "\n"; print $fh "$title\n"; print $fh "\n"; print $fh "\n"; print $fh "

$title

\n"; print $fh "content
\n"; print $fh "\n"; } # end