blob: 00ae37f3d716f656bfc241de507e692f210ab8a3 [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
Fred Drakefc16e781998-03-12 21:03:26 +000084sub do_cmd_character{ &do_cmd_samp(@_); }
85
86sub do_cmd_regexp{
87 local($_) = @_;
88 s|$next_pair_pr_rx|<tt>\2</tt>|;
89 $_;
90}
91
92sub do_cmd_envvar{
93 local($_) = @_;
94 s/$next_pair_pr_rx/\$\2/;
95 $_;
96}
97
98sub do_cmd_mimetype{
99 local($_) = @_;
100 s|$next_pair_pr_rx|<font face=sans-serif>\2</font>|;
101 $_;
102}
103
Fred Drake6659c301998-03-03 22:02:19 +0000104sub do_cmd_email{
105 local($_) = @_;
Fred Drakefc16e781998-03-12 21:03:26 +0000106 s|$any_next_pair_pr_rx|<tt><font face=sans-serif>\2</font></tt>|;
Fred Drake6659c301998-03-03 22:02:19 +0000107 $_;
108}
109
110sub do_cmd_url{
111 # use the URL as both text and hyperlink
112 local($_) = @_;
113 s/$any_next_pair_pr_rx//;
114 local($url) = $2;
115 $url =~ s/~/&#126;/g;
116 "<tt><font face=sans-serif><a href=\"$url\">$url</a></font></tt>" . $_;
117}
118
119sub do_cmd_manpage{
120 # two parameters: \manpage{name}{section}
121 local($_) = @_;
Fred Drakefc16e781998-03-12 21:03:26 +0000122 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake6659c301998-03-03 22:02:19 +0000123 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<i>\2<\/i>(\4)/;
124 $_;
125}
126
127sub do_cmd_rfc{
128 local($_) = @_;
129 s/$next_pair_pr_rx//;
130 local($br_id,$rfcnumber) = ($1, $2);
131
132 # Save the reference
133 local($nstr) = &gen_index_id("RFC!RFC $rfcnumber", '');
134 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
135 "<a name=\"$br_id\">RFC $rfcnumber<\/a>" .$_;
136}
137
138sub do_cmd_kbd{
139 local($_) = @_;
140 s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/;
141 $_;
142}
143
144sub do_cmd_key{
145 local($_) = @_;
146 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
147 $_;
148}
149
150sub do_cmd_var{
151 local($_) = @_;
152 s/$any_next_pair_pr_rx/<i>\2<\/i>/;
153 $_;
154}
155
156sub do_cmd_dfn{
157 local($_) = @_;
158 s/$any_next_pair_pr_rx/<i>\2<\/i>/;
159 $_;
160}
161
162sub do_cmd_emph{
163 local($_) = @_;
164 s/$any_next_pair_pr_rx/<i>\2<\/i>/;
165 $_;
166}
167
168sub do_cmd_strong{
169 local($_) = @_;
170 s/$any_next_pair_pr_rx/<b>\2<\/b>/;
171 $_;
172}
173
174sub do_cmd_deprecated{
175 # two parameters: \deprecated{version}{whattodo}
176 local($_) = @_;
Fred Drakefc16e781998-03-12 21:03:26 +0000177 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake6659c301998-03-03 22:02:19 +0000178 local($release,$action) = ($2, $4);
179 s/$next_pair_pr_rx$any_next_pair_pr_rx3//;
180 "<b>Deprecated since release $release.</b>"
181 . "\n$action<p>"
182 . $_;
183}
184
185# file and samp are at the end of this file since they screw up fontlock.
186
187# index commands
188
189$INDEX_SUBITEM = "";
190
191sub get_indexsubitem{
Fred Drakefc16e781998-03-12 21:03:26 +0000192 #$INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
193 '';
Fred Drake6659c301998-03-03 22:02:19 +0000194}
195
196sub do_cmd_setindexsubitem{
197 local($_) = @_;
198 s/$any_next_pair_pr_rx//;
199 $INDEX_SUBITEM = $2;
200 $_;
201}
202
Fred Drakefc16e781998-03-12 21:03:26 +0000203sub do_cmd_withsubitem{
204 # We can't really do the right right thing, because LaTeX2HTML doesn't
205 # do things in the right order, but we need to at least strip this stuff
206 # out, and leave anything that the second argument expanded out to.
207 #
208 local($_) = @_;
209 s/$next_pair_pr_rx$any_next_pair_pr_rx3/\4/;
210 $_;
211}
212
213sub do_cmd_makemodindex{ @_[0]; }
214
Fred Drake6659c301998-03-03 22:02:19 +0000215sub do_cmd_indexii{
216 local($_) = @_;
217 s/$next_pair_pr_rx//o;
218 local($br_id1, $str1) = ($1, $2);
219 s/$next_pair_pr_rx//o;
220 local($br_id2, $str2) = ($1, $2);
221 join('', &make_index_entry($br_id1, "$str1 $str2"),
222 &make_index_entry($br_id2, "$str2, $str1"), $_);
223}
224
225sub do_cmd_indexiii{
226 local($_) = @_;
227 s/$next_pair_pr_rx//o;
228 local($br_id1, $str1) = ($1, $2);
229 s/$next_pair_pr_rx//o;
230 local($br_id2, $str2) = ($1, $2);
231 s/$next_pair_pr_rx//o;
232 local($br_id3, $str3) = ($1, $2);
233 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
234 &make_index_entry($br_id2, "$str2 $str3, $str1"),
235 &make_index_entry($br_id3, "$str3, $str1 $str2"),
236 $_);
237}
238
239sub do_cmd_indexiv{
240 local($_) = @_;
241 s/$next_pair_pr_rx//o;
242 local($br_id1, $str1) = ($1, $2);
243 s/$next_pair_pr_rx//o;
244 local($br_id2, $str2) = ($1, $2);
245 s/$next_pair_pr_rx//o;
246 local($br_id3, $str3) = ($1, $2);
247 s/$next_pair_pr_rx//o;
248 local($br_id4, $str4) = ($1, $2);
249 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
250 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
251 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
252 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
253 $_);
254}
255
256sub do_cmd_ttindex{ &do_cmd_index(@_); }
257
258sub my_typed_index_helper{
259 local($word, $_) = @_;
260 s/$next_pair_pr_rx//o;
261 local($br_id, $str) = ($1, $2);
262 join('', &make_index_entry($br_id, "$str $word"),
263 &make_index_entry($br_id, "$word, $str"), $_);
264}
265
266sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
267sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
268sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
269sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
270
271sub my_parword_index_helper{
272 local($word, $_) = @_;
273 s/$next_pair_pr_rx//o;
274 local($br_id, $str) = ($1, $2);
275 &make_index_entry($br_id, "$str ($word)") . $_;
276}
277
278
279# Set this to true to strip out the <tt>...</tt> from index entries;
280# this is analogous to using the second definition of \idxcode{} from
281# myformat.sty.
282#
283# It is used from &make_mod_index_entry() and &make_str_index_entry().
284#
285$STRIP_INDEX_TT = 0;
286
287sub make_mod_index_entry{
288 local($br_id,$str,$define) = @_;
289 local($halfref) = &make_half_href("$CURRENT_FILE#$br_id");
290 # If TITLE is not yet available (i.e the \index command is in the title
291 # of the current section), use $ref_before.
292 $TITLE = $ref_before unless $TITLE;
293 # Save the reference
294 if ($define eq "DEF") {
295 local($nstr,$garbage) = split / /, $str, 2;
296 $Modules{$nstr} .= $halfref;
297 }
298 $str = &gen_index_id($str, $define);
299 if ($STRIP_INDEX_TT) {
300 $str =~ s/<tt>(.*)<\/tt>/\1/;
301 }
302 $index{$str} .= $halfref;
303 "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
304}
305
306sub my_module_index_helper{
307 local($word, $_) = @_;
308 s/$next_pair_pr_rx[\n]*//o;
309 local($br_id, $str) = ($1, $2);
310 local($section_tag) = join('', @curr_sec_id);
311 $word = "$word " if $word;
312 &make_mod_index_entry("SECTION$section_tag",
313 "<tt>$str</tt> (${word}module)", 'DEF');
314 $_;
315}
316
317sub ref_module_index_helper{
318 local($word, $_) = @_;
319 s/$next_pair_pr_rx//o;
320 local($br_id, $str) = ($1, $2);
321 $word = "$word " if $word;
322 &make_mod_index_entry($br_id, "<tt>$str</tt> (${word}module)", 'REF') . $_;
323}
324
325sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
326sub do_cmd_modindex{ &my_module_index_helper('', @_); }
327sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_); }
328sub do_cmd_exmodindex{ &my_module_index_helper('extension', @_); }
329sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_); }
330
331# these should be adjusted a bit....
332sub do_cmd_refmodindex{ &ref_module_index_helper('', @_); }
333sub do_cmd_refbimodindex{ &ref_module_index_helper('built-in', @_); }
334sub do_cmd_refexmodindex{ &ref_module_index_helper('extension', @_); }
335sub do_cmd_refstmodindex{ &ref_module_index_helper('standard', @_); }
336
337sub do_cmd_nodename{ &do_cmd_label(@_); }
338
339sub init_myformat{
340 # XXX need some way for this to be called after &initialise; ???
341 $anchor_mark = '';
342 $icons{'anchor_mark'} = '';
343 # <<2>>...<<2>>
344 $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
345 $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
346 $any_next_pair_rx7 = "$O(\\d+)$C([\\s\\S]*)$O\\7$C";
347 $any_next_pair_rx9 = "$O(\\d+)$C([\\s\\S]*)$O\\9$C";
348 # <#2#>...<#2#>
Fred Drakefc16e781998-03-12 21:03:26 +0000349 $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
350 $any_next_pair_pr_rx5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
351 $any_next_pair_pr_rx7 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP";
352 $any_next_pair_pr_rx9 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP";
Fred Drake2da947a1998-03-04 05:30:49 +0000353# if (defined &process_commands_wrap_deferred) {
354# &process_commands_wrap_deferred(<<THESE_COMMANDS);
355# indexii # {} # {}
356# indexiii # {} # {} # {}
357# indexiv # {} # {} # {} # {}
358# exindex # {}
359# obindex # {}
360# opindex # {}
361# stindex # {}
362# ttindex # {}
363# bifuncindex # {}
364# modindex # {}
365# bimodindex # {}
366# exmodindex # {}
367# stmodindex # {}
368# refmodindex # {}
369# refbimodindex # {}
370# refexmodindex # {}
371# refstmodindex # {}
372# rfc # {}
373# THESE_COMMANDS
374# }
Fred Drake6659c301998-03-03 22:02:19 +0000375}
376
377&init_myformat;
378
379# similar to make_index_entry(), but includes the string in the result
380# instead of the dummy filler.
381#
382sub make_str_index_entry{
383 local($br_id,$str) = @_;
384 # If TITLE is not yet available (i.e the \index command is in the title
385 # of the current section), use $ref_before.
386 $TITLE = $ref_before unless $TITLE;
387 # Save the reference
388 local($nstr) = &gen_index_id($str, '');
389 if ($STRIP_INDEX_TT) {
390 $nstr =~ s/<tt>(.*)<\/tt>/\1/;
391 }
392 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
393 "<a name=\"$br_id\">$str<\/a>";
394}
395
396# Changed from the stock version to indent {verbatim} sections,
397# and make them smaller, to better match the LaTeX version:
398
399# (Used with LaTeX2HTML 96.1*)
400sub replace_verbatim {
401 # Modifies $_
Fred Drakec1137451998-03-05 17:00:55 +0000402 local($prefix,$suffix) = ("\n<p><dl><dd><pre>\n", "</pre></dl>");
Fred Drake6659c301998-03-03 22:02:19 +0000403 s/$verbatim_mark(verbatim)(\d+)/$prefix$verbatim{$2}$suffix/go;
404 s/$verbatim_mark(rawhtml)(\d+)/$verbatim{$2}/ego; # Raw HTML
405}
406
407# (Used with LaTeX2HTML 98.1)
408sub replace_verbatim_hook{
409 # Modifies $_
Fred Drakec1137451998-03-05 17:00:55 +0000410 local($prefix,$suffix) = ("\n<p><dl><dd>", "</dl>");
Fred Drake6659c301998-03-03 22:02:19 +0000411 s/$math_verbatim_rx/&put_comment("MATH: ".$verbatim{$1})/eg;
412 s/$verbatim_mark(\w*[vV]erbatim\*?)(\d+)\#/$prefix$verbatim{$2}$suffix/go;
413 # Raw HTML, but replacements may have protected characters
414 s/$verbatim_mark(rawhtml)(\d+)#/&unprotect_raw_html($verbatim{$2})/eg;
415 s/$verbatim_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX
416 s/$unfinished_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX
417}
418
419sub do_env_cfuncdesc{
420 local($_) = @_;
421 local($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
Fred Drakefc16e781998-03-12 21:03:26 +0000422 local($any_next_pair_rx3) = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
423 local($any_next_pair_rx5) = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
Fred Drake6659c301998-03-03 22:02:19 +0000424 local($cfuncdesc_rx) =
425 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
426 if (/$cfuncdesc_rx/o) {
427 $return_type = "$2";
428 $function_name = "$4";
429 $arg_list = "$6";
430 $idx = &make_str_index_entry($3,
431 "<tt>$function_name</tt>" . &get_indexsubitem);
432 $idx =~ s/ \(.*\)//;
433 }
434 "<dl><dt>$return_type <b>$idx</b>"
435 . "(<var>$arg_list</var>)\n<dd>$'\n</dl>"
436}
437
438sub do_env_ctypedesc{
439 local($_) = @_;
440 local($type_name) = ('');
441 local($cfuncdesc_rx) = "$next_pair_rx";
442 if (/$cfuncdesc_rx/o) {
443 $type_name = "$2";
444 $idx = &make_str_index_entry($1,
445 "<tt>$type_name</tt>" . &get_indexsubitem);
446 $idx =~ s/ \(.*\)//;
447 }
448 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
449}
450
451sub do_env_cvardesc{
452 local($_) = @_;
453 local($var_type,$var_name,$idx) = ('', '', '');
454 local($cfuncdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
455 if (/$cfuncdesc_rx/o) {
456 $var_type = "$2";
457 $var_name = "$4";
458 $idx = &make_str_index_entry($3,
459 "<tt>$var_name</tt>" . &get_indexsubitem);
460 $idx =~ s/ \(.*\)//;
461 }
462 "<dl><dt>$var_type <b>$idx</b>\n"
463 . "<dd>$'\n</dl>";
464}
465
466sub do_env_funcdesc{
467 local($_) = @_;
468 local($function_name,$arg_list,$idx) = ('', '', '');
469 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
470 if (/$funcdesc_rx/o) {
471 $function_name = "$2";
472 $arg_list = "$4";
473 $idx = &make_str_index_entry($3,
474 "<tt>$function_name</tt>" . &get_indexsubitem);
475 $idx =~ s/ \(.*\)//;
476 }
477 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
478}
479
480sub do_env_funcdescni{
481 local($_) = @_;
482 local($function_name,$arg_list,$idx) = ('', '', '');
483 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
484 if (/$funcdesc_rx/o) {
485 $function_name = "$2";
486 $arg_list = "$4";
487 if ($STRIP_INDEX_TT) {
488 $idx = $function_name; }
489 else {
490 $idx = "<tt>$function_name</tt>"; }
491 }
492 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
493}
494
495sub do_cmd_funcline{
496 local($_) = @_;
497 local($funcdesc_rx) = "$next_pair_pr_rx$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
498
499 s/$funcdesc_rx//o;
500 local($br_id, $function_name, $arg_list) = ($3, $2, $4);
501 local($idx) = &make_str_index_entry($br_id, "<tt>$function_name</tt>");
502
503 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
504}
505
506# Change this flag to index the opcode entries. I don't think it's very
507# useful to index them, since they're only presented to describe the dis
508# module.
509#
510$INDEX_OPCODES = 0;
511
512sub do_env_opcodedesc{
513 local($_) = @_;
514 local($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
515 local($opcodedesc_rx) = "$next_pair_rx$any_next_pair_rx3";
516 if (/$opcodedesc_rx/o) {
517 $opcode_name = "$2";
518 $arg_list = "$4";
519 if ($INDEX_OPCODES) {
520 $idx = &make_str_index_entry($3,
521 "<tt>$opcode_name</tt> (byte code instruction)");
522 $idx =~ s/ \(byte code instruction\)//;
523 }
524 else {
525 $idx = "<tt>$opcode_name</tt>";
526 }
527 }
528 $stuff = "<dl><dt><b>$idx</b>";
529 if ($arg_list) {
530 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
531 }
532 $stuff . "\n<dd>$'\n</dl>";
533}
534
535sub do_env_datadesc{
536 local($_) = @_;
537 local($idx) = '';
538 if (/$next_pair_rx/o) {
539 $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
540 $idx =~ s/ \(.*\)//;
541 }
542 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
543}
544
545sub do_env_datadescni{
546 local($_) = @_;
547 local($idx) = '';
548 if (/$next_pair_rx/o) {
549 if ($STRING_INDEX_TT) {
550 $idx = "$2"; }
551 else {
552 $idx = "<tt>$2</tt>"; }
553 }
554 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
555}
556
557sub do_cmd_dataline{
558 local($_) = @_;
559
560 s/$next_pair_pr_rx//o;
561 local($br_id, $data_name) = ($1, $2);
562 local($idx) = &make_str_index_entry($br_id, "<tt>$data_name</tt>"
563 . &get_indexsubitem);
564 $idx =~ s/ \(.*\)//;
565
566 "<dt><b>$idx</b>\n<dd>" . $_;
567}
568
569sub do_env_excdesc{ &do_env_datadesc(@_); }
570sub do_env_classdesc{ &do_env_funcdesc(@_); }
571sub do_env_fulllineitems{ &do_env_itemize(@_); }
572
573
574@col_aligns = ("<td>", "<td>", "<td>");
575
576sub setup_column_alignments{
577 local($_) = @_;
578 local($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_);
579 local($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
580 $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>");
581 $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>");
582 $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>");
583 # return the aligned header start tags; only used for \begin{tableiii?}
584 $th1 = (($a1 eq "l") ? "<th align=left>"
585 : ($a1 eq "r" ? "<th align=right>" : "<th>"));
586 $th2 = (($a2 eq "l") ? "<th align=left>"
587 : ($a2 eq "r" ? "<th align=right>" : "<th>"));
588 $th3 = (($a3 eq "l") ? "<th align=left>"
589 : ($a3 eq "r" ? "<th align=right>" : "<th>"));
590 ($th1, $th2, $th3);
591}
592
593sub do_env_tableii{
594 local($_) = @_;
595 local($font,$h1,$h2) = ('', '', '');
596 local($tableiii_rx) =
597 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7";
598 if (/$tableiii_rx/o) {
599 $font = $4;
600 $h1 = $6;
601 $h2 = $8;
602 }
603 local($th1,$th2,$th3) = &setup_column_alignments($2);
604 $globals{"lineifont"} = $font;
605 "<table border align=center>"
606 . "\n <tr>$th1<b>$h1</b></th>"
607 . "\n $th2<b>$h2</b></th>$'"
608 . "\n</table>";
609}
610
611sub do_cmd_lineii{
612 local($_) = @_;
613 s/$next_pair_pr_rx//o;
614 local($c1) = $2;
615 s/$next_pair_pr_rx//o;
616 local($c2) = $2;
617 local($font) = $globals{"lineifont"};
618 local($c1align, $c2align) = @col_aligns[0,1];
619 "<tr>$c1align<$font>$c1</$font></td>\n"
620 . " $c2align$c2</td>$'";
621}
622
623sub do_env_tableiii{
624 local($_) = @_;
625 local($font,$h1,$h2,$h3) = ('', '', '', '');
626
627 local($tableiii_rx) =
628 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"
629 . "$any_next_pair_rx9";
630 if (/$tableiii_rx/o) {
631 $font = $4;
632 $h1 = $6;
633 $h2 = $8;
634 $h3 = $10;
635 }
636 local($th1,$th2,$th3) = &setup_column_alignments($2);
637 $globals{"lineifont"} = $font;
638 "<table border align=center>"
639 . "\n <tr>$th1<b>$h1</b></th>"
640 . "\n $th2<b>$h2</b></th>"
641 . "\n $th3<b>$h3</b></th>$'"
642 . "\n</table>";
643}
644
645sub do_cmd_lineiii{
646 local($_) = @_;
647 s/$next_pair_pr_rx//o;
648 local($c1) = $2;
649 s/$next_pair_pr_rx//o;
650 local($c2) = $2;
651 s/$next_pair_pr_rx//o;
652 local($c3) = $2;
653 local($font) = $globals{"lineifont"};
654 local($c1align, $c2align, $c3align) = @col_aligns;
655 "<tr>$c1align<$font>$c1</$font></td>\n"
656 . " $c2align$c2</td>\n"
657 . " $c3align$c3</td>$'";
658}
659
660sub do_env_seealso{
661 "<p><b>See Also:</b></p>\n" . @_[0];
662}
663
664sub do_cmd_seemodule{
665 # Insert the right magic to jump to the module definition. This should
666 # work most of the time, at least for repeat builds....
667 local($_) = @_;
Fred Drakeb3c9bca1998-03-06 21:20:08 +0000668 local($opt_arg) = "(\\[([^\\]]*)])?";
669# local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drakefc16e781998-03-12 21:03:26 +0000670# local($any_next_pair_pr_rx5) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
Fred Drakeb3c9bca1998-03-06 21:20:08 +0000671 s/$opt_arg$any_next_pair_pr_rx3$any_next_pair_pr_rx5//;
672 local($module,$text,$key) = ($4, $6, $2);
673 $key = $module if not $key;
674 "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
Fred Drake6659c301998-03-03 22:02:19 +0000675 . "&nbsp;&nbsp;&nbsp;($text)</p>"
676 . $_;
677}
678
679sub do_cmd_seetext{
680 "<p>" . @_[0];
681}
682
683
684sub do_cmd_maketitle {
685 local($_) = @_;
686 local($the_title) = '';
687 if ($t_title) {
688 $the_title .= "<h1 align=\"center\">$t_title</h1>";
689 } else { &write_warnings("\nThis document has no title."); }
690 if ($t_author) {
691 if ($t_authorURL) {
692 local($href) = &translate_commands($t_authorURL);
693 $href = &make_named_href('author', $href, "<strong>${t_author}</strong>");
694 $the_title .= "\n<p align=\"center\">$href</p>";
695 } else {
696 $the_title .= "\n<p align=\"center\"><strong>$t_author</strong></p>";
697 }
698 } else { &write_warnings("\nThere is no author for this document."); }
699 if ($t_institute) {
700 $the_title .= "\n<p align=\"center\"><small>$t_institute</small></p>";}
701 if ($AUTHOR_ADDRESS) {
702 $the_title .= "\n<p align=\"center\"><small>$AUTHOR_ADDRESS";
703 $the_title .= "</small></p>";}
704 if ($t_affil) {
705 $the_title .= "\n<p align=\"center\"><i>$t_affil</i></p>";}
706 if ($t_date) {
707 $the_title .= "\n<p align=\"center\"><strong>$t_date</strong>";
708 if ($PYTHON_VERSION) {
709 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
710 $the_title .= "</p>"
711 }
712 if ($t_address) {
713 $the_title .= "<br>\n<p align=\"left\"><small>$t_address</small></p>";
714 } else { $the_title .= "\n<p align=\"left\">"}
715 if ($t_email) {
716 $the_title .= "\n<p align=\"left\"><small>$t_email</small></p>";
717 } else { $the_title .= "</p>" }
718 $the_title . "<p><hr>\n" . $_ ;
719}
720
721
Fred Drakefc16e781998-03-12 21:03:26 +0000722sub do_cmd_inputindex{
723 local($_) = @_;
724 s/$next_pair_pr_rx//;
725 &do_cmd_input($2);
726}
727
728
729# These are located down here since they screw up fontlock. -- used to.
Fred Drake6659c301998-03-03 22:02:19 +0000730
731sub do_cmd_file{
732 # This uses a weird HTML construct to adjust the font to be
733 # reasonable match that used in the printed form as much as
734 # possible. The expected behavior is that a browser that doesn't
735 # understand "<font face=...>" markup will use courier (or whatever
736 # the font is for <tt>).
737 local($_) = @_;
Fred Drake2da947a1998-03-04 05:30:49 +0000738 s/$any_next_pair_pr_rx/\"<tt>\2<\/tt>\"/;
Fred Drake6659c301998-03-03 22:02:19 +0000739 $_;
740}
741
742sub do_cmd_samp{
743 local($_) = @_;
Fred Drake2da947a1998-03-04 05:30:49 +0000744 s/$any_next_pair_pr_rx/\"<tt>\2<\/tt>\"/;
Fred Drake6659c301998-03-03 22:02:19 +0000745 $_;
746}
747
7481; # This must be the last line