1 # python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*-
3 # Heavily based on Guido van Rossum's myformat.perl (now obsolete).
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.
14 $param = missing_braces
()
15 unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
16 ||(s/$next_pair_rx/$param=$2;''/eo));
20 sub next_optional_argument
{
21 my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
22 s/$rx/$param=$2;''/eo;
27 # This is a fairly simple hack; it supports \let when it is used to create
28 # (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
29 # Many possible uses of \let aren't supported or aren't supported correctly.
34 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
36 my($new, $old) = ($1, $3);
37 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
38 print "\ndefining handler for \\$new using \\$old\n";
41 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
43 my($new, $char) = ($1, $3);
44 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
45 print "\ndefining handler for \\$new to insert '$char'\n";
48 write_warnings
("Could not interpret \\let construct...");
55 # words typeset in a special way (not in HTML though)
57 sub do_cmd_ABC
{ 'ABC' . @_[0]; }
58 sub do_cmd_UNIX
{ 'Unix'. @_[0]; }
59 sub do_cmd_ASCII
{ 'ASCII' . @_[0]; }
60 sub do_cmd_POSIX
{ 'POSIX' . @_[0]; }
61 sub do_cmd_C
{ 'C' . @_[0]; }
62 sub do_cmd_Cpp
{ 'C++' . @_[0]; }
63 sub do_cmd_EOF
{ 'EOF' . @_[0]; }
64 sub do_cmd_NULL
{ '<tt>NULL</tt>' . @_[0]; }
66 sub do_cmd_e
{ '\' . @_[0]; }
68 $DEVELOPER_ADDRESS = '';
71 sub do_cmd_version
{ $PYTHON_VERSION . @_[0]; }
74 $PYTHON_VERSION = next_argument
();
78 sub do_cmd_authoraddress
{
80 $DEVELOPER_ADDRESS = next_argument
();
84 #sub do_cmd_developer{ do_cmd_author(@_[0]); }
85 #sub do_cmd_developers{ do_cmd_author(@_[0]); }
86 #sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
95 local($_,$before,$after) = @_;
96 my $stuff = next_argument
();
97 return $before . $stuff . $after . $_;
101 return use_wrappers
(@_[0], '<font face="sans-serif">', '</font>');
104 return use_wrappers
(@_[0], '<i>', '</i>');
108 return use_wrappers
(@_[0], "</var><big>\[</big><var>",
109 "</var><big>\]</big><var>");
112 # Logical formatting (some based on texinfo), needs to be converted to
113 # minimalist HTML. The "minimalist" is primarily to reduce the size of
114 # output files for users that read them over the network rather than
115 # from local repositories.
117 # \file and \samp are at the end of this file since they screw up fontlock.
119 sub do_cmd_pytype
{ return @_[0]; }
120 sub do_cmd_makevar
{ return @_[0]; }
122 return use_wrappers
(@_[0], '<tt>', '</tt>'); }
124 return use_wrappers
(@_[0], '<tt class=module>', '</tt>'); }
126 return use_wrappers
(@_[0], '<tt class=keyword>', '</tt>'); }
127 sub do_cmd_exception
{
128 return use_wrappers
(@_[0], '<tt class=exception>', '</tt>'); }
130 return use_wrappers
(@_[0], '<tt class=class>', '</tt>'); }
132 return use_wrappers
(@_[0], '<tt class=function>', '</tt>'); }
134 return use_wrappers
(@_[0], '<tt class=constant>', '</tt>'); }
136 return use_wrappers
(@_[0], '<tt class=member>', '</tt>'); }
138 return use_wrappers
(@_[0], '<tt class=method>', '</tt>'); }
139 sub do_cmd_cfunction
{
140 return use_wrappers
(@_[0], '<tt class=cfunction>', '</tt>'); }
142 return use_wrappers
(@_[0], '<tt class=cdata>', '</tt>'); }
144 return use_wrappers
(@_[0], '<tt class=ctype>', '</tt>'); }
146 return use_wrappers
(@_[0], '<tt class=regexp>', '</tt>'); }
147 sub do_cmd_character
{
148 return use_wrappers
(@_[0], '"<tt class=character>', '</tt>"'); }
150 return use_wrappers
(@_[0], '<b class=program>', '</b>'); }
151 sub do_cmd_programopt
{
152 return use_wrappers
(@_[0], '<b class="programopt">', '</b>'); }
154 return use_wrappers
(@_[0], '<span class=email>', '</span>'); }
156 return use_wrappers
(@_[0], '<span class=mimetype>', '</span>'); }
158 return use_wrappers
(@_[0], "<var>", "</var>"); }
160 return use_wrappers
(@_[0], '<i class=dfn>', '</i>'); }
162 return use_italics
(@_); }
164 return use_wrappers
(@_[0], '<tt class=file>', '</tt>'); }
166 return use_wrappers
(@_[0], '<tt class=file>', '</tt>'); }
168 return use_wrappers
(@_[0], '"<tt class=samp>', '</tt>"'); }
170 return use_wrappers
(@_[0], '<kbd>', '</kbd>'); }
172 return use_wrappers
(@_[0], '<b>', '</b>'); }
174 return use_wrappers
(@_[0], '<b>', '</b>'); }
176 return use_wrappers
(@_[0], '<i>', '</i>'); }
179 sub do_cmd_refmodule
{
180 # Insert the right magic to jump to the module definition.
182 my $key = next_optional_argument
();
183 my $module = next_argument
();
186 return "<tt class=module><a href=\"module-$key.html\">$module</a></tt>" . $_;
189 sub do_cmd_newsgroup
{
191 my $newsgroup = next_argument
();
192 my $stuff = "<a class=newsgroup href=\"news:$newsgroup\">$newsgroup</a>";
198 my $envvar = next_argument
();
199 my($name,$aname,$ahref) = new_link_info
();
200 # The <tt> here is really to keep buildindex.py from making
201 # the variable name case-insensitive.
202 add_index_entry
("environment variables!$envvar@<tt>\$$envvar</tt>",
204 add_index_entry
("$envvar@\$$envvar", $ahref);
205 $aname =~ s/<a/<a class=envvar/;
206 return "$aname\$$envvar</a>" . $_;
210 # use the URL as both text and hyperlink
212 my $url = next_argument
();
213 $url =~ s/~/~/g;
214 return "<a class=url href=\"$url\">$url</a>" . $_;
218 # two parameters: \manpage{name}{section}
220 my $page = next_argument
();
221 my $section = next_argument
();
222 return "<span class=manpage><i>$page</i>($section)</span>" . $_;
227 my $rfcnumber = next_argument
();
228 my $id = "rfcref-" . ++$global{'max_id'};
230 "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt";
232 my $nstr = gen_index_id
("RFC!RFC $rfcnumber", '');
233 $index{$nstr} .= make_half_href
("$CURRENT_FILE#$id");
234 return ("<a class=rfc name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>"
238 sub do_cmd_citetitle
{
240 my $url = next_optional_argument
();
241 my $title = next_argument
();
244 $repl = ("<em class='citetitle'><a\n"
246 . " title='$title'\n"
247 . " >$title</a></em>");
250 $repl = "<em class='citetitle'\n >$title</em>";
255 sub do_cmd_deprecated
{
256 # two parameters: \deprecated{version}{whattodo}
258 my $release = next_argument
();
259 my $reason = next_argument
();
260 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
263 sub do_cmd_versionadded
{
264 # one parameter: \versionadded{version}
266 my $release = next_argument
();
267 return "\nNew in version $release.\n" . $_;
270 sub do_cmd_versionchanged
{
271 # one parameter: \versionchanged{version}
273 my $release = next_argument
();
274 return "\nChanged in version $release.\n" . $_;
278 # These function handle platform dependency tracking.
282 my $platform = next_argument
();
283 $ModulePlatforms{$THIS_MODULE} = $platform;
284 $platform = "Macintosh"
285 if $platform eq 'Mac';
286 return "\n<p class=availability>Availability: <span"
287 . "\n class=platform>$platform</span>.</p>\n" . $_;
290 $IGNORE_PLATFORM_ANNOTATION = '';
291 sub do_cmd_ignorePlatformAnnotation
{
293 $IGNORE_PLATFORM_ANNOTATION = next_argument
();
302 sub get_indexsubitem
{
303 return $INDEX_SUBITEM ?
" $INDEX_SUBITEM" : '';
306 sub do_cmd_setindexsubitem
{
308 $INDEX_SUBITEM = next_argument
();
312 sub do_cmd_withsubitem
{
313 # We can't really do the right thing, because LaTeX2HTML doesn't
314 # do things in the right order, but we need to at least strip this stuff
315 # out, and leave anything that the second argument expanded out to.
318 my $oldsubitem = $INDEX_SUBITEM;
319 $INDEX_SUBITEM = next_argument
();
320 my $stuff = next_argument
();
321 my $br_id = ++$globals{'max_id'};
322 my $marker = "$O$br_id$C";
325 . "\\setindexsubitem$marker$oldsubitem$marker"
329 # This is the prologue macro which is required to start writing the
330 # mod\jobname.idx file; we can just ignore it. (Defining this suppresses
331 # a warning that \makemodindex is unknown.)
333 sub do_cmd_makemodindex
{ return @_[0]; }
335 # We're in the document subdirectory when this happens!
337 open(IDXFILE
, '>index.dat') || die "\n$!\n";
338 open(INTLABELS
, '>intlabels.pl') || die "\n$!\n";
339 print INTLABELS
"%internal_labels = ();\n";
340 print INTLABELS
"1; # hack in case there are no entries\n\n";
342 # Using \0 for this is bad because we can't use common tools to work with the
343 # resulting files. Things like grep can be useful with this stuff!
345 $IDXFILE_FIELD_SEP = "\1";
348 my ($ahref, $str) = @_;
349 print IDXFILE
$ahref, $IDXFILE_FIELD_SEP, $str, "\n";
354 my($node,$target) = @_;
355 print INTLABELS
"\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
356 return "<a href=\"$node#$target\">";
360 # add an entry to the index structures; ignore the return value
361 my($str,$ahref) = @_;
362 $str = gen_index_id
($str, '');
363 $index{$str} .= $ahref;
364 write_idxfile
($ahref, $str);
368 my $name = "l2h-" . ++$globals{'max_id'};
369 my $aname = '<a name="' . $name . '">';
370 my $ahref = gen_link
($CURRENT_FILE, $name);
371 return ($name, $aname, $ahref);
374 $IndexMacroPattern = '';
375 sub define_indexing_macro
{
378 for (; $i < $count; ++$i) {
380 my $cmd = "idx_cmd_$name";
381 die "\nNo function $cmd() defined!\n"
383 eval ("sub do_cmd_$name { return process_index_macros("
384 . "\@_[0], '$name'); }");
385 if (length($IndexMacroPattern) == 0) {
386 $IndexMacroPattern = "$name";
389 $IndexMacroPattern .= "|$name";
395 sub process_index_macros
{
397 my $cmdname = @_[1]; # This is what triggered us in the first place;
398 # we know it's real, so just process it.
399 my($name,$aname,$ahref) = new_link_info
();
400 my $cmd = "idx_cmd_$cmdname";
401 print "\nIndexing: \\$cmdname"
403 &$cmd($ahref); # modifies $_ and adds index entries
404 while (/^[\s\n]*\\($IndexMacroPattern)</) {
408 $cmd = "idx_cmd_$cmdname";
409 if (!defined &$cmd) {
413 s/^[\s\n]*\\$cmdname//;
417 return "$aname$anchor_invisible_mark</a>" . $_;
420 define_indexing_macro
('index');
422 my $str = next_argument
();
423 add_index_entry
("$str", @_[0]);
426 define_indexing_macro
('kwindex');
428 my $str = next_argument
();
429 add_index_entry
("<tt>$str</tt>!keyword", @_[0]);
430 add_index_entry
("keyword!<tt>$str</tt>", @_[0]);
433 define_indexing_macro
('indexii');
435 my $str1 = next_argument
();
436 my $str2 = next_argument
();
437 add_index_entry
("$str1!$str2", @_[0]);
438 add_index_entry
("$str2!$str1", @_[0]);
441 define_indexing_macro
('indexiii');
442 sub idx_cmd_indexiii
{
443 my $str1 = next_argument
();
444 my $str2 = next_argument
();
445 my $str3 = next_argument
();
446 add_index_entry
("$str1!$str2 $str3", @_[0]);
447 add_index_entry
("$str2!$str3, $str1", @_[0]);
448 add_index_entry
("$str3!$str1 $str2", @_[0]);
451 define_indexing_macro
('indexiv');
453 my $str1 = next_argument
();
454 my $str2 = next_argument
();
455 my $str3 = next_argument
();
456 my $str4 = next_argument
();
457 add_index_entry
("$str1!$str2 $str3 $str4", @_[0]);
458 add_index_entry
("$str2!$str3 $str4, $str1", @_[0]);
459 add_index_entry
("$str3!$str4, $str1 $str2", @_[0]);
460 add_index_entry
("$str4!$$str1 $str2 $str3", @_[0]);
463 define_indexing_macro
('ttindex');
465 my $str = next_argument
();
466 my $entry = $str . get_indexsubitem
();
467 add_index_entry
($entry, @_[0]);
470 sub my_typed_index_helper
{
471 my($word,$ahref) = @_;
472 my $str = next_argument
();
473 add_index_entry
("$str $word", $ahref);
474 add_index_entry
("$word!$str", $ahref);
477 define_indexing_macro
('stindex', 'opindex', 'exindex', 'obindex');
478 sub idx_cmd_stindex
{ my_typed_index_helper
('statement', @_[0]); }
479 sub idx_cmd_opindex
{ my_typed_index_helper
('operator', @_[0]); }
480 sub idx_cmd_exindex
{ my_typed_index_helper
('exception', @_[0]); }
481 sub idx_cmd_obindex
{ my_typed_index_helper
('object', @_[0]); }
483 define_indexing_macro
('bifuncindex');
484 sub idx_cmd_bifuncindex
{
485 my $str = next_argument
();
486 add_index_entry
("<tt>$str()</tt> (built-in function)", @_[0]);
490 sub make_mod_index_entry
{
491 my($str,$define) = @_;
492 my($name,$aname,$ahref) = new_link_info
();
493 # equivalent of add_index_entry() using $define instead of ''
494 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
495 if ($define eq 'DEF');
496 $str = gen_index_id
($str, $define);
497 $index{$str} .= $ahref;
498 write_idxfile
($ahref, $str);
500 if ($define eq 'DEF') {
501 # add to the module index
502 my($nstr,$garbage) = split / /, $str, 2;
503 $Modules{$nstr} .= $ahref;
505 return "$aname$anchor_invisible_mark</a>";
513 my($word,$name) = @_;
514 my $section_tag = join('', @curr_sec_id);
515 if ($word ne "built-in" && $word ne "extension"
516 && $word ne "standard" && $word ne "") {
517 write_warnings
("Bad module type '$word'"
518 . " for \\declaremodule (module $name)");
521 $word = "$word " if $word;
522 $THIS_MODULE = "$name";
523 $INDEX_SUBITEM = "(in $name)";
525 return make_mod_index_entry
("<tt>$name</tt> (${word}module)", 'DEF');
528 sub my_module_index_helper
{
529 local($word, $_) = @_;
530 my $name = next_argument
();
531 return define_module
($word, $name) . $_;
534 sub do_cmd_modindex
{ return my_module_index_helper
('', @_); }
535 sub do_cmd_bimodindex
{ return my_module_index_helper
('built-in', @_); }
536 sub do_cmd_exmodindex
{ return my_module_index_helper
('extension', @_); }
537 sub do_cmd_stmodindex
{ return my_module_index_helper
('standard', @_); }
539 sub ref_module_index_helper
{
540 local($word, $ahref) = @_;
541 my $str = next_argument
();
542 $word = "$word " if $word;
543 $str = "<tt>$str</tt> (${word}module)";
544 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
545 # just inline it all here
546 $str = gen_index_id
($str, 'REF');
547 $index{$str} .= $ahref;
548 write_idxfile
($ahref, $str);
551 # these should be adjusted a bit....
552 define_indexing_macro
('refmodindex', 'refbimodindex',
553 'refexmodindex', 'refstmodindex');
554 sub idx_cmd_refmodindex
{ return ref_module_index_helper
('', @_); }
555 sub idx_cmd_refbimodindex
{ return ref_module_index_helper
('built-in', @_); }
556 sub idx_cmd_refexmodindex
{ return ref_module_index_helper
('extension', @_); }
557 sub idx_cmd_refstmodindex
{ return ref_module_index_helper
('standard', @_); }
559 sub do_cmd_nodename
{ return do_cmd_label
(@_); }
562 # $anchor_invisible_mark = '';
564 $icons{'anchor_mark'} = '';
568 # Create an index entry, but include the string in the target anchor
569 # instead of the dummy filler.
571 sub make_str_index_entry
{
573 my($name,$aname,$ahref) = new_link_info
();
574 add_index_entry
($str, $ahref);
575 return "$aname$str</a>";
578 sub do_env_cfuncdesc
{
580 my $return_type = next_argument
();
581 my $function_name = next_argument
();
582 my $arg_list = next_argument
();
583 my $idx = make_str_index_entry
("<tt class=cfunction>$function_name()</tt>"
584 . get_indexsubitem
());
586 $idx =~ s/\(\)//; # ????
587 return "<dl><dt>$return_type <b>$idx</b> (<var>$arg_list</var>)\n<dd>"
592 sub do_env_ctypedesc
{
594 my $type_name = next_argument
();
595 my $idx = make_str_index_entry
("<tt class=ctype>$type_name</tt>"
596 . get_indexsubitem
());
598 return "<dl><dt><b>$idx</b>\n<dd>"
605 my $var_type = next_argument
();
606 my $var_name = next_argument
();
607 my $idx = make_str_index_entry
("<tt class=cdata>$var_name</tt>"
608 . get_indexsubitem
());
610 return "<dl><dt>$var_type <b>$idx</b>\n"
618 my $function_name = next_argument
();
619 my $arg_list = next_argument
();
620 my $idx = make_str_index_entry
("<tt class=function>$function_name()</tt>"
621 . get_indexsubitem
());
623 $idx =~ s/\(\)<\/tt>/<\
/tt>/;
624 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
627 sub do_env_funcdescni
{
629 my $function_name = next_argument
();
630 my $arg_list = next_argument
();
631 return "<dl><dt><b><tt class=function>$function_name</tt></b>"
632 . " (<var>$arg_list</var>)\n"
640 my $function_name = next_argument
();
641 my $arg_list = next_argument
();
642 my $prefix = "<tt class=function>$function_name()</tt>";
643 my $idx = make_str_index_entry
($prefix . get_indexsubitem
());
646 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
649 sub do_cmd_funclineni
{
651 my $function_name = next_argument
();
652 my $arg_list = next_argument
();
653 my $prefix = "<tt class=function>$function_name</tt>";
655 return "<dt><b>$prefix</b> (<var>$arg_list</var>)\n<dd>" . $_;
658 # Change this flag to index the opcode entries. I don't think it's very
659 # useful to index them, since they're only presented to describe the dis
664 sub do_env_opcodedesc
{
666 my $opcode_name = next_argument
();
667 my $arg_list = next_argument
();
669 if ($INDEX_OPCODES) {
670 $idx = make_str_index_entry
(
671 "<tt class=opcode>$opcode_name</tt> (byte code instruction)");
672 $idx =~ s/ \(byte code instruction\)//;
675 $idx = "<tt class=opcode>$opcode_name</tt>";
677 my $stuff = "<dl><dt><b>$idx</b>";
679 $stuff .= " <var>$arg_list</var>";
681 return $stuff . "\n<dd>" . $_ . '</dl>';
686 my $dataname = next_argument
();
687 my $idx = make_str_index_entry
("<tt>$dataname</tt>" . get_indexsubitem
());
689 return "<dl><dt><b>$idx</b>\n<dd>"
694 sub do_env_datadescni
{
696 my $idx = next_argument
();
697 if (! $STRING_INDEX_TT) {
698 $idx = "<tt>$idx</tt>";
700 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
705 my $data_name = next_argument
();
706 my $idx = make_str_index_entry
("<tt>$data_name</tt>" . get_indexsubitem
());
708 return "<dt><b>$idx</b><dd>" . $_;
713 my $excname = next_argument
();
714 my $idx = make_str_index_entry
("<tt class=exception>$excname</tt>");
715 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
718 sub do_env_fulllineitems
{ return do_env_itemize
(@_); }
721 sub do_env_classdesc
{
723 $THIS_CLASS = next_argument
();
724 my $arg_list = next_argument
();
725 $idx = make_str_index_entry
(
726 "<tt class=class>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
728 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
732 sub do_env_methoddesc
{
734 my $class_name = next_optional_argument
();
735 $class_name = $THIS_CLASS
737 my $method = next_argument
();
738 my $arg_list = next_argument
();
741 $extra = " ($class_name method)";
743 my $idx = make_str_index_entry
("<tt class=method>$method()</tt>$extra");
746 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
750 sub do_cmd_methodline
{
752 my $class_name = next_optional_argument
();
753 $class_name = $THIS_CLASS
755 my $method = next_argument
();
756 my $arg_list = next_argument
();
759 $extra = " ($class_name method)";
761 my $idx = make_str_index_entry
("<tt class=method>$method()</tt>$extra");
764 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
769 sub do_cmd_methodlineni
{
771 next_optional_argument
();
772 my $method = next_argument
();
773 my $arg_list = next_argument
();
774 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
778 sub do_env_methoddescni
{
780 next_optional_argument
();
781 my $method = next_argument
();
782 my $arg_list = next_argument
();
783 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
789 sub do_env_memberdesc
{
791 my $class = next_optional_argument
();
792 my $member = next_argument
();
796 $extra = " ($class attribute)"
798 my $idx = make_str_index_entry
("<tt class=member>$member</tt>$extra");
801 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
805 sub do_cmd_memberline
{
807 my $class = next_optional_argument
();
808 my $member = next_argument
();
812 $extra = " ($class attribute)"
814 my $idx = make_str_index_entry
("<tt class=member>$member</tt>$extra");
817 return "<dt><b>$idx</b><dd>" . $_;
820 sub do_env_memberdescni
{
822 next_optional_argument
();
823 my $member = next_argument
();
824 return "<dl><dt><b><tt class=member>$member</tt></b>\n<dd>" . $_ . '</dl>';
828 sub do_cmd_memberlineni
{
830 next_optional_argument
();
831 my $member = next_argument
();
832 return "<dt><b><tt class=member>$member</tt></b><dd>" . $_;
835 @col_aligns = ("<td>", "<td>", "<td>", "<td>");
837 $TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR;
843 { $r = '<th align=left>'; }
844 elsif (substr($a, 0, 1) eq 'p')
845 { $r = '<th align=left>'; }
847 { $r = '<th align=right>'; }
852 # do a little magic on a font name to get the right behavior in the first
853 # column of the output table
855 if ($font eq 'textrm') {
858 elsif ($font eq 'file' || $font eq 'filenq') {
859 $font = 'tt class=file';
864 sub setup_column_alignments
{
866 my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
867 my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>');
868 $col_aligns[0] = (($a1 eq 'c') ?
'<td align=center valign=baseline>'
869 : '<td valign=baseline>');
870 $col_aligns[1] = (($a2 eq 'c') ?
'<td align=center>' : '<td>');
871 $col_aligns[2] = (($a3 eq 'c') ?
'<td align=center>' : '<td>');
872 $col_aligns[3] = (($a4 eq 'c') ?
'<td align=center>' : '<td>');
873 # return the aligned header start tags
874 return (get_th
($a1), get_th
($a2), get_th
($a3), get_th
($a4));
879 my($th1,$th2,$th3,$th4) = setup_column_alignments
(next_argument
());
880 my $font = fix_font
(next_argument
());
881 my $h1 = next_argument
();
882 my $h2 = next_argument
();
884 $globals{'lineifont'} = $font;
885 return '<table border align=center style="border-collapse: collapse">'
887 . "\n <tr$TABLE_HEADER_BGCOLOR>"
888 . "\n $th1<b>$h1</b>\ \ </th>"
889 . "\n $th2<b>$h2</b>\ \ </th>"
891 . "\n <tbody valign=baseline>"
899 my $c1 = next_argument
();
900 my $c2 = next_argument
();
902 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
908 my($c1align,$c2align) = @col_aligns[0,1];
909 return "\n <tr>$c1align$sfont$c1$efont</td>\n"
910 . " $c2align$c2\ </td>"
916 my($th1,$th2,$th3,$th4) = setup_column_alignments
(next_argument
());
917 my $font = fix_font
(next_argument
());
918 my $h1 = next_argument
();
919 my $h2 = next_argument
();
920 my $h3 = next_argument
();
922 $globals{'lineifont'} = $font;
923 return '<table border align=center style="border-collapse: collapse">'
925 . "\n <tr$TABLE_HEADER_BGCOLOR>"
926 . "\n $th1<b>$h1</b>\ \ </th>"
927 . "\n $th2<b>$h2</b>\ \ </th>"
928 . "\n $th3<b>$h3</b>\ \ </th>"
930 . "\n <tbody valign=baseline>"
938 my $c1 = next_argument
();
939 my $c2 = next_argument
();
940 my $c3 = next_argument
();
942 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
948 my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
949 return "\n <tr>$c1align$sfont$c1$efont</td>\n"
950 . " $c2align$c2</td>\n"
951 . " $c3align$c3\ </td>"
957 my($th1,$th2,$th3,$th4) = setup_column_alignments
(next_argument
());
958 my $font = fix_font
(next_argument
());
959 my $h1 = next_argument
();
960 my $h2 = next_argument
();
961 my $h3 = next_argument
();
962 my $h4 = next_argument
();
964 $globals{'lineifont'} = $font;
965 return '<table border align=center style="border-collapse: collapse">'
967 . "\n <tr$TABLE_HEADER_BGCOLOR>"
968 . "\n $th1<b>$h1</b>\ \ </th>"
969 . "\n $th2<b>$h2</b>\ \ </th>"
970 . "\n $th3<b>$h3</b>\ \ </th>"
971 . "\n $th4<b>$h4</b>\ \ </th>"
973 . "\n <tbody valign=baseline>"
981 my $c1 = next_argument
();
982 my $c2 = next_argument
();
983 my $c3 = next_argument
();
984 my $c4 = next_argument
();
986 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
992 my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
993 return "\n <tr>$c1align$sfont$c1$efont</td>\n"
994 . " $c2align$c2</td>\n"
995 . " $c3align$c3</td>\n"
996 . " $c4align$c4\ </td>"
1000 sub do_cmd_maketitle
{
1002 my $the_title = "\n<div class=titlepage><center>";
1004 $the_title .= "\n<h1>$t_title</h1>";
1005 } else { write_warnings
("\nThis document has no title."); }
1008 my $href = translate_commands
($t_authorURL);
1009 $href = make_named_href
('author', $href,
1010 "<b><font size='+2'>$t_author</font></b>");
1011 $the_title .= "\n<p>$href</p>";
1013 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
1015 } else { write_warnings
("\nThere is no author for this document."); }
1017 $the_title .= "\n<p>$t_institute</p>";}
1018 if ($DEVELOPER_ADDRESS) {
1019 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
1021 $the_title .= "\n<p><i>$t_affil</i></p>";}
1023 $the_title .= "\n<p><strong>$t_date</strong>";
1024 if ($PYTHON_VERSION) {
1025 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
1026 $the_title .= "</p>"
1029 $the_title .= "\n<p>$t_address</p>";
1030 } else { $the_title .= "\n<p>"}
1032 $the_title .= "\n<p>$t_email</p>";
1033 }# else { $the_title .= "</p>" }
1034 $the_title .= "\n</center></div>";
1035 return $the_title . $_ ;
1040 # Module synopsis support
1043 require SynopsisTable
;
1045 sub get_chapter_id
(){
1046 my $id = do_cmd_thechapter
('');
1047 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\
1/;
1052 %ModuleSynopses = ('chapter' => 'SynopsisTable instance');
1054 sub get_synopsis_table
($){
1056 my $st = $ModuleSynopses{$chap};
1058 foreach $key (keys %ModuleSynopses) {
1059 if ($key eq $chap) {
1060 return $ModuleSynopses{$chap};
1063 $st = SynopsisTable
->new();
1064 $ModuleSynopses{$chap} = $st;
1068 sub do_cmd_moduleauthor
{
1075 sub do_cmd_sectionauthor
{
1082 sub do_cmd_declaremodule
{
1084 my $key = next_optional_argument
();
1085 my $type = next_argument
();
1086 my $name = next_argument
();
1087 my $st = get_synopsis_table
(get_chapter_id
());
1089 $key = $name unless $key;
1090 $type = 'built-in' if $type eq 'builtin';
1091 $st->declare($name, $key, $type);
1092 define_module
($type, $name);
1093 return anchor_label
("module-$key",$CURRENT_FILE,$_)
1096 sub do_cmd_modulesynopsis
{
1098 my $st = get_synopsis_table
(get_chapter_id
());
1099 $st->set_synopsis($THIS_MODULE, translate_commands
(next_argument
()));
1103 sub do_cmd_localmoduletable
{
1105 my $chap = get_chapter_id
();
1106 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
1109 sub process_all_localmoduletables
{
1110 while (/<tex2html-localmoduletable><(\d+)>/) {
1113 my $st = get_synopsis_table
($chap);
1114 my $data = $st->tohtml();
1118 sub process_python_state
{
1119 process_all_localmoduletables
();
1124 # "See also:" -- references placed at the end of a \section
1128 return "<div class=seealso>\n "
1129 . "<p class=heading><b>See Also:</b></p>\n"
1134 sub do_cmd_seemodule
{
1135 # Insert the right magic to jump to the module definition. This should
1136 # work most of the time, at least for repeat builds....
1138 my $key = next_optional_argument
();
1139 my $module = next_argument
();
1140 my $text = next_argument
();
1144 if ($text =~ /\.$/) {
1147 return '<dl compact class=seemodule>'
1148 . "\n <dt>Module <b><tt class=module><a href=\"module-$key.html\">"
1149 . "$module</a></tt>:</b>"
1150 . "\n <dd>$text$period\n </dl>"
1156 my $content = next_argument
();
1157 return '<div class=seetext><p>' . $content . '</div>' . $_;
1162 # Definition list support.
1165 sub do_env_definitions
{
1167 return "<dl class=definitions>$_</dl>\n";
1172 my $term = next_argument
();
1173 my($name,$aname,$ahref) = new_link_info
();
1174 # could easily add an index entry here...
1175 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
1179 process_commands_wrap_deferred
(<<_RAW_ARG_DEFERRED_CMDS_
);
1181 declaremodule
# [] # {} # {}
1182 memberline
# [] # {}
1183 methodline
# [] # {} # {}
1187 setindexsubitem
# {}
1188 withsubitem
# {} # {}
1189 _RAW_ARG_DEFERRED_CMDS_
1192 1; # This must be the last line