blob: f7531a5410a89c89db89aadf4e49827dc6612219 [file] [log] [blame]
Fred Drake6659c301998-03-03 22:02:19 +00001# python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*-
2#
3# Heavily based on Guido van Rossum's myformat.perl (now obsolete).
4#
5# Extension to LaTeX2HTML for documents using myformat.sty.
6# Subroutines of the form do_cmd_<name> here define translations
7# for LaTeX commands \<name> defined in the corresponding .sty file.
8
9package main;
10
11
12# words typeset in a special way (not in HTML though)
13
14sub do_cmd_ABC{ 'ABC' . @_[0]; }
15sub do_cmd_UNIX{ 'Unix'. @_[0]; }
16sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
17sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
18sub do_cmd_C{ 'C' . @_[0]; }
19sub do_cmd_Cpp{ 'C++' . @_[0]; }
20sub do_cmd_EOF{ 'EOF' . @_[0]; }
21sub do_cmd_NULL{ '<tt>NULL</tt>' . @_[0]; }
22
23sub do_cmd_e{ '&#92;' . @_[0]; }
24
25$AUTHOR_ADDRESS = '';
26$PYTHON_VERSION = '';
27
28sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
29sub do_cmd_release{
30 local($_) = @_;
31 s/$any_next_pair_pr_rx//;
32 $PYTHON_VERSION = "$2";
33 $_;
34}
35
36sub do_cmd_authoraddress{
37 local($_) = @_;
38 s/$any_next_pair_pr_rx//;
39 $AUTHOR_ADDRESS = "$2";
40 $_;
41}
42
43sub do_cmd_hackscore{
44 local($_) = @_;
45 s/$any_next_pair_pr_rx/_/;
46 $_;
47}
48
49sub do_cmd_optional{
50 local($_) = @_;
51 s/$any_next_pair_pr_rx/<\/var><big>\[<\/big><var>\2<\/var><big>\]<\/big><var>/;
52 $_;
53}
54
55sub do_cmd_varvars{
56 local($_) = @_;
57 s/$any_next_pair_pr_rx/<var>\2<\/var>/;
58 $_;
59}
60
61# texinfo-like formatting commands: \code{...} etc.
62
63sub do_cmd_code{
64 local($_) = @_;
65 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
66 $_;
67}
68
69sub do_cmd_sectcode{ &do_cmd_code(@_); }
70sub do_cmd_module{ &do_cmd_code(@_); }
71sub do_cmd_keyword{ &do_cmd_code(@_); }
72sub do_cmd_exception{ &do_cmd_code(@_); }
73sub do_cmd_class{ &do_cmd_code(@_); }
74sub do_cmd_function{ &do_cmd_code(@_); }
75sub do_cmd_constant{ &do_cmd_code(@_); }
76sub do_cmd_member{ &do_cmd_code(@_); }
77sub do_cmd_method{ &do_cmd_code(@_); }
78sub do_cmd_email{ &do_cmd_code(@_); }
79sub do_cmd_program{ &do_cmd_code(@_); }
80sub do_cmd_cfunction{ &do_cmd_code(@_); }
81sub do_cmd_cdata{ &do_cmd_code(@_); }
82sub do_cmd_ctype{ &do_cmd_code(@_); }
83
84sub do_cmd_email{
85 local($_) = @_;
86 s/$any_next_pair_pr_rx/<tt><font face=sans-serif>\2<\/font><\/tt>/;
87 $_;
88}
89
90sub do_cmd_url{
91 # use the URL as both text and hyperlink
92 local($_) = @_;
93 s/$any_next_pair_pr_rx//;
94 local($url) = $2;
95 $url =~ s/~/&#126;/g;
96 "<tt><font face=sans-serif><a href=\"$url\">$url</a></font></tt>" . $_;
97}
98
99sub do_cmd_manpage{
100 # two parameters: \manpage{name}{section}
101 local($_) = @_;
102 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
103 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<i>\2<\/i>(\4)/;
104 $_;
105}
106
107sub do_cmd_rfc{
108 local($_) = @_;
109 s/$next_pair_pr_rx//;
110 local($br_id,$rfcnumber) = ($1, $2);
111
112 # Save the reference
113 local($nstr) = &gen_index_id("RFC!RFC $rfcnumber", '');
114 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
115 "<a name=\"$br_id\">RFC $rfcnumber<\/a>" .$_;
116}
117
118sub do_cmd_kbd{
119 local($_) = @_;
120 s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/;
121 $_;
122}
123
124sub do_cmd_key{
125 local($_) = @_;
126 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
127 $_;
128}
129
130sub do_cmd_var{
131 local($_) = @_;
132 s/$any_next_pair_pr_rx/<i>\2<\/i>/;
133 $_;
134}
135
136sub do_cmd_dfn{
137 local($_) = @_;
138 s/$any_next_pair_pr_rx/<i>\2<\/i>/;
139 $_;
140}
141
142sub do_cmd_emph{
143 local($_) = @_;
144 s/$any_next_pair_pr_rx/<i>\2<\/i>/;
145 $_;
146}
147
148sub do_cmd_strong{
149 local($_) = @_;
150 s/$any_next_pair_pr_rx/<b>\2<\/b>/;
151 $_;
152}
153
154sub do_cmd_deprecated{
155 # two parameters: \deprecated{version}{whattodo}
156 local($_) = @_;
157 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
158 local($release,$action) = ($2, $4);
159 s/$next_pair_pr_rx$any_next_pair_pr_rx3//;
160 "<b>Deprecated since release $release.</b>"
161 . "\n$action<p>"
162 . $_;
163}
164
165# file and samp are at the end of this file since they screw up fontlock.
166
167# index commands
168
169$INDEX_SUBITEM = "";
170
171sub get_indexsubitem{
172 $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
173}
174
175sub do_cmd_setindexsubitem{
176 local($_) = @_;
177 s/$any_next_pair_pr_rx//;
178 $INDEX_SUBITEM = $2;
179 $_;
180}
181
182sub do_cmd_indexii{
183 local($_) = @_;
184 s/$next_pair_pr_rx//o;
185 local($br_id1, $str1) = ($1, $2);
186 s/$next_pair_pr_rx//o;
187 local($br_id2, $str2) = ($1, $2);
188 join('', &make_index_entry($br_id1, "$str1 $str2"),
189 &make_index_entry($br_id2, "$str2, $str1"), $_);
190}
191
192sub do_cmd_indexiii{
193 local($_) = @_;
194 s/$next_pair_pr_rx//o;
195 local($br_id1, $str1) = ($1, $2);
196 s/$next_pair_pr_rx//o;
197 local($br_id2, $str2) = ($1, $2);
198 s/$next_pair_pr_rx//o;
199 local($br_id3, $str3) = ($1, $2);
200 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
201 &make_index_entry($br_id2, "$str2 $str3, $str1"),
202 &make_index_entry($br_id3, "$str3, $str1 $str2"),
203 $_);
204}
205
206sub do_cmd_indexiv{
207 local($_) = @_;
208 s/$next_pair_pr_rx//o;
209 local($br_id1, $str1) = ($1, $2);
210 s/$next_pair_pr_rx//o;
211 local($br_id2, $str2) = ($1, $2);
212 s/$next_pair_pr_rx//o;
213 local($br_id3, $str3) = ($1, $2);
214 s/$next_pair_pr_rx//o;
215 local($br_id4, $str4) = ($1, $2);
216 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
217 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
218 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
219 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
220 $_);
221}
222
223sub do_cmd_ttindex{ &do_cmd_index(@_); }
224
225sub my_typed_index_helper{
226 local($word, $_) = @_;
227 s/$next_pair_pr_rx//o;
228 local($br_id, $str) = ($1, $2);
229 join('', &make_index_entry($br_id, "$str $word"),
230 &make_index_entry($br_id, "$word, $str"), $_);
231}
232
233sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
234sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
235sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
236sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
237
238sub my_parword_index_helper{
239 local($word, $_) = @_;
240 s/$next_pair_pr_rx//o;
241 local($br_id, $str) = ($1, $2);
242 &make_index_entry($br_id, "$str ($word)") . $_;
243}
244
245
246# Set this to true to strip out the <tt>...</tt> from index entries;
247# this is analogous to using the second definition of \idxcode{} from
248# myformat.sty.
249#
250# It is used from &make_mod_index_entry() and &make_str_index_entry().
251#
252$STRIP_INDEX_TT = 0;
253
254sub make_mod_index_entry{
255 local($br_id,$str,$define) = @_;
256 local($halfref) = &make_half_href("$CURRENT_FILE#$br_id");
257 # If TITLE is not yet available (i.e the \index command is in the title
258 # of the current section), use $ref_before.
259 $TITLE = $ref_before unless $TITLE;
260 # Save the reference
261 if ($define eq "DEF") {
262 local($nstr,$garbage) = split / /, $str, 2;
263 $Modules{$nstr} .= $halfref;
264 }
265 $str = &gen_index_id($str, $define);
266 if ($STRIP_INDEX_TT) {
267 $str =~ s/<tt>(.*)<\/tt>/\1/;
268 }
269 $index{$str} .= $halfref;
270 "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
271}
272
273sub my_module_index_helper{
274 local($word, $_) = @_;
275 s/$next_pair_pr_rx[\n]*//o;
276 local($br_id, $str) = ($1, $2);
277 local($section_tag) = join('', @curr_sec_id);
278 $word = "$word " if $word;
279 &make_mod_index_entry("SECTION$section_tag",
280 "<tt>$str</tt> (${word}module)", 'DEF');
281 $_;
282}
283
284sub ref_module_index_helper{
285 local($word, $_) = @_;
286 s/$next_pair_pr_rx//o;
287 local($br_id, $str) = ($1, $2);
288 $word = "$word " if $word;
289 &make_mod_index_entry($br_id, "<tt>$str</tt> (${word}module)", 'REF') . $_;
290}
291
292sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
293sub do_cmd_modindex{ &my_module_index_helper('', @_); }
294sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_); }
295sub do_cmd_exmodindex{ &my_module_index_helper('extension', @_); }
296sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_); }
297
298# these should be adjusted a bit....
299sub do_cmd_refmodindex{ &ref_module_index_helper('', @_); }
300sub do_cmd_refbimodindex{ &ref_module_index_helper('built-in', @_); }
301sub do_cmd_refexmodindex{ &ref_module_index_helper('extension', @_); }
302sub do_cmd_refstmodindex{ &ref_module_index_helper('standard', @_); }
303
304sub do_cmd_nodename{ &do_cmd_label(@_); }
305
306sub init_myformat{
307 # XXX need some way for this to be called after &initialise; ???
308 $anchor_mark = '';
309 $icons{'anchor_mark'} = '';
310 # <<2>>...<<2>>
311 $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
312 $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
313 $any_next_pair_rx7 = "$O(\\d+)$C([\\s\\S]*)$O\\7$C";
314 $any_next_pair_rx9 = "$O(\\d+)$C([\\s\\S]*)$O\\9$C";
315 # <#2#>...<#2#>
316 $any_next_pair_pr_rx_3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
317 $any_next_pair_pr_rx_5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
318 $any_next_pair_pr_rx_7 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP";
319 $any_next_pair_pr_rx_9 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP";
Fred Drake2da947a1998-03-04 05:30:49 +0000320# if (defined &process_commands_wrap_deferred) {
321# &process_commands_wrap_deferred(<<THESE_COMMANDS);
322# indexii # {} # {}
323# indexiii # {} # {} # {}
324# indexiv # {} # {} # {} # {}
325# exindex # {}
326# obindex # {}
327# opindex # {}
328# stindex # {}
329# ttindex # {}
330# bifuncindex # {}
331# modindex # {}
332# bimodindex # {}
333# exmodindex # {}
334# stmodindex # {}
335# refmodindex # {}
336# refbimodindex # {}
337# refexmodindex # {}
338# refstmodindex # {}
339# rfc # {}
340# THESE_COMMANDS
341# }
Fred Drake6659c301998-03-03 22:02:19 +0000342}
343
344&init_myformat;
345
346# similar to make_index_entry(), but includes the string in the result
347# instead of the dummy filler.
348#
349sub make_str_index_entry{
350 local($br_id,$str) = @_;
351 # If TITLE is not yet available (i.e the \index command is in the title
352 # of the current section), use $ref_before.
353 $TITLE = $ref_before unless $TITLE;
354 # Save the reference
355 local($nstr) = &gen_index_id($str, '');
356 if ($STRIP_INDEX_TT) {
357 $nstr =~ s/<tt>(.*)<\/tt>/\1/;
358 }
359 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
360 "<a name=\"$br_id\">$str<\/a>";
361}
362
363# Changed from the stock version to indent {verbatim} sections,
364# and make them smaller, to better match the LaTeX version:
365
366# (Used with LaTeX2HTML 96.1*)
367sub replace_verbatim {
368 # Modifies $_
Fred Drakec1137451998-03-05 17:00:55 +0000369 local($prefix,$suffix) = ("\n<p><dl><dd><pre>\n", "</pre></dl>");
Fred Drake6659c301998-03-03 22:02:19 +0000370 s/$verbatim_mark(verbatim)(\d+)/$prefix$verbatim{$2}$suffix/go;
371 s/$verbatim_mark(rawhtml)(\d+)/$verbatim{$2}/ego; # Raw HTML
372}
373
374# (Used with LaTeX2HTML 98.1)
375sub replace_verbatim_hook{
376 # Modifies $_
Fred Drakec1137451998-03-05 17:00:55 +0000377 local($prefix,$suffix) = ("\n<p><dl><dd>", "</dl>");
Fred Drake6659c301998-03-03 22:02:19 +0000378 s/$math_verbatim_rx/&put_comment("MATH: ".$verbatim{$1})/eg;
379 s/$verbatim_mark(\w*[vV]erbatim\*?)(\d+)\#/$prefix$verbatim{$2}$suffix/go;
380 # Raw HTML, but replacements may have protected characters
381 s/$verbatim_mark(rawhtml)(\d+)#/&unprotect_raw_html($verbatim{$2})/eg;
382 s/$verbatim_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX
383 s/$unfinished_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX
384}
385
386sub do_env_cfuncdesc{
387 local($_) = @_;
388 local($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
389 local($cfuncdesc_rx) =
390 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
391 if (/$cfuncdesc_rx/o) {
392 $return_type = "$2";
393 $function_name = "$4";
394 $arg_list = "$6";
395 $idx = &make_str_index_entry($3,
396 "<tt>$function_name</tt>" . &get_indexsubitem);
397 $idx =~ s/ \(.*\)//;
398 }
399 "<dl><dt>$return_type <b>$idx</b>"
400 . "(<var>$arg_list</var>)\n<dd>$'\n</dl>"
401}
402
403sub do_env_ctypedesc{
404 local($_) = @_;
405 local($type_name) = ('');
406 local($cfuncdesc_rx) = "$next_pair_rx";
407 if (/$cfuncdesc_rx/o) {
408 $type_name = "$2";
409 $idx = &make_str_index_entry($1,
410 "<tt>$type_name</tt>" . &get_indexsubitem);
411 $idx =~ s/ \(.*\)//;
412 }
413 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
414}
415
416sub do_env_cvardesc{
417 local($_) = @_;
418 local($var_type,$var_name,$idx) = ('', '', '');
419 local($cfuncdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
420 if (/$cfuncdesc_rx/o) {
421 $var_type = "$2";
422 $var_name = "$4";
423 $idx = &make_str_index_entry($3,
424 "<tt>$var_name</tt>" . &get_indexsubitem);
425 $idx =~ s/ \(.*\)//;
426 }
427 "<dl><dt>$var_type <b>$idx</b>\n"
428 . "<dd>$'\n</dl>";
429}
430
431sub do_env_funcdesc{
432 local($_) = @_;
433 local($function_name,$arg_list,$idx) = ('', '', '');
434 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
435 if (/$funcdesc_rx/o) {
436 $function_name = "$2";
437 $arg_list = "$4";
438 $idx = &make_str_index_entry($3,
439 "<tt>$function_name</tt>" . &get_indexsubitem);
440 $idx =~ s/ \(.*\)//;
441 }
442 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
443}
444
445sub do_env_funcdescni{
446 local($_) = @_;
447 local($function_name,$arg_list,$idx) = ('', '', '');
448 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
449 if (/$funcdesc_rx/o) {
450 $function_name = "$2";
451 $arg_list = "$4";
452 if ($STRIP_INDEX_TT) {
453 $idx = $function_name; }
454 else {
455 $idx = "<tt>$function_name</tt>"; }
456 }
457 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
458}
459
460sub do_cmd_funcline{
461 local($_) = @_;
462 local($funcdesc_rx) = "$next_pair_pr_rx$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
463
464 s/$funcdesc_rx//o;
465 local($br_id, $function_name, $arg_list) = ($3, $2, $4);
466 local($idx) = &make_str_index_entry($br_id, "<tt>$function_name</tt>");
467
468 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
469}
470
471# Change this flag to index the opcode entries. I don't think it's very
472# useful to index them, since they're only presented to describe the dis
473# module.
474#
475$INDEX_OPCODES = 0;
476
477sub do_env_opcodedesc{
478 local($_) = @_;
479 local($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
480 local($opcodedesc_rx) = "$next_pair_rx$any_next_pair_rx3";
481 if (/$opcodedesc_rx/o) {
482 $opcode_name = "$2";
483 $arg_list = "$4";
484 if ($INDEX_OPCODES) {
485 $idx = &make_str_index_entry($3,
486 "<tt>$opcode_name</tt> (byte code instruction)");
487 $idx =~ s/ \(byte code instruction\)//;
488 }
489 else {
490 $idx = "<tt>$opcode_name</tt>";
491 }
492 }
493 $stuff = "<dl><dt><b>$idx</b>";
494 if ($arg_list) {
495 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
496 }
497 $stuff . "\n<dd>$'\n</dl>";
498}
499
500sub do_env_datadesc{
501 local($_) = @_;
502 local($idx) = '';
503 if (/$next_pair_rx/o) {
504 $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
505 $idx =~ s/ \(.*\)//;
506 }
507 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
508}
509
510sub do_env_datadescni{
511 local($_) = @_;
512 local($idx) = '';
513 if (/$next_pair_rx/o) {
514 if ($STRING_INDEX_TT) {
515 $idx = "$2"; }
516 else {
517 $idx = "<tt>$2</tt>"; }
518 }
519 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
520}
521
522sub do_cmd_dataline{
523 local($_) = @_;
524
525 s/$next_pair_pr_rx//o;
526 local($br_id, $data_name) = ($1, $2);
527 local($idx) = &make_str_index_entry($br_id, "<tt>$data_name</tt>"
528 . &get_indexsubitem);
529 $idx =~ s/ \(.*\)//;
530
531 "<dt><b>$idx</b>\n<dd>" . $_;
532}
533
534sub do_env_excdesc{ &do_env_datadesc(@_); }
535sub do_env_classdesc{ &do_env_funcdesc(@_); }
536sub do_env_fulllineitems{ &do_env_itemize(@_); }
537
538
539@col_aligns = ("<td>", "<td>", "<td>");
540
541sub setup_column_alignments{
542 local($_) = @_;
543 local($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_);
544 local($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
545 $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>");
546 $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>");
547 $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>");
548 # return the aligned header start tags; only used for \begin{tableiii?}
549 $th1 = (($a1 eq "l") ? "<th align=left>"
550 : ($a1 eq "r" ? "<th align=right>" : "<th>"));
551 $th2 = (($a2 eq "l") ? "<th align=left>"
552 : ($a2 eq "r" ? "<th align=right>" : "<th>"));
553 $th3 = (($a3 eq "l") ? "<th align=left>"
554 : ($a3 eq "r" ? "<th align=right>" : "<th>"));
555 ($th1, $th2, $th3);
556}
557
558sub do_env_tableii{
559 local($_) = @_;
560 local($font,$h1,$h2) = ('', '', '');
561 local($tableiii_rx) =
562 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7";
563 if (/$tableiii_rx/o) {
564 $font = $4;
565 $h1 = $6;
566 $h2 = $8;
567 }
568 local($th1,$th2,$th3) = &setup_column_alignments($2);
569 $globals{"lineifont"} = $font;
570 "<table border align=center>"
571 . "\n <tr>$th1<b>$h1</b></th>"
572 . "\n $th2<b>$h2</b></th>$'"
573 . "\n</table>";
574}
575
576sub do_cmd_lineii{
577 local($_) = @_;
578 s/$next_pair_pr_rx//o;
579 local($c1) = $2;
580 s/$next_pair_pr_rx//o;
581 local($c2) = $2;
582 local($font) = $globals{"lineifont"};
583 local($c1align, $c2align) = @col_aligns[0,1];
584 "<tr>$c1align<$font>$c1</$font></td>\n"
585 . " $c2align$c2</td>$'";
586}
587
588sub do_env_tableiii{
589 local($_) = @_;
590 local($font,$h1,$h2,$h3) = ('', '', '', '');
591
592 local($tableiii_rx) =
593 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"
594 . "$any_next_pair_rx9";
595 if (/$tableiii_rx/o) {
596 $font = $4;
597 $h1 = $6;
598 $h2 = $8;
599 $h3 = $10;
600 }
601 local($th1,$th2,$th3) = &setup_column_alignments($2);
602 $globals{"lineifont"} = $font;
603 "<table border align=center>"
604 . "\n <tr>$th1<b>$h1</b></th>"
605 . "\n $th2<b>$h2</b></th>"
606 . "\n $th3<b>$h3</b></th>$'"
607 . "\n</table>";
608}
609
610sub do_cmd_lineiii{
611 local($_) = @_;
612 s/$next_pair_pr_rx//o;
613 local($c1) = $2;
614 s/$next_pair_pr_rx//o;
615 local($c2) = $2;
616 s/$next_pair_pr_rx//o;
617 local($c3) = $2;
618 local($font) = $globals{"lineifont"};
619 local($c1align, $c2align, $c3align) = @col_aligns;
620 "<tr>$c1align<$font>$c1</$font></td>\n"
621 . " $c2align$c2</td>\n"
622 . " $c3align$c3</td>$'";
623}
624
625sub do_env_seealso{
626 "<p><b>See Also:</b></p>\n" . @_[0];
627}
628
629sub do_cmd_seemodule{
630 # Insert the right magic to jump to the module definition. This should
631 # work most of the time, at least for repeat builds....
632 local($_) = @_;
633 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
634 s/$next_pair_pr_rx$any_next_pair_pr_rx3//;
635 local($module,$text,$node,$key) = ($2, $4, '', "module$2");
636 $key =~ s/_//g;
637 # XXX somewhat bogus computation of $node
638# $node = $external_labels{$key} unless
639# ($node = $ref_files{$key});
640 $node = $key;
641 "<p>Module <tt><b><a href=\"$node#$key\">$module</a></b></tt>"
642 . "&nbsp;&nbsp;&nbsp;($text)</p>"
643 . $_;
644}
645
646sub do_cmd_seetext{
647 "<p>" . @_[0];
648}
649
650
651sub do_cmd_maketitle {
652 local($_) = @_;
653 local($the_title) = '';
654 if ($t_title) {
655 $the_title .= "<h1 align=\"center\">$t_title</h1>";
656 } else { &write_warnings("\nThis document has no title."); }
657 if ($t_author) {
658 if ($t_authorURL) {
659 local($href) = &translate_commands($t_authorURL);
660 $href = &make_named_href('author', $href, "<strong>${t_author}</strong>");
661 $the_title .= "\n<p align=\"center\">$href</p>";
662 } else {
663 $the_title .= "\n<p align=\"center\"><strong>$t_author</strong></p>";
664 }
665 } else { &write_warnings("\nThere is no author for this document."); }
666 if ($t_institute) {
667 $the_title .= "\n<p align=\"center\"><small>$t_institute</small></p>";}
668 if ($AUTHOR_ADDRESS) {
669 $the_title .= "\n<p align=\"center\"><small>$AUTHOR_ADDRESS";
670 $the_title .= "</small></p>";}
671 if ($t_affil) {
672 $the_title .= "\n<p align=\"center\"><i>$t_affil</i></p>";}
673 if ($t_date) {
674 $the_title .= "\n<p align=\"center\"><strong>$t_date</strong>";
675 if ($PYTHON_VERSION) {
676 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
677 $the_title .= "</p>"
678 }
679 if ($t_address) {
680 $the_title .= "<br>\n<p align=\"left\"><small>$t_address</small></p>";
681 } else { $the_title .= "\n<p align=\"left\">"}
682 if ($t_email) {
683 $the_title .= "\n<p align=\"left\"><small>$t_email</small></p>";
684 } else { $the_title .= "</p>" }
685 $the_title . "<p><hr>\n" . $_ ;
686}
687
688
689# These are located down here since they screw up fontlock.
690
691sub do_cmd_file{
692 # This uses a weird HTML construct to adjust the font to be
693 # reasonable match that used in the printed form as much as
694 # possible. The expected behavior is that a browser that doesn't
695 # understand "<font face=...>" markup will use courier (or whatever
696 # the font is for <tt>).
697 local($_) = @_;
Fred Drake2da947a1998-03-04 05:30:49 +0000698 s/$any_next_pair_pr_rx/\"<tt>\2<\/tt>\"/;
Fred Drake6659c301998-03-03 22:02:19 +0000699 $_;
700}
701
702sub do_cmd_samp{
703 local($_) = @_;
Fred Drake2da947a1998-03-04 05:30:49 +0000704 s/$any_next_pair_pr_rx/\"<tt>\2<\/tt>\"/;
Fred Drake6659c301998-03-03 22:02:19 +0000705 $_;
706}
707
7081; # This must be the last line