genmodule: revert r52790
[AROS.git] / tools / cxref / FAQ-html.pl
blobab16eceea5a1effff516e17024342dbba0e5636e
1 #!/usr/bin/perl
4 # Copyright Andrew M. Bishop 1996.97,98,2001,03.
6 # Usage: FAQ-html.pl < FAQ > FAQ.html
9 $_=<STDIN>;
10 s/^ *//;
11 s/ *\n//;
12 $first=$_;
14 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n";
15 print "<HTML>\n";
16 print "\n";
17 print "<HEAD>\n";
18 print "<TITLE>$first</TITLE>\n";
19 print "</HEAD>\n";
20 print "\n";
21 print "<BODY>\n";
22 print "\n";
23 print "<h1>$first</h1>\n";
25 $questions=0;
26 $answers=0;
27 $pre=0;
28 $blank=1;
30 while(<STDIN>)
32 chop;
34 s/&/&amp;/g;
35 s/</&lt;/g;
36 s/>/&gt;/g;
38 next if(m/^ *=+ *$/);
39 next if ($_ eq "--------------------");
40 $pre++,$blank=0,next if($pre==1 && $_ eq "");
41 $blank=1,next if($pre!=1 && $_ eq "");
42 $pre++ if($pre);
44 if ($_ eq "--------------------------------------------------------------------------------")
46 $pre=0,print "</pre>\n" if($pre);
47 print "<hr>\n";
48 $answers++ if( $answers);
49 $questions=0,$answers=1 if( $questions);
50 $questions=1 if(!$questions && !$answers);
52 elsif (m/^(Section [0-9]+)/)
54 $section = $1;
55 $section =~ tr/ /-/;
57 $pre=0,print "</pre>\n" if($pre);
58 print "<p><b><a href=\"#$section\">$_</a></b>\n" if($questions);
59 print "<h2><a name=\"$section\">$_</a></h2>\n" if($answers);
61 elsif (m/^(Q [0-9]+.[0-9]+[a-z]*)/)
63 $question = $1;
64 $question =~ tr/ /-/;
66 $blank=0,$pre=0,print "</pre>\n" if($pre);
67 print "<p><a href=\"#$question\">$_</a>\n" if($questions);
68 print "<h3><a name=\"$question\">$_</a></h3>\n" if($answers);
69 $pre=1,print "<pre>\n" if($answers);
71 elsif (m/\((See Q [0-9]+.[0-9]+[a-z]*)\)/)
73 $question = substr($1,4);
74 $question =~ tr/ /-/;
75 $href=$1;
77 s%$1%<a href="#$question">$href</a>% if($answers);
78 print "$_\n";
80 elsif (m%(^|[^\'\"])(http://[A-Za-z0-9-_.]+/[/A-Za-z0-9-_.~]*)%)
82 $href=$2;
84 s%$2%<a href="$href">$href</a>%;
85 print "$_\n";
87 else
89 $blank=0,print "\n" if($blank);
90 print "$_\n";
94 print "</BODY>\n";
95 print "\n";
96 print "</HTML>\n";