~diresu/blender/blender-command-port

« back to all changes in this revision

Viewing changes to extern/fftw/doc/FAQ/m-html.pl

  • Committer: theeth
  • Date: 2008-10-14 16:52:04 UTC
  • Revision ID: vcs-imports@canonical.com-20081014165204-r32w2gm6s0osvdhn
copy back trunk

Show diffs side-by-side

added added

removed removed

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