blob: a29220eef97a13f565fe7b4d18a66b891d5813f6 [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($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000031 s/$next_pair_pr_rx//;
Fred Drake6659c301998-03-03 22:02:19 +000032 $PYTHON_VERSION = "$2";
33 $_;
34}
35
36sub do_cmd_authoraddress{
37 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000038 s/$next_pair_pr_rx//;
Fred Drake6659c301998-03-03 22:02:19 +000039 $AUTHOR_ADDRESS = "$2";
40 $_;
41}
42
43sub do_cmd_hackscore{
44 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000045 s/$next_pair_pr_rx/_/;
Fred Drake6659c301998-03-03 22:02:19 +000046 $_;
47}
48
49sub do_cmd_optional{
50 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000051 s|$next_pair_pr_rx|</var><big>\[</big><var>\2</var><big>\]</big><var>|;
Fred Drake6659c301998-03-03 22:02:19 +000052 $_;
53}
54
55sub do_cmd_varvars{
56 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000057 s|$next_pair_pr_rx|<var>\2</var>|;
Fred Drake6659c301998-03-03 22:02:19 +000058 $_;
59}
60
Fred Drakec9a44381998-03-17 06:29:13 +000061# Logical formatting (some based on texinfo), needs to be converted to
62# minimalist HTML. The "minimalist" is primarily to reduce the size of
63# output files for users that read them over the network rather than
64# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +000065
66sub do_cmd_code{
67 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000068 s|$next_pair_pr_rx|<tt>\2</tt>|;
69 $_;
70}
71
72sub use_sans_serif{
73 local($_) = @_;
74 s|$next_pair_pr_rx|<font face=sans-serif>\2</font>|;
75 $_;
76}
77
78sub use_italics{
79 local($_) = @_;
80 s|$next_pair_pr_rx|<i>\2</i>|;
Fred Drake6659c301998-03-03 22:02:19 +000081 $_;
82}
83
84sub do_cmd_sectcode{ &do_cmd_code(@_); }
85sub do_cmd_module{ &do_cmd_code(@_); }
86sub do_cmd_keyword{ &do_cmd_code(@_); }
87sub do_cmd_exception{ &do_cmd_code(@_); }
88sub do_cmd_class{ &do_cmd_code(@_); }
89sub do_cmd_function{ &do_cmd_code(@_); }
90sub do_cmd_constant{ &do_cmd_code(@_); }
91sub do_cmd_member{ &do_cmd_code(@_); }
92sub do_cmd_method{ &do_cmd_code(@_); }
Fred Drake6659c301998-03-03 22:02:19 +000093sub do_cmd_cfunction{ &do_cmd_code(@_); }
94sub do_cmd_cdata{ &do_cmd_code(@_); }
95sub do_cmd_ctype{ &do_cmd_code(@_); }
Fred Drakec9a44381998-03-17 06:29:13 +000096sub do_cmd_regexp{ &do_cmd_code(@_); }
97sub do_cmd_key{ &do_cmd_code(@_); }
Fred Drake6659c301998-03-03 22:02:19 +000098
Fred Drakefc16e781998-03-12 21:03:26 +000099sub do_cmd_character{ &do_cmd_samp(@_); }
100
Fred Drakec9a44381998-03-17 06:29:13 +0000101sub do_cmd_program{ &do_cmd_strong(@_); }
102
103sub do_cmd_email{ &use_sans_serif(@_); }
104sub do_cmd_mimetype{ &use_sans_serif(@_); }
105
106sub do_cmd_var{ &use_italics(@_); }
107sub do_cmd_dfn{ &use_italics(@_); }
108sub do_cmd_emph{ &use_italics(@_); }
109
Fred Drakefc16e781998-03-12 21:03:26 +0000110
111sub do_cmd_envvar{
112 local($_) = @_;
113 s/$next_pair_pr_rx/\$\2/;
114 $_;
115}
116
Fred Drake6659c301998-03-03 22:02:19 +0000117sub do_cmd_url{
118 # use the URL as both text and hyperlink
119 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000120 s/$next_pair_pr_rx//;
121 my $url = $2;
Fred Drake6659c301998-03-03 22:02:19 +0000122 $url =~ s/~/&#126;/g;
Fred Drakec9a44381998-03-17 06:29:13 +0000123 "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000124}
125
126sub do_cmd_manpage{
127 # two parameters: \manpage{name}{section}
128 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000129 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
130 s|$pair_pr_rx$any_next_pair_pr_rx3|<i>\2</i>(\4)|;
Fred Drake6659c301998-03-03 22:02:19 +0000131 $_;
132}
133
134sub do_cmd_rfc{
135 local($_) = @_;
136 s/$next_pair_pr_rx//;
Fred Drakec9a44381998-03-17 06:29:13 +0000137 my($br_id,$rfcnumber) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000138
139 # Save the reference
Fred Drakec9a44381998-03-17 06:29:13 +0000140 my $nstr = &gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drake6659c301998-03-03 22:02:19 +0000141 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
Fred Drakec9a44381998-03-17 06:29:13 +0000142 "<a name=$br_id>RFC $rfcnumber</a>" .$_;
Fred Drake6659c301998-03-03 22:02:19 +0000143}
144
145sub do_cmd_kbd{
146 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000147 s|$next_pair_pr_rx|<kbd>\2</kbd>|;
Fred Drake6659c301998-03-03 22:02:19 +0000148 $_;
149}
150
151sub do_cmd_strong{
152 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000153 s|$next_pair_pr_rx|<b>\2</b>|;
Fred Drake6659c301998-03-03 22:02:19 +0000154 $_;
155}
156
157sub do_cmd_deprecated{
158 # two parameters: \deprecated{version}{whattodo}
159 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000160 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
161 my($release,$action) = ($2, $4);
Fred Drake6659c301998-03-03 22:02:19 +0000162 s/$next_pair_pr_rx$any_next_pair_pr_rx3//;
163 "<b>Deprecated since release $release.</b>"
164 . "\n$action<p>"
165 . $_;
166}
167
168# file and samp are at the end of this file since they screw up fontlock.
169
170# index commands
171
172$INDEX_SUBITEM = "";
173
174sub get_indexsubitem{
Fred Drakefc16e781998-03-12 21:03:26 +0000175 #$INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
176 '';
Fred Drake6659c301998-03-03 22:02:19 +0000177}
178
179sub do_cmd_setindexsubitem{
180 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000181 s/$next_pair_pr_rx//;
Fred Drake6659c301998-03-03 22:02:19 +0000182 $INDEX_SUBITEM = $2;
183 $_;
184}
185
Fred Drakefc16e781998-03-12 21:03:26 +0000186sub do_cmd_withsubitem{
187 # We can't really do the right right thing, because LaTeX2HTML doesn't
188 # do things in the right order, but we need to at least strip this stuff
189 # out, and leave anything that the second argument expanded out to.
190 #
191 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000192 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drakefc16e781998-03-12 21:03:26 +0000193 s/$next_pair_pr_rx$any_next_pair_pr_rx3/\4/;
194 $_;
195}
196
197sub do_cmd_makemodindex{ @_[0]; }
198
Fred Drake6659c301998-03-03 22:02:19 +0000199sub do_cmd_indexii{
200 local($_) = @_;
201 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000202 my($br_id1,$str1) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000203 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000204 my($br_id2,$str2) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000205 join('', &make_index_entry($br_id1, "$str1 $str2"),
206 &make_index_entry($br_id2, "$str2, $str1"), $_);
207}
208
209sub do_cmd_indexiii{
210 local($_) = @_;
211 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000212 my($br_id1,$str1) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000213 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000214 my($br_id2,$str2) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000215 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000216 my($br_id3,$str3) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000217 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
218 &make_index_entry($br_id2, "$str2 $str3, $str1"),
219 &make_index_entry($br_id3, "$str3, $str1 $str2"),
220 $_);
221}
222
223sub do_cmd_indexiv{
224 local($_) = @_;
225 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000226 my($br_id1,$str1) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000227 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000228 my($br_id2,$str2) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000229 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000230 my($br_id3,$str3) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000231 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000232 my($br_id4,$str4) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000233 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
234 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
235 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
236 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
237 $_);
238}
239
Fred Drakec9a44381998-03-17 06:29:13 +0000240sub do_cmd_ttindex{
241 local($_) = @_;
242 s/$next_pair_pr_rx//;
243 my($br_id,$str) = ($1, $2);
244 &make_index_entry($br_id, $str . &get_indexsubitem) . $_;
245}
Fred Drake6659c301998-03-03 22:02:19 +0000246
247sub my_typed_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000248 local($word,$_) = @_;
Fred Drake6659c301998-03-03 22:02:19 +0000249 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000250 my($br_id,$str) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000251 join('', &make_index_entry($br_id, "$str $word"),
252 &make_index_entry($br_id, "$word, $str"), $_);
253}
254
255sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
256sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
257sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
258sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
259
260sub my_parword_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000261 local($word,$_) = @_;
Fred Drake6659c301998-03-03 22:02:19 +0000262 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000263 my($br_id,$str) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000264 &make_index_entry($br_id, "$str ($word)") . $_;
265}
266
267
268# Set this to true to strip out the <tt>...</tt> from index entries;
269# this is analogous to using the second definition of \idxcode{} from
270# myformat.sty.
271#
272# It is used from &make_mod_index_entry() and &make_str_index_entry().
273#
274$STRIP_INDEX_TT = 0;
275
276sub make_mod_index_entry{
Fred Drakec9a44381998-03-17 06:29:13 +0000277 my($br_id,$str,$define) = @_;
278 my $halfref = &make_half_href("$CURRENT_FILE#$br_id");
Fred Drake6659c301998-03-03 22:02:19 +0000279 # If TITLE is not yet available (i.e the \index command is in the title
280 # of the current section), use $ref_before.
281 $TITLE = $ref_before unless $TITLE;
282 # Save the reference
Fred Drakec9a44381998-03-17 06:29:13 +0000283 if ($define eq 'DEF') {
284 my($nstr,$garbage) = split / /, $str, 2;
Fred Drake6659c301998-03-03 22:02:19 +0000285 $Modules{$nstr} .= $halfref;
286 }
287 $str = &gen_index_id($str, $define);
288 if ($STRIP_INDEX_TT) {
Fred Drakec9a44381998-03-17 06:29:13 +0000289 $str =~ s|<tt>(.*)</tt>|\1|;
Fred Drake6659c301998-03-03 22:02:19 +0000290 }
291 $index{$str} .= $halfref;
Fred Drakec9a44381998-03-17 06:29:13 +0000292 "<a name=$br_id>$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000293}
294
Fred Drakec9a44381998-03-17 06:29:13 +0000295$THIS_MODULE = '';
296
Fred Drake6659c301998-03-03 22:02:19 +0000297sub my_module_index_helper{
298 local($word, $_) = @_;
299 s/$next_pair_pr_rx[\n]*//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000300 my($br_id, $str) = ($1, $2);
301 my $section_tag = join('', @curr_sec_id);
Fred Drake6659c301998-03-03 22:02:19 +0000302 $word = "$word " if $word;
Fred Drakec9a44381998-03-17 06:29:13 +0000303 $THIS_MODULE = "$str";
Fred Drake6659c301998-03-03 22:02:19 +0000304 &make_mod_index_entry("SECTION$section_tag",
305 "<tt>$str</tt> (${word}module)", 'DEF');
306 $_;
307}
308
309sub ref_module_index_helper{
310 local($word, $_) = @_;
311 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000312 my($br_id, $str) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000313 $word = "$word " if $word;
314 &make_mod_index_entry($br_id, "<tt>$str</tt> (${word}module)", 'REF') . $_;
315}
316
Fred Drakec9a44381998-03-17 06:29:13 +0000317sub do_cmd_bifuncindex{
318 local($_) = @_;
319 s/$next_pair_pr_rx//o;
320 my($br_id,$str,$fname) = ($1, $2, "<tt>$2()</tt>");
321 $fname = "$str()"
322 if $STRIP_INDEX_TT;
323 &make_index_entry($br_id, "$fname (built-in function)") . $_;
324}
325
Fred Drake6659c301998-03-03 22:02:19 +0000326sub 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{
Fred Drakec9a44381998-03-17 06:29:13 +0000383 my($br_id,$str) = @_;
Fred Drake6659c301998-03-03 22:02:19 +0000384 # 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
Fred Drakec9a44381998-03-17 06:29:13 +0000388 my $nstr = &gen_index_id($str, '');
Fred Drake6659c301998-03-03 22:02:19 +0000389 if ($STRIP_INDEX_TT) {
Fred Drakec9a44381998-03-17 06:29:13 +0000390 $nstr =~ s|<tt>(.*)</tt>|\1|;
Fred Drake6659c301998-03-03 22:02:19 +0000391 }
392 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
Fred Drakec9a44381998-03-17 06:29:13 +0000393 "<a name=\"$br_id\">$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000394}
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 Drakec9a44381998-03-17 06:29:13 +0000402 my($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 Drakec9a44381998-03-17 06:29:13 +0000410 my($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($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000421 my($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
422 my $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
423 my $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
424 my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
Fred Drake6659c301998-03-03 22:02:19 +0000425 if (/$cfuncdesc_rx/o) {
426 $return_type = "$2";
427 $function_name = "$4";
428 $arg_list = "$6";
429 $idx = &make_str_index_entry($3,
Fred Drakec9a44381998-03-17 06:29:13 +0000430 "<tt>$function_name()</tt>" . &get_indexsubitem);
Fred Drake6659c301998-03-03 22:02:19 +0000431 $idx =~ s/ \(.*\)//;
Fred Drakec9a44381998-03-17 06:29:13 +0000432 $idx =~ s/\(\)//;
Fred Drake6659c301998-03-03 22:02:19 +0000433 }
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($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000440 my $type_name = ('');
441 my $cfuncdesc_rx = "$next_pair_rx";
Fred Drake6659c301998-03-03 22:02:19 +0000442 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($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000453 my($var_type,$var_name,$idx) = ('', '', '');
454 my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3";
Fred Drake6659c301998-03-03 22:02:19 +0000455 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($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000468 my($function_name,$arg_list,$idx) = ('', '', '');
469 my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3";
Fred Drake6659c301998-03-03 22:02:19 +0000470 if (/$funcdesc_rx/o) {
471 $function_name = "$2";
472 $arg_list = "$4";
Fred Drakec9a44381998-03-17 06:29:13 +0000473 $idx = &make_str_index_entry($3, "<tt>$function_name()</tt>"
474 . &get_indexsubitem);
Fred Drake6659c301998-03-03 22:02:19 +0000475 $idx =~ s/ \(.*\)//;
Fred Drakec9a44381998-03-17 06:29:13 +0000476 $idx =~ s/\(\)//;
Fred Drake6659c301998-03-03 22:02:19 +0000477 }
478 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
479}
480
481sub do_env_funcdescni{
482 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000483 my($function_name,$arg_list,$idx) = ('', '', '');
484 my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3";
Fred Drake6659c301998-03-03 22:02:19 +0000485 if (/$funcdesc_rx/o) {
486 $function_name = "$2";
487 $arg_list = "$4";
488 if ($STRIP_INDEX_TT) {
Fred Drakec9a44381998-03-17 06:29:13 +0000489 $idx = "$function_name"; }
Fred Drake6659c301998-03-03 22:02:19 +0000490 else {
491 $idx = "<tt>$function_name</tt>"; }
492 }
493 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
494}
495
496sub do_cmd_funcline{
497 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000498 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake6659c301998-03-03 22:02:19 +0000499
Fred Drakec9a44381998-03-17 06:29:13 +0000500 s/$next_pair_pr_rx//o;
501 my $function_name = $2;
502 s/$next_pair_pr_rx//o;
503 my($br_id,$arg_list) = ($1, $2);
504 my $idx = &make_str_index_entry($br_id, "<tt>$function_name()</tt>"
505 . &get_indexsubitem);
506 $idx =~ s/\(\)//;
Fred Drake6659c301998-03-03 22:02:19 +0000507
508 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
509}
510
511# Change this flag to index the opcode entries. I don't think it's very
512# useful to index them, since they're only presented to describe the dis
513# module.
514#
515$INDEX_OPCODES = 0;
516
517sub do_env_opcodedesc{
518 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000519 my($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
520 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
521 my $opcodedesc_rx = "$next_pair_rx$any_next_pair_rx3";
Fred Drake6659c301998-03-03 22:02:19 +0000522 if (/$opcodedesc_rx/o) {
523 $opcode_name = "$2";
524 $arg_list = "$4";
525 if ($INDEX_OPCODES) {
526 $idx = &make_str_index_entry($3,
527 "<tt>$opcode_name</tt> (byte code instruction)");
528 $idx =~ s/ \(byte code instruction\)//;
529 }
530 else {
531 $idx = "<tt>$opcode_name</tt>";
532 }
533 }
534 $stuff = "<dl><dt><b>$idx</b>";
535 if ($arg_list) {
536 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
537 }
538 $stuff . "\n<dd>$'\n</dl>";
539}
540
541sub do_env_datadesc{
542 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000543 my $idx = '';
Fred Drake6659c301998-03-03 22:02:19 +0000544 if (/$next_pair_rx/o) {
545 $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
546 $idx =~ s/ \(.*\)//;
547 }
548 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
549}
550
551sub do_env_datadescni{
552 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000553 my $idx = '';
Fred Drake6659c301998-03-03 22:02:19 +0000554 if (/$next_pair_rx/o) {
555 if ($STRING_INDEX_TT) {
556 $idx = "$2"; }
557 else {
558 $idx = "<tt>$2</tt>"; }
559 }
560 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
561}
562
563sub do_cmd_dataline{
564 local($_) = @_;
565
566 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000567 my($br_id, $data_name) = ($1, $2);
568 my $idx = &make_str_index_entry($br_id, "<tt>$data_name</tt>"
569 . &get_indexsubitem);
Fred Drake6659c301998-03-03 22:02:19 +0000570 $idx =~ s/ \(.*\)//;
571
572 "<dt><b>$idx</b>\n<dd>" . $_;
573}
574
575sub do_env_excdesc{ &do_env_datadesc(@_); }
Fred Drakec9a44381998-03-17 06:29:13 +0000576#sub do_env_classdesc{ &do_env_funcdesc(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000577sub do_env_fulllineitems{ &do_env_itemize(@_); }
578
579
Fred Drakec9a44381998-03-17 06:29:13 +0000580sub do_env_classdesc{
581 local($_) = @_;
582 my($function_name,$arg_list,$idx) = ('', '', '');
583 my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3";
584 if (/$funcdesc_rx/o) {
585 $function_name = "$2";
586 $arg_list = "$4";
587 $idx = &make_str_index_entry($3,
588 "<tt>$function_name</tt> (class in $THIS_MODULE)" );
589 $idx =~ s/ \(.*\)//;
590 }
591 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
592}
593
Fred Drake6659c301998-03-03 22:02:19 +0000594@col_aligns = ("<td>", "<td>", "<td>");
595
596sub setup_column_alignments{
597 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000598 my($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_);
599 my($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
Fred Drake6659c301998-03-03 22:02:19 +0000600 $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>");
601 $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>");
602 $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>");
603 # return the aligned header start tags; only used for \begin{tableiii?}
604 $th1 = (($a1 eq "l") ? "<th align=left>"
605 : ($a1 eq "r" ? "<th align=right>" : "<th>"));
606 $th2 = (($a2 eq "l") ? "<th align=left>"
607 : ($a2 eq "r" ? "<th align=right>" : "<th>"));
608 $th3 = (($a3 eq "l") ? "<th align=left>"
609 : ($a3 eq "r" ? "<th align=right>" : "<th>"));
610 ($th1, $th2, $th3);
611}
612
613sub do_env_tableii{
614 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000615 my($font,$h1,$h2) = ('', '', '');
616 my $tableiii_rx =
Fred Drake6659c301998-03-03 22:02:19 +0000617 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7";
618 if (/$tableiii_rx/o) {
619 $font = $4;
620 $h1 = $6;
621 $h2 = $8;
622 }
Fred Drakec9a44381998-03-17 06:29:13 +0000623 my($th1,$th2,$th3) = &setup_column_alignments($2);
Fred Drake6659c301998-03-03 22:02:19 +0000624 $globals{"lineifont"} = $font;
625 "<table border align=center>"
626 . "\n <tr>$th1<b>$h1</b></th>"
627 . "\n $th2<b>$h2</b></th>$'"
628 . "\n</table>";
629}
630
631sub do_cmd_lineii{
632 local($_) = @_;
633 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000634 my $c1 = $2;
Fred Drake6659c301998-03-03 22:02:19 +0000635 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000636 my $c2 = $2;
637 my $font = $globals{"lineifont"};
638 my($c1align,$c2align) = @col_aligns[0,1];
Fred Drake6659c301998-03-03 22:02:19 +0000639 "<tr>$c1align<$font>$c1</$font></td>\n"
640 . " $c2align$c2</td>$'";
641}
642
643sub do_env_tableiii{
644 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000645 my($font,$h1,$h2,$h3) = ('', '', '', '');
Fred Drake6659c301998-03-03 22:02:19 +0000646
Fred Drakec9a44381998-03-17 06:29:13 +0000647 my $tableiii_rx =
Fred Drake6659c301998-03-03 22:02:19 +0000648 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"
649 . "$any_next_pair_rx9";
650 if (/$tableiii_rx/o) {
651 $font = $4;
652 $h1 = $6;
653 $h2 = $8;
654 $h3 = $10;
655 }
Fred Drakec9a44381998-03-17 06:29:13 +0000656 my($th1,$th2,$th3) = &setup_column_alignments($2);
Fred Drake6659c301998-03-03 22:02:19 +0000657 $globals{"lineifont"} = $font;
658 "<table border align=center>"
659 . "\n <tr>$th1<b>$h1</b></th>"
660 . "\n $th2<b>$h2</b></th>"
661 . "\n $th3<b>$h3</b></th>$'"
662 . "\n</table>";
663}
664
665sub do_cmd_lineiii{
666 local($_) = @_;
667 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000668 my $c1 = $2;
Fred Drake6659c301998-03-03 22:02:19 +0000669 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000670 my $c2 = $2;
Fred Drake6659c301998-03-03 22:02:19 +0000671 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000672 my $c3 = $2;
673 my $font = $globals{"lineifont"};
674 my($c1align, $c2align, $c3align) = @col_aligns;
Fred Drake6659c301998-03-03 22:02:19 +0000675 "<tr>$c1align<$font>$c1</$font></td>\n"
676 . " $c2align$c2</td>\n"
677 . " $c3align$c3</td>$'";
678}
679
680sub do_env_seealso{
681 "<p><b>See Also:</b></p>\n" . @_[0];
682}
683
684sub do_cmd_seemodule{
685 # Insert the right magic to jump to the module definition. This should
686 # work most of the time, at least for repeat builds....
687 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000688 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
689 my $any_next_pair_pr_rx5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
690 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
691 # require the argument to be there.
692 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
693 s/$opt_arg_rx$any_next_pair_pr_rx3$any_next_pair_pr_rx5//;
694 my($key,$module,$text) = ($2, $4, $6);
695 $key = $module unless $key;
Fred Drakeb3c9bca1998-03-06 21:20:08 +0000696 "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
Fred Drake6659c301998-03-03 22:02:19 +0000697 . "&nbsp;&nbsp;&nbsp;($text)</p>"
698 . $_;
699}
700
701sub do_cmd_seetext{
702 "<p>" . @_[0];
703}
704
705
706sub do_cmd_maketitle {
707 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000708 my $the_title = '';
Fred Drake6659c301998-03-03 22:02:19 +0000709 if ($t_title) {
Fred Drakec9a44381998-03-17 06:29:13 +0000710 $the_title .= "<h1 align=center>$t_title</h1>";
Fred Drake6659c301998-03-03 22:02:19 +0000711 } else { &write_warnings("\nThis document has no title."); }
Fred Drakec9a44381998-03-17 06:29:13 +0000712 $the_title .= "\n<center>";
Fred Drake6659c301998-03-03 22:02:19 +0000713 if ($t_author) {
714 if ($t_authorURL) {
Fred Drakec9a44381998-03-17 06:29:13 +0000715 my $href = &translate_commands($t_authorURL);
Fred Drake6659c301998-03-03 22:02:19 +0000716 $href = &make_named_href('author', $href, "<strong>${t_author}</strong>");
Fred Drakec9a44381998-03-17 06:29:13 +0000717 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +0000718 } else {
Fred Drakec9a44381998-03-17 06:29:13 +0000719 $the_title .= "\n<p><strong>$t_author</strong></p>";
Fred Drake6659c301998-03-03 22:02:19 +0000720 }
721 } else { &write_warnings("\nThere is no author for this document."); }
722 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +0000723 $the_title .= "\n<p>$t_institute</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000724 if ($AUTHOR_ADDRESS) {
Fred Drakec9a44381998-03-17 06:29:13 +0000725 $the_title .= "\n<p>$AUTHOR_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000726 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +0000727 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000728 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +0000729 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +0000730 if ($PYTHON_VERSION) {
731 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
732 $the_title .= "</p>"
733 }
Fred Drakec9a44381998-03-17 06:29:13 +0000734 $the_title .= "\n</center>";
Fred Drake6659c301998-03-03 22:02:19 +0000735 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +0000736 $the_title .= "\n<p>$t_address</p>";
737 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +0000738 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +0000739 $the_title .= "\n<p>$t_email</p>";
740 }# else { $the_title .= "</p>" }
741 $the_title . "<hr>\n" . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +0000742}
743
744
Fred Drakefc16e781998-03-12 21:03:26 +0000745sub do_cmd_inputindex{
746 local($_) = @_;
747 s/$next_pair_pr_rx//;
748 &do_cmd_input($2);
749}
750
Fred Drakec9a44381998-03-17 06:29:13 +0000751sub do_cmd_indexlabel{
752 "genindex" . @_[0];
753}
754
Fred Drakefc16e781998-03-12 21:03:26 +0000755
756# These are located down here since they screw up fontlock. -- used to.
Fred Drake6659c301998-03-03 22:02:19 +0000757
758sub do_cmd_file{
759 # This uses a weird HTML construct to adjust the font to be
760 # reasonable match that used in the printed form as much as
761 # possible. The expected behavior is that a browser that doesn't
762 # understand "<font face=...>" markup will use courier (or whatever
763 # the font is for <tt>).
764 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000765 s|$next_pair_pr_rx|\"<tt>\2</tt>\"|;
Fred Drake6659c301998-03-03 22:02:19 +0000766 $_;
767}
768
769sub do_cmd_samp{
770 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000771 s|$next_pair_pr_rx|\"<tt>\2</tt>\"|;
Fred Drake6659c301998-03-03 22:02:19 +0000772 $_;
773}
774
7751; # This must be the last line