annotate src/fftw-3.3.5/doc/FAQ/m-html.pl @ 42:2cd0e3b3e1fd

Current fftw source
author Chris Cannam
date Tue, 18 Oct 2016 13:40:26 +0100
parents
children
rev   line source
Chris@42 1 ## HTML output
Chris@42 2 # Copyright (C) 1993-1995 Ian Jackson.
Chris@42 3
Chris@42 4 # This file is free software; you can redistribute it and/or modify
Chris@42 5 # it under the terms of the GNU General Public License as published by
Chris@42 6 # the Free Software Foundation; either version 2, or (at your option)
Chris@42 7 # any later version.
Chris@42 8
Chris@42 9 # It is distributed in the hope that it will be useful,
Chris@42 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@42 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@42 12 # GNU General Public License for more details.
Chris@42 13
Chris@42 14 # You should have received a copy of the GNU General Public License
Chris@42 15 # along with GNU Emacs; see the file COPYING. If not, write to
Chris@42 16 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Chris@42 17 # Boston, MA 02111-1307, USA.
Chris@42 18
Chris@42 19 # (Note: I do not consider works produced using these BFNN processing
Chris@42 20 # tools to be derivative works of the tools, so they are NOT covered
Chris@42 21 # by the GPL. However, I would appreciate it if you credited me if
Chris@42 22 # appropriate in any documents you format using BFNN.)
Chris@42 23
Chris@42 24 %saniarray= ('<','lt', '>','gt', '&','amp', '"','quot');
Chris@42 25
Chris@42 26 sub html_init {
Chris@42 27 $html_prefix = './'.$prefix;
Chris@42 28 $html_prefix =~ s:^\.//:/:;
Chris@42 29 system('rm','-r',"$html_prefix.html");
Chris@42 30 system('mkdir',"$html_prefix.html");
Chris@42 31 open(HTML,">$html_prefix.html/index.html");
Chris@42 32 print HTML "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n";
Chris@42 33 print HTML "<html>\n";
Chris@42 34 $html_needpara= -1;
Chris@42 35 $html_end='';
Chris@42 36 chop($html_date=`date '+%d %B %Y'`);
Chris@42 37 chop($html_year=`date '+%Y'`);
Chris@42 38 }
Chris@42 39
Chris@42 40 sub html_startup {
Chris@42 41 print HTML <<END;
Chris@42 42 <head><title>
Chris@42 43 $user_title
Chris@42 44 </title>
Chris@42 45 <link rev="made" href="mailto:$user_authormail">
Chris@42 46 <link rel="Contents" href="index.html">
Chris@42 47 <link rel="Start" href="index.html">
Chris@42 48 <META name="description"
Chris@42 49 content="Frequently asked questions and answers (FAQ) for FFTW.">
Chris@42 50 <link rel="Bookmark" title="FFTW FAQ" href="index.html">
Chris@42 51 <LINK rel="Bookmark" title="FFTW Home Page"
Chris@42 52 href="http://www.fftw.org">
Chris@42 53 <LINK rel="Bookmark" title="FFTW Manual"
Chris@42 54 href="http://www.fftw.org/doc/">
Chris@42 55 </head><body text="#000000" bgcolor="#FFFFFF"><h1>
Chris@42 56 $user_title
Chris@42 57 </h1>
Chris@42 58 END
Chris@42 59 &html_readrefs($_[0]);
Chris@42 60 if (length($user_copyrightref)) {
Chris@42 61 local ($refn) = $qrefn{$user_copyrightref};
Chris@42 62 if (!length($refn)) {
Chris@42 63 warn "unknown question (copyright) `$user_copyrightref'";
Chris@42 64 }
Chris@42 65 $refn =~ m/(\d+)\.(\d+)/;
Chris@42 66 local ($s,$n) = ($1,$2);
Chris@42 67 $html_copyrighthref= ($s == $html_sectionn)?'':"section$s.html";
Chris@42 68 $html_copyrighthref.= "#$qn2ref{$s,$n}";
Chris@42 69 }
Chris@42 70 }
Chris@42 71
Chris@42 72 sub html_close {
Chris@42 73 print HTML $html_end,"<address>\n$user_author\n";
Chris@42 74 print HTML "- $html_date\n</address><br>\n";
Chris@42 75 print HTML "Extracted from $user_title,\n";
Chris@42 76 print HTML "<A href=\"$html_copyrighthref\">" if length($html_copyrighthref);
Chris@42 77 print HTML "Copyright &copy; $html_year $user_copyholder.";
Chris@42 78 print HTML "</A>" if length($html_copyrighthref);
Chris@42 79 print HTML "\n</body></html>\n";
Chris@42 80 close(HTML);
Chris@42 81 }
Chris@42 82
Chris@42 83 sub html_startmajorheading {
Chris@42 84 local ($ref, $this,$next,$back) = @_;
Chris@42 85 local ($nextt,$backt);
Chris@42 86 $this =~ s/^Section /section/; $html_sectionn= $ref;
Chris@42 87 $next =~ s/^Section /section/ && ($nextt= $sn2title{$'});
Chris@42 88 $back =~ s/^Section /section/ ? ($backt= $sn2title{$'}) : ($back='');
Chris@42 89 if ($html_sectionn) {
Chris@42 90 &html_close;
Chris@42 91 open(HTML,">$html_prefix.html/$this.html");
Chris@42 92 print HTML "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n";
Chris@42 93 print HTML "<html>\n";
Chris@42 94 $html_end= "<hr>\n";
Chris@42 95 $html_end.= "Next: <a href=\"$next.html\" rel=precedes>$nextt</a>.<br>\n"
Chris@42 96 if $next;
Chris@42 97 $html_end.= "Back: <a href=\"$back.html\" rev=precedes>$backt</a>.<br>\n"
Chris@42 98 if $back;
Chris@42 99 $html_end.= "<a href=\"index.html\" rev=subdocument>";
Chris@42 100 $html_end.= "Return to contents</a>.<p>\n";
Chris@42 101 print HTML <<END;
Chris@42 102 <head><title>
Chris@42 103 $user_brieftitle - Section $html_sectionn
Chris@42 104 </title>
Chris@42 105 <link rev="made" href="mailto:$user_authormail">
Chris@42 106 <link rel="Contents" href="index.html">
Chris@42 107 <link rel="Start" href="index.html">
Chris@42 108 END
Chris@42 109 print HTML "<link rel=\"Next\" href=\"$next.html\">" if $next;
Chris@42 110 print HTML "<link rel=\"Previous\" href=\"$back.html\">" if $back;
Chris@42 111 print HTML <<END;
Chris@42 112 <link rel="Bookmark" title="FFTW FAQ" href="index.html">
Chris@42 113 </head><body text="#000000" bgcolor="#FFFFFF"><h1>
Chris@42 114 $user_brieftitle - Section $html_sectionn <br>
Chris@42 115 END
Chris@42 116 $html_needpara= -1;
Chris@42 117 }
Chris@42 118 else {
Chris@42 119 print HTML "\n<h1>\n";
Chris@42 120 $html_needpara=-1;
Chris@42 121 }
Chris@42 122 }
Chris@42 123
Chris@42 124 sub html_endmajorheading {
Chris@42 125 print HTML "\n</h1>\n\n";
Chris@42 126 $html_needpara=-1;
Chris@42 127 }
Chris@42 128
Chris@42 129 sub html_startminorheading {
Chris@42 130 local ($ref, $this) = @_;
Chris@42 131 $html_needpara=0;
Chris@42 132 $this =~ m/^Question (\d+)\.(\d+)/;
Chris@42 133 local ($s,$n) = ($1,$2);
Chris@42 134 print HTML "\n<h2><A name=\"$qn2ref{$s,$n}\">\n";
Chris@42 135 }
Chris@42 136
Chris@42 137 sub html_endminorheading {
Chris@42 138 print HTML "\n</A></h2>\n\n";
Chris@42 139 $html_needpara=-1;
Chris@42 140 }
Chris@42 141
Chris@42 142 sub html_newsgroup { &arg('newsgroup'); }
Chris@42 143 sub html_endnewsgroup { &endarg('newsgroup'); }
Chris@42 144 sub html_do_newsgroup {
Chris@42 145 print HTML "<A href=\"news:$_[0]\"><code>$_[0]</code></A>";
Chris@42 146 }
Chris@42 147
Chris@42 148 sub html_email { &arg('email'); }
Chris@42 149 sub html_endemail { &endarg('email'); }
Chris@42 150 sub html_do_email {
Chris@42 151 print HTML "<A href=\"mailto:$_[0]\"><code>$_[0]</code></A>";
Chris@42 152 }
Chris@42 153
Chris@42 154 sub html_courier { print HTML "<code>" ; }
Chris@42 155 sub html_endcourier { print HTML "</code>"; }
Chris@42 156 sub html_italic { print HTML "<i>" ; }
Chris@42 157 sub html_enditalic { print HTML "</i>" ; }
Chris@42 158
Chris@42 159 sub html_docref { &arg('docref'); }
Chris@42 160 sub html_enddocref { &endarg('docref'); }
Chris@42 161 sub html_do_docref {
Chris@42 162 if (!defined($html_refval{$_[0]})) {
Chris@42 163 warn "undefined HTML reference $_[0]";
Chris@42 164 $html_refval{$n}='UNDEFINED';
Chris@42 165 }
Chris@42 166 print HTML "<A href=\"$html_refval{$_[0]}\">";
Chris@42 167 &recurse($_[0]);
Chris@42 168 print HTML "</A>";
Chris@42 169 }
Chris@42 170
Chris@42 171 sub html_readrefs {
Chris@42 172 local ($p);
Chris@42 173 open(HTMLREFS,"<$_[0]") || (warn("failed to open HTML refs $_[0]: $!"),return);
Chris@42 174 while(<HTMLREFS>) {
Chris@42 175 next if m/^\\\s/;
Chris@42 176 s/\s*\n$//;
Chris@42 177 if (s/^\\prefix\s*//) {
Chris@42 178 $p= $'; next;
Chris@42 179 } elsif (s/^\s*(\S.*\S)\s*\\\s*//) {
Chris@42 180 $_=$1; $v=$';
Chris@42 181 s/\\\\/\\/g;
Chris@42 182 $html_refval{$_}= $p.$v;
Chris@42 183 } else {
Chris@42 184 warn("ununderstood line in HTML refs >$_<");
Chris@42 185 }
Chris@42 186 }
Chris@42 187 close(HTMLREFS);
Chris@42 188 }
Chris@42 189
Chris@42 190 sub html_ftpsilent { &arg('ftpsilent'); }
Chris@42 191 sub html_endftpsilent { &endarg('ftpsilent'); }
Chris@42 192 sub html_do_ftpsilent {
Chris@42 193 if ($_[0] =~ m/:/) {
Chris@42 194 $html_ftpsite= $`;
Chris@42 195 $html_ftpdir= $'.'/';
Chris@42 196 } else {
Chris@42 197 $html_ftpsite= $_[0];
Chris@42 198 $html_ftpdir= '';
Chris@42 199 }
Chris@42 200 }
Chris@42 201
Chris@42 202 sub html_ftpon { &arg('ftpon'); }
Chris@42 203 sub html_endftpon { &endarg('ftpon'); }
Chris@42 204 sub html_do_ftpon {
Chris@42 205 #print STDERR "ftpon($_[0])\n";
Chris@42 206 $html_ftpsite= $_[0]; $html_ftpdir= '';
Chris@42 207 print HTML "<code>";
Chris@42 208 &recurse($_[0]);
Chris@42 209 print HTML "</code>";
Chris@42 210 }
Chris@42 211
Chris@42 212 sub html_ftpin { &arg('ftpin'); }
Chris@42 213 sub html_endftpin { &endarg('ftpin'); }
Chris@42 214 sub html_do_ftpin {
Chris@42 215 #print STDERR "ftpin($_[0])\n";
Chris@42 216 print HTML "<A href=\"ftp://$html_ftpsite$html_ftpdir$_[0]\"><code>";
Chris@42 217 &recurse($_[0]);
Chris@42 218 print HTML "</code></A>";
Chris@42 219 }
Chris@42 220
Chris@42 221 sub html_text {
Chris@42 222 print HTML "\n<p>\n" if $html_needpara > 0;
Chris@42 223 $html_needpara=0;
Chris@42 224 $html_stuff= &html_sanitise($_[0]);
Chris@42 225 while ($html_stuff =~ s/^(.{40,70}) //) {
Chris@42 226 print HTML "$1\n";
Chris@42 227 }
Chris@42 228 print HTML $html_stuff;
Chris@42 229 }
Chris@42 230
Chris@42 231 sub html_tab {
Chris@42 232 $htmltabignore++ || warn "html tab ignored";
Chris@42 233 }
Chris@42 234
Chris@42 235 sub html_newline { print HTML "<br>\n" ; }
Chris@42 236 sub html_startverbatim { print HTML "<pre>\n" ; }
Chris@42 237 sub html_verbatim { print HTML &html_sanitise($_[0]),"\n"; }
Chris@42 238 sub html_endverbatim { print HTML "</pre>\n" ; $html_needpara= -1; }
Chris@42 239
Chris@42 240 sub html_endpara {
Chris@42 241 $html_needpara || $html_needpara++;
Chris@42 242 }
Chris@42 243
Chris@42 244 sub html_finish {
Chris@42 245 &html_close;
Chris@42 246 }
Chris@42 247
Chris@42 248 sub html_startindex {
Chris@42 249 print HTML "<ul>\n";
Chris@42 250 }
Chris@42 251
Chris@42 252 sub html_endindex {
Chris@42 253 print HTML "</ul><hr>\n";
Chris@42 254 }
Chris@42 255
Chris@42 256 sub html_startindexitem {
Chris@42 257 local ($ref,$qval) = @_;
Chris@42 258 $qval =~ m/Q(\d+)\.(\d+)/;
Chris@42 259 local ($s,$n) = ($1,$2);
Chris@42 260 print HTML "<li><a href=\"";
Chris@42 261 print HTML ($s == $html_sectionn)?'':"section$s.html";
Chris@42 262 print HTML "#$qn2ref{$s,$n}\" rel=subdocument>Q$s.$n. ";
Chris@42 263 $html_indexunhead='';
Chris@42 264 }
Chris@42 265
Chris@42 266 sub html_startindexmainitem {
Chris@42 267 local ($ref,$s) = @_;
Chris@42 268 $s =~ m/\d+/; $s= $&;
Chris@42 269 print HTML "<br><br>" if ($s > 1);
Chris@42 270 print HTML "<li><b><font size=\"+2\"><a href=\"section$s.html\" rel=subdocument>Section $s. ";
Chris@42 271 $html_indexunhead='</font></b>';
Chris@42 272 }
Chris@42 273
Chris@42 274 sub html_endindexitem {
Chris@42 275 print HTML "</a>$html_indexunhead\n";
Chris@42 276 }
Chris@42 277
Chris@42 278 sub html_startlist {
Chris@42 279 print HTML "\n";
Chris@42 280 $html_itemend="<ul>";
Chris@42 281 }
Chris@42 282
Chris@42 283 sub html_endlist {
Chris@42 284 print HTML "$html_itemend\n</ul>\n";
Chris@42 285 $html_needpara=-1
Chris@42 286 }
Chris@42 287
Chris@42 288 sub html_item {
Chris@42 289 print HTML "$html_itemend\n<li>";
Chris@42 290 $html_itemend="";
Chris@42 291 $html_needpara=-1;
Chris@42 292 }
Chris@42 293
Chris@42 294 sub html_startpackedlist {
Chris@42 295 print HTML "\n";
Chris@42 296 $html_itemend="<dir>";
Chris@42 297 }
Chris@42 298
Chris@42 299 sub html_endpackedlist {
Chris@42 300 print HTML "$html_itemend\n</dir>\n";
Chris@42 301 $html_needpara=-1;
Chris@42 302 }
Chris@42 303
Chris@42 304 sub html_packeditem {
Chris@42 305 print HTML "$html_itemend\n<li>";
Chris@42 306 $html_itemend="";
Chris@42 307 $html_needpara=-1;
Chris@42 308 }
Chris@42 309
Chris@42 310 sub html_startindent { print HTML "<blockquote>\n"; }
Chris@42 311 sub html_endindent { print HTML "</blockquote>\n"; }
Chris@42 312
Chris@42 313 sub html_pageref {
Chris@42 314 local ($ref,$sq) = @_;
Chris@42 315 $sq =~ m/(\d+)\.(\d+)/;
Chris@42 316 local ($s,$n) = ($1,$2);
Chris@42 317 print HTML "<A href=\"";
Chris@42 318 print HTML ($s == $html_sectionn)?'':"section$s.html";
Chris@42 319 print HTML "#$qn2ref{$s,$n}\">Q$sq \`";
Chris@42 320 }
Chris@42 321
Chris@42 322 sub html_endpageref {
Chris@42 323 print HTML "'</A>";
Chris@42 324 }
Chris@42 325
Chris@42 326 sub html_sanitise {
Chris@42 327 local ($in) = @_;
Chris@42 328 local ($out);
Chris@42 329 while ($in =~ m/[<>&"]/) {
Chris@42 330 $out.= $`. '&'. $saniarray{$&}. ';';
Chris@42 331 $in=$';
Chris@42 332 }
Chris@42 333 $out.= $in;
Chris@42 334 $out;
Chris@42 335 }
Chris@42 336
Chris@42 337 1;