1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#!perl -w
print <<EOD;
<HTML>
<HEAD>
<TITLE>Macro Commands</TITLE>
</HEAD>
<BODY>
EOD
sub out {
my $lin = $_[0];
$lin =~ s/\&/\&./og;
$lin =~ s/\</\</og;
$lin =~ s/\>/\>/og;
return $lin;
}
sub out_seealso {
my $first = 1;
my $section = $_[0];
print "<P><B>SEE ALSO:</B>\n";
if ($#see_also >= 0) {
foreach $see (@see_also) {
if (!$first) { print ", "; }
print $see;
$first = 0;
}
}
if (defined $section) {
if (!$first) { print ", "; }
print qq|<A HREF="#$sec_ref{$section}">| . out($section) . "</A>";
$first = 0;
} else {
foreach (@sections) {
if (!$first) { print ", "; }
print qq|<A HREF="#$sec_ref{$_}">| . out($_) . "</A>";
$first = 0;
}
}
if (!$first) { print "."; }
@see_also = ();
}
sub out_contents {
my $section = $_[0];
print "<UL>\n";
foreach (@{$contents{$section}}) {
print qq|<LI><A HREF="#ec.$_">| . $_ . "</A>\n";
}
print "</UL>\n";
}
sub out_sections {
print "<UL>\n";
foreach (@sections) {
print qq|<LI><A HREF="#$sec_ref{$_}">| . $_ . "</A>\n";
}
print "</UL>\n";
}
sub new_command {
if ($newcommand) {
if ($output) {
if ($was_section) {
out_seealso();
} else {
out_seealso($section);
}
print qq|<HR><H2><A NAME="ec.$command">| . out($command) . "</A></H2>\n";
} else {
push(@{$contents{$section}}, $command);
}
$was_command = 1;
$newcommand = 0;
$was_section = 0;
}
}
@file = <>;
for ($output = 0; $output <= 1; $output++) {
out_sections() if $output;
@see_also = ();
$was_command = 0;
foreach (@file) {
if (m|Ex([A-Za-z]+)\,|) {
$command = $1;
$newcommand = 1;
} elsif (m|///\s*(.*)|) {
$text = $1;
new_command();
if ($output) {
if ($text eq '') {
print '<P>' unless $was_command || $was_section;
} else {
print out($text), "\n";
}
}
} elsif (m|//\\\s*(.*)|) {
$text = $1;
new_command();
if ($output) {
if ($text eq '') {
print '<BR>' unless $was_command || $was_section;
} else {
print $text, "\n";
}
}
} elsif (m|//\&\s*(.*)|) {
push (@see_also, $1);
} elsif (m|//<([^>]*)>\s*(.*)|) {
out_seealso($section) if $was_command && $output;
$ref = $1;
$section = $2;
if ($output) {
print qq|<HR><H1><A NAME="$ref">| . out($section) . "</A></H1>\n";
out_contents($section);
} else {
$contents{$section} = [];
$sec_ref{$section} = $ref;
#$ref_sec{$ref} = $section;
push(@sections, $section);
}
$newcommand = 0;
$was_section = 1;
$was_command = 0;
}
}
}
out_seealso($section);
print <<EOD;
</BODY>
</HTML>
EOD
|