#! /usr/bin/perl -w use strict; sub escape { s/\&/\&/g; s/\/\>/g; } # TOC my $l = ""; my $n = 0; print "

Table of Contents

\n"; my $dirty = 0; while () { escape($_); last if /^=+$/; next if /^\w*$/; if (/^\[([^\[]+)\] (.*)/) { print "\n" if $dirty; $l = $1; $n = 0; $dirty = 1; print "

$1 $2

\n"; print "
    \n"; } elsif (/^\* (.*)/) { $n++; print "
  1. $1
  2. \n"; } } print "
\n" if $dirty; # Contents my $top = ' '; $l = ""; $n = 0; my $pre = 0; my $snip = 0; while () { next if /^=+$/; if (/^----- snip:start -----/) { print "
";
	$snip = 1;
	next;
    }
    if ($snip) {
	if (/^----- snip:end -----/) {
	    print "
"; $snip = 0; } else { escape($_); print; } next; } if (/^ /) { print "
" unless $pre;
	$pre = 1;
	escape($_);
	print;
	next;
    }
    if ($pre) {
	print "
\n"; $pre = 0; } if (/^$/) { print "

"; next; } if (//) { chomp; $_ .= ; } s//\@\@\@$1\@\@\@/; escape($_); s/\@\@\@(.*?)\@\@\@/$1<\/a>/; if (s/\((.?)\)/XX$1XX/g) { while (/([A-Za-z_\.]*)XX(.?)XX/) { foreach my $section ("apps", "ssl", "crypto") { if (-f "../docs/$section/$1.html") { s|([A-Za-z_\.]*)XX(.?)XX|$1($2)|; goto found; } } s/XX(.?)XX/($1)/; found: } } if (/^\[([^\[]+)\] =+/) { $l = $1; $n = 0; print "


\n"; print "

[$1] $top

\n"; } elsif (/^\* (.*)/) { $n++; print "\n

$n. $1$top

\n"; } elsif (/^$/) { print "

"; } else { print; } } exit(0);