blob: baa9b9097351686b64ad9e1e971c8a8bc42887a7 [file] [log] [blame]
Fred Drake8ca70061997-12-08 20:59:54 +00001# myformat.perl by Guido van Rossum <guido@cwi.nl> 25 Jan 1994 -*- perl -*-
Guido van Rossum9e93fb61994-01-25 20:06:09 +00002#
3# Extension to LaTeX2HTML for documents using myformat.sty.
4# Subroutines of the form do_cmd_<name> here define translations
5# for LaTeX commands \<name> defined in the corresponding .sty file.
6#
7# XXX Not complete: \indexii etc.; \funcitem etc.
8
Fred Drake44640221996-11-11 20:51:09 +00009package main;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000010
11# \bcode and \ecode brackets around verbatim
12
13sub do_cmd_bcode{ @_[0]; }
14sub do_cmd_ecode{ @_[0]; }
15
16# words typeset in a special way (not in HTML though)
17
18sub do_cmd_ABC{ join('', 'ABC', @_[0]); }
19sub do_cmd_UNIX{ join('', 'Unix', @_[0]); }
20sub do_cmd_ASCII{ join('', 'ASCII', @_[0]); }
Fred Drakebceaf351998-01-22 16:13:44 +000021sub do_cmd_POSIX{ join('', 'POSIX', @_[0]); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000022sub do_cmd_C{ join('', 'C', @_[0]); }
Guido van Rossumb8b264b1994-08-12 13:13:50 +000023sub do_cmd_Cpp{ join('', 'C++', @_[0]); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000024sub do_cmd_EOF{ join('', 'EOF', @_[0]); }
Fred Drake00dcfb21998-02-13 07:21:03 +000025sub do_cmd_NULL{ join('', '<tt>NULL</tt>', @_[0]); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000026
Fred Drake3e1fe891996-11-11 23:03:36 +000027sub do_cmd_e{ local($_) = @_; '&#92;' . $_; }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000028
Fred Drakec384d751996-11-11 16:04:35 +000029sub do_cmd_optional{
Fred Drake00dcfb21998-02-13 07:21:03 +000030 local($_) = @_;
31 s/$any_next_pair_pr_rx/<\/var><big>\[<\/big><var>\2<\/var><big>\]<\/big><var>/;
32 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000033}
34
Fred Drakec384d751996-11-11 16:04:35 +000035sub do_cmd_varvars{
Fred Drake00dcfb21998-02-13 07:21:03 +000036 local($_) = @_;
37 s/$any_next_pair_pr_rx/<var>\2<\/var>/;
38 $_;
Fred Drakec384d751996-11-11 16:04:35 +000039}
40
Fred Drake3e1fe891996-11-11 23:03:36 +000041# texinfo-like formatting commands: \code{...} etc.
42
Fred Drakec384d751996-11-11 16:04:35 +000043sub do_cmd_code{
Fred Drake00dcfb21998-02-13 07:21:03 +000044 local($_) = @_;
45 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
46 $_;
Fred Drakec384d751996-11-11 16:04:35 +000047}
48
49sub do_cmd_sectcode{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000050sub do_cmd_module{ &do_cmd_code(@_); }
51sub do_cmd_keyword{ &do_cmd_code(@_); }
52sub do_cmd_exception{ &do_cmd_code(@_); }
53sub do_cmd_class{ &do_cmd_code(@_); }
54sub do_cmd_function{ &do_cmd_code(@_); }
55sub do_cmd_cfunction{ &do_cmd_code(@_); }
56sub do_cmd_constant{ &do_cmd_code(@_); }
57sub do_cmd_method{ &do_cmd_code(@_); }
58sub do_cmd_email{ &do_cmd_code(@_); }
Fred Drake00dcfb21998-02-13 07:21:03 +000059sub do_cmd_program{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000060
Fred Drakece0e1751998-02-18 22:45:53 +000061sub do_cmd_email{
62 local($_) = @_;
63 s/$any_next_pair_pr_rx/<tt><font face=sans-serif>\2<\/font><\/tt>/;
64 $_;
65}
66
Fred Drakebceaf351998-01-22 16:13:44 +000067sub do_cmd_url{
68 # use the URL as both text and hyperlink
69 local($_) = @_;
Fred Drakece0e1751998-02-18 22:45:53 +000070 s/$any_next_pair_pr_rx//;
71 local($url) = $2;
72 "<tt><font face=sans-serif><a href=\"$url\">$url</a></font></tt>" . $_;
Fred Drakebceaf351998-01-22 16:13:44 +000073}
74
75sub do_cmd_manpage{
76 # two parameters: \manpage{name}{section}
77 local($_) = @_;
78 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
79 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<em>\2<\/em>(\4)/;
80 $_;
81}
Fred Drakec384d751996-11-11 16:04:35 +000082
Fred Drake42543631998-02-10 22:11:07 +000083sub do_cmd_rfc{
84 local($_) = @_;
85 s/$next_pair_pr_rx//;
86 local($br_id,$rfcnumber) = ($1, $2);
87
88 # Save the reference
89 local($nstr) = &gen_index_id("RFC!RFC $rfcnumber", '');
90 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
91 "<a name=\"$br_id\">RFC $rfcnumber<\/a>" .$_;
92}
93
Guido van Rossum9e93fb61994-01-25 20:06:09 +000094sub do_cmd_kbd{
Fred Drake00dcfb21998-02-13 07:21:03 +000095 local($_) = @_;
96 s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/;
97 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000098}
99
100sub do_cmd_key{
Fred Drake00dcfb21998-02-13 07:21:03 +0000101 local($_) = @_;
102 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
103 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000104}
105
106sub do_cmd_var{
Fred Drake00dcfb21998-02-13 07:21:03 +0000107 local($_) = @_;
108 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
109 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000110}
111
112sub do_cmd_dfn{
Fred Drake00dcfb21998-02-13 07:21:03 +0000113 local($_) = @_;
114 s/$any_next_pair_pr_rx/<i><dfn>\2<\/dfn><\/i>/;
115 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000116}
117
118sub do_cmd_emph{
Fred Drake00dcfb21998-02-13 07:21:03 +0000119 local($_) = @_;
120 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
121 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000122}
123
124sub do_cmd_strong{
Fred Drake00dcfb21998-02-13 07:21:03 +0000125 local($_) = @_;
126 s/$any_next_pair_pr_rx/<b>\2<\/b>/;
127 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000128}
129
Fred Drake7c4cba81997-12-03 19:45:08 +0000130# file and samp are at the end of this file since they screw up fontlock.
131
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000132# index commands
133
Fred Drake42543631998-02-10 22:11:07 +0000134$INDEX_SUBITEM = "";
135
136sub do_cmd_setindexsubitem{
137 local($_) = @_;
138 s/$any_next_pair_pr_rx//;
139 $INDEX_SUBITEM = $2;
140 $_;
141}
142
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000143sub do_cmd_indexii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000144 local($_) = @_;
145 s/$next_pair_pr_rx//o;
146 local($br_id1, $str1) = ($1, $2);
147 s/$next_pair_pr_rx//o;
148 local($br_id2, $str2) = ($1, $2);
149 join('', &make_index_entry($br_id1, "$str1 $str2"),
150 &make_index_entry($br_id2, "$str2, $str1"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000151}
152
153sub do_cmd_indexiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000154 local($_) = @_;
155 s/$next_pair_pr_rx//o;
156 local($br_id1, $str1) = ($1, $2);
157 s/$next_pair_pr_rx//o;
158 local($br_id2, $str2) = ($1, $2);
159 s/$next_pair_pr_rx//o;
160 local($br_id3, $str3) = ($1, $2);
161 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
162 &make_index_entry($br_id2, "$str2 $str3, $str1"),
163 &make_index_entry($br_id3, "$str3, $str1 $str2"),
164 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000165}
166
167sub do_cmd_indexiv{
Fred Drake00dcfb21998-02-13 07:21:03 +0000168 local($_) = @_;
169 s/$next_pair_pr_rx//o;
170 local($br_id1, $str1) = ($1, $2);
171 s/$next_pair_pr_rx//o;
172 local($br_id2, $str2) = ($1, $2);
173 s/$next_pair_pr_rx//o;
174 local($br_id3, $str3) = ($1, $2);
175 s/$next_pair_pr_rx//o;
176 local($br_id4, $str4) = ($1, $2);
177 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
178 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
179 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
180 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
181 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000182}
183
Fred Drake00dcfb21998-02-13 07:21:03 +0000184sub do_cmd_ttindex{ &do_cmd_index(@_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000185
186sub my_typed_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000187 local($word, $_) = @_;
188 s/$next_pair_pr_rx//o;
189 local($br_id, $str) = ($1, $2);
190 join('', &make_index_entry($br_id, "$str $word"),
191 &make_index_entry($br_id, "$word, $str"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000192}
193
194sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000195sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
196sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
197sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
198
199sub my_parword_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000200 local($word, $_) = @_;
201 s/$next_pair_pr_rx//o;
202 local($br_id, $str) = ($1, $2);
203 &make_index_entry($br_id, "$str ($word)") . $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000204}
205
Fred Drake42543631998-02-10 22:11:07 +0000206
207# Set this to true to strip out the <tt>...</tt> from index entries;
208# this is analogous to using the second definition of \idxcode{} from
209# myformat.sty.
210#
211# It is used from &make_mod_index_entry() and &make_str_index_entry().
212#
213$STRIP_INDEX_TT = 0;
214
Fred Drake25492491998-02-13 15:08:36 +0000215sub make_mod_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000216 local($br_id,$str,$define) = @_;
Fred Drakeab0b65d1998-01-13 04:05:11 +0000217 local($halfref) = &make_half_href("$CURRENT_FILE#$br_id");
218 # If TITLE is not yet available (i.e the \index command is in the title
219 # of the current section), use $ref_before.
Fred Drake84818d71997-12-17 02:59:39 +0000220 $TITLE = $ref_before unless $TITLE;
221 # Save the reference
Fred Drakeab0b65d1998-01-13 04:05:11 +0000222 if ($define eq "DEF") {
223 local($nstr,$garbage) = split / /, $str, 2;
224 $Modules{$nstr} .= $halfref;
225 }
Fred Drake84818d71997-12-17 02:59:39 +0000226 $str = &gen_index_id($str, $define);
Fred Drake42543631998-02-10 22:11:07 +0000227 if ($STRIP_INDEX_TT) {
228 $str =~ s/<tt>(.*)<\/tt>/\1/;
229 }
Fred Drakeab0b65d1998-01-13 04:05:11 +0000230 $index{$str} .= $halfref;
Fred Drake8da9e6a1997-12-18 14:14:16 +0000231 "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
Fred Drake84818d71997-12-17 02:59:39 +0000232}
233
234sub my_module_index_helper{
Fred Drakece0e1751998-02-18 22:45:53 +0000235 local($word, $_) = @_;
236 s/$next_pair_pr_rx[\n]*//o;
237 local($br_id, $str) = ($1, $2);
238 local($section_tag) = join('', @curr_sec_id);
239 &make_mod_index_entry("SECTION$section_tag",
240 "<tt>$str</tt> ($word module)", 'DEF');
241 $_;
242}
243
244sub ref_module_index_helper{
245 local($word, $_) = @_;
Fred Drake00dcfb21998-02-13 07:21:03 +0000246 s/$next_pair_pr_rx//o;
247 local($br_id, $str) = ($1, $2);
Fred Drakece0e1751998-02-18 22:45:53 +0000248 &make_mod_index_entry($br_id, "<tt>$str</tt> ($word module)", 'REF') . $_;
Fred Drake84818d71997-12-17 02:59:39 +0000249}
250
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000251sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
Fred Drakece0e1751998-02-18 22:45:53 +0000252sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_); }
253sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000254
Fred Drakece0e1751998-02-18 22:45:53 +0000255# these should be adjusted a bit....
256sub do_cmd_refbimodindex{ &ref_module_index_helper('built-in', @_); }
257sub do_cmd_refstmodindex{ &ref_module_index_helper('standard', @_); }
Fred Drake72df9bc1997-12-16 21:13:20 +0000258
Fred Drakec384d751996-11-11 16:04:35 +0000259sub do_cmd_nodename{ &do_cmd_label(@_); }
260
Fred Drake1af9e791998-01-12 23:15:29 +0000261sub init_myformat{
262 # XXX need some way for this to be called after &initialise;
Fred Drakece0e1751998-02-18 22:45:53 +0000263 $anchor_mark = '';
264 $icons{'anchor_mark'} = '';
Fred Drake1af9e791998-01-12 23:15:29 +0000265 # <<2>>...<<2>>
266 $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
267 $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
268 $any_next_pair_rx7 = "$O(\\d+)$C([\\s\\S]*)$O\\7$C";
269 $any_next_pair_rx9 = "$O(\\d+)$C([\\s\\S]*)$O\\9$C";
270 # <#2#>...<#2#>
271 $any_next_pair_pr_rx_3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
272 $any_next_pair_pr_rx_5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
273 $any_next_pair_pr_rx_7 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP";
274 $any_next_pair_pr_rx_9 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000275}
276
277&init_myformat;
Fred Drakec384d751996-11-11 16:04:35 +0000278
279sub get_indexsubitem{
Fred Drake00dcfb21998-02-13 07:21:03 +0000280 local($result) = $INDEX_SUBITEM;
Fred Drakec384d751996-11-11 16:04:35 +0000281 #print "\nget_indexsubitem ==> $result\n";
Fred Drake9597daf1997-12-22 22:37:34 +0000282 $result ? " $result" : '';
Fred Drakec384d751996-11-11 16:04:35 +0000283}
284
Fred Drake84818d71997-12-17 02:59:39 +0000285# similar to make_index_entry(), but includes the string in the result
286# instead of the dummy filler.
287#
Fred Drake25492491998-02-13 15:08:36 +0000288sub make_str_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000289 local($br_id,$str) = @_;
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 local($nstr) = &gen_index_id($str, '');
Fred Drake42543631998-02-10 22:11:07 +0000295 if ($STRIP_INDEX_TT) {
296 $nstr =~ s/<tt>(.*)<\/tt>/\1/;
297 }
Fred Drake84818d71997-12-17 02:59:39 +0000298 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
299 "<a name=\"$br_id\">$str<\/a>";
300}
301
Fred Drake06e16641998-02-16 22:50:06 +0000302# Changed from the stock version to indent {verbatim} sections:
303sub replace_verbatim {
304 # Modifies $_
305 s/$verbatim_mark(verbatim)(\d+)/<dl><dd><pre>$verbatim{$2}<\/pre><\/dl>/go;
306 s/$verbatim_mark(rawhtml)(\d+)/$verbatim{$2}/ego; # Raw HTML
307}
308
Fred Drake7a7480d1996-10-29 15:56:57 +0000309sub do_env_cfuncdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000310 local($_) = @_;
311 local($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
312 local($cfuncdesc_rx) =
313 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
314 if (/$cfuncdesc_rx/o) {
315 $return_type = "$2";
316 $function_name = "$4";
317 $arg_list = "$6";
318 $idx = &make_str_index_entry($3,
319 "<tt>$function_name</tt>" . &get_indexsubitem);
320 $idx =~ s/ \(.*\)//;
321 }
322 "<dl><dt>$return_type <b>$idx</b>"
323 . "(<var>$arg_list</var>)\n<dd>$'\n</dl>"
Fred Drake7a7480d1996-10-29 15:56:57 +0000324}
325
Fred Drake9dcc5a91997-10-13 22:04:17 +0000326sub do_env_ctypedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000327 local($_) = @_;
328 local($type_name) = ('');
329 local($cfuncdesc_rx) = "$next_pair_rx";
330 if (/$cfuncdesc_rx/o) {
331 $type_name = "$2";
332 $idx = &make_str_index_entry($1,
333 "<tt>$type_name</tt>" . &get_indexsubitem);
334 $idx =~ s/ \(.*\)//;
335 }
336 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake9dcc5a91997-10-13 22:04:17 +0000337}
338
339sub do_env_cvardesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000340 local($_) = @_;
341 local($var_type,$var_name,$idx) = ('', '', '');
342 local($cfuncdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
343 if (/$cfuncdesc_rx/o) {
344 $var_type = "$2";
345 $var_name = "$4";
346 $idx = &make_str_index_entry($3,
347 "<tt>$var_name</tt>" . &get_indexsubitem);
348 $idx =~ s/ \(.*\)//;
349 }
350 "<dl><dt>$var_type <b>$idx</b>\n"
351 . "<dd>$'\n</dl>";
Fred Drake9dcc5a91997-10-13 22:04:17 +0000352}
353
Fred Drakec384d751996-11-11 16:04:35 +0000354sub do_env_funcdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000355 local($_) = @_;
356 local($function_name,$arg_list,$idx) = ('', '', '');
357 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
358 if (/$funcdesc_rx/o) {
359 $function_name = "$2";
360 $arg_list = "$4";
361 $idx = &make_str_index_entry($3,
362 "<tt>$function_name</tt>" . &get_indexsubitem);
363 $idx =~ s/ \(.*\)//;
364 }
365 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
Fred Drake1af9e791998-01-12 23:15:29 +0000366}
367
Fred Drake25492491998-02-13 15:08:36 +0000368sub do_env_funcdescni{
369 local($_) = @_;
370 local($function_name,$arg_list,$idx) = ('', '', '');
371 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
372 if (/$funcdesc_rx/o) {
373 $function_name = "$2";
374 $arg_list = "$4";
375 if ($STRIP_INDEX_TT) {
376 $idx = $function_name; }
377 else {
378 $idx = "<tt>$function_name</tt>"; }
379 }
380 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
381}
382
Fred Drake1af9e791998-01-12 23:15:29 +0000383sub do_cmd_funcline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000384 local($_) = @_;
385 local($funcdesc_rx) = "$next_pair_pr_rx$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000386
Fred Drake00dcfb21998-02-13 07:21:03 +0000387 s/$funcdesc_rx//o;
388 local($br_id, $function_name, $arg_list) = ($3, $2, $4);
389 local($idx) = &make_str_index_entry($br_id, "<tt>$function_name</tt>");
Fred Drake1af9e791998-01-12 23:15:29 +0000390
Fred Drake00dcfb21998-02-13 07:21:03 +0000391 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000392}
393
Fred Drake00dcfb21998-02-13 07:21:03 +0000394# Change this flag to index the opcode entries. I don't think it's very
395# useful to index them, since they're only presented to describe the dis
396# module.
397#
398$INDEX_OPCODES = 0;
399
Fred Drake7c4cba81997-12-03 19:45:08 +0000400sub do_env_opcodedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000401 local($_) = @_;
402 local($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
403 local($opcodedesc_rx) = "$next_pair_rx$any_next_pair_rx3";
404 if (/$opcodedesc_rx/o) {
405 $opcode_name = "$2";
406 $arg_list = "$4";
407 if ($INDEX_OPCODES) {
408 $idx = &make_str_index_entry($3,
409 "<tt>$opcode_name</tt> (byte code instruction)");
410 $idx =~ s/ \(byte code instruction\)//;
411 }
412 else {
413 $idx = "<tt>$opcode_name</tt>";
414 }
415 }
416 $stuff = "<dl><dt><b>$idx</b>";
417 if ($arg_list) {
418 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
419 }
420 $stuff . "\n<dd>$'\n</dl>";
Fred Drakec384d751996-11-11 16:04:35 +0000421}
422
423sub do_env_datadesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000424 local($_) = @_;
425 local($idx) = '';
426 if (/$next_pair_rx/o) {
427 $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
428 $idx =~ s/ \(.*\)//;
429 }
430 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake1af9e791998-01-12 23:15:29 +0000431}
432
Fred Drake25492491998-02-13 15:08:36 +0000433sub do_env_datadescni{
434 local($_) = @_;
435 local($idx) = '';
436 if (/$next_pair_rx/o) {
437 if ($STRING_INDEX_TT) {
438 $idx = "$2"; }
439 else {
440 $idx = "<tt>$2</tt>"; }
441 }
442 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
443}
444
Fred Drake1af9e791998-01-12 23:15:29 +0000445sub do_cmd_dataline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000446 local($_) = @_;
Fred Drake1af9e791998-01-12 23:15:29 +0000447
Fred Drake00dcfb21998-02-13 07:21:03 +0000448 s/$next_pair_pr_rx//o;
449 local($br_id, $data_name) = ($1, $2);
450 local($idx) = &make_str_index_entry($br_id, "<tt>$data_name</tt>"
451 . &get_indexsubitem);
452 $idx =~ s/ \(.*\)//;
Fred Drake1af9e791998-01-12 23:15:29 +0000453
Fred Drake00dcfb21998-02-13 07:21:03 +0000454 "<dt><b>$idx</b>\n<dd>" . $_;
Fred Drakec384d751996-11-11 16:04:35 +0000455}
456
457sub do_env_excdesc{ &do_env_datadesc(@_); }
Fred Drake00dcfb21998-02-13 07:21:03 +0000458sub do_env_codesample{ &do_env_verbatim(@_); }
459
Fred Drakec384d751996-11-11 16:04:35 +0000460
Fred Drake9597daf1997-12-22 22:37:34 +0000461@col_aligns = ("<td>", "<td>", "<td>");
462
463sub setup_column_alignments{
Fred Drake00dcfb21998-02-13 07:21:03 +0000464 local($_) = @_;
465 local($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_);
466 local($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
467 $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>");
468 $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>");
469 $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>");
470 # return the aligned header start tags; only used for \begin{tableiii?}
471 $th1 = (($a1 eq "l") ? "<th align=left>"
472 : ($a1 eq "r" ? "<th align=right>" : "<th>"));
473 $th2 = (($a2 eq "l") ? "<th align=left>"
474 : ($a2 eq "r" ? "<th align=right>" : "<th>"));
475 $th3 = (($a3 eq "l") ? "<th align=left>"
476 : ($a3 eq "r" ? "<th align=right>" : "<th>"));
477 ($th1, $th2, $th3);
Fred Drake9597daf1997-12-22 22:37:34 +0000478}
479
480sub do_env_tableii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000481 local($_) = @_;
482 local($font,$h1,$h2) = ('', '', '');
483 local($tableiii_rx) =
484 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7";
485 if (/$tableiii_rx/o) {
486 $font = $4;
487 $h1 = $6;
488 $h2 = $8;
489 }
490 local($th1,$th2,$th3) = &setup_column_alignments($2);
491 $globals{"lineifont"} = $font;
492 "<table border align=center>\n <tr>$th1$h1</th>\n $th2$h2</th>$'\n"
493 . "</table>";
Fred Drake9597daf1997-12-22 22:37:34 +0000494}
495
496sub do_cmd_lineii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000497 local($_) = @_;
498 s/$next_pair_pr_rx//o;
499 local($c1) = $2;
500 s/$next_pair_pr_rx//o;
501 local($c2) = $2;
502 local($font) = $globals{"lineifont"};
503 local($c1align, $c2align) = @col_aligns[0,1];
504 "<tr>$c1align<$font>$c1</$font></td>\n"
505 . " $c2align$c2</td>$'";
Fred Drake9597daf1997-12-22 22:37:34 +0000506}
507
508sub do_env_tableiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000509 local($_) = @_;
510 local($font,$h1,$h2,$h3) = ('', '', '', '');
Fred Drake1af9e791998-01-12 23:15:29 +0000511
Fred Drake00dcfb21998-02-13 07:21:03 +0000512 local($tableiii_rx) =
513 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"
514 . "$any_next_pair_rx9";
515 if (/$tableiii_rx/o) {
516 $font = $4;
517 $h1 = $6;
518 $h2 = $8;
519 $h3 = $10;
520 }
521 local($th1,$th2,$th3) = &setup_column_alignments($2);
522 $globals{"lineifont"} = $font;
523 "<table border align=center>\n <tr>$th1$h1</th>\n $th2$h2</th>"
524 . "\n $th3$h3</th>$'\n"
525 . "</table>";
Fred Drake9597daf1997-12-22 22:37:34 +0000526}
527
528sub do_cmd_lineiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000529 local($_) = @_;
530 s/$next_pair_pr_rx//o;
531 local($c1) = $2;
532 s/$next_pair_pr_rx//o;
533 local($c2) = $2;
534 s/$next_pair_pr_rx//o;
535 local($c3) = $2;
536 local($font) = $globals{"lineifont"};
537 local($c1align, $c2align, $c3align) = @col_aligns;
538 "<tr>$c1align<$font>$c1</$font></td>\n"
539 . " $c2align$c2</td>\n"
540 . " $c3align$c3</td>$'";
Fred Drake9597daf1997-12-22 22:37:34 +0000541}
542
Fred Drake9dcc5a91997-10-13 22:04:17 +0000543sub do_env_seealso{
Fred Drake00dcfb21998-02-13 07:21:03 +0000544 "<p><b>See Also:</b></p>\n" . @_[0];
Fred Drake9dcc5a91997-10-13 22:04:17 +0000545}
546
547sub do_cmd_seemodule{
Fred Drakece0e1751998-02-18 22:45:53 +0000548 # Insert the right magic to jump to the module definition. This should
549 # work most of the time, at least for repeat builds....
Fred Drake00dcfb21998-02-13 07:21:03 +0000550 local($_) = @_;
551 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drakece0e1751998-02-18 22:45:53 +0000552 s/$next_pair_pr_rx$any_next_pair_pr_rx3//;
553 local($module,$text,$node,$key) = ($2, $4, '', "module$2");
554 $key =~ s/_//g;
555# $node = $external_labels{$key} unless
556# ($node = $ref_files{$key});
557 $node = $key;
558 print "seemodule $module: $node#$key\n";
559 "<p>Module <tt><b><a href=\"$node#$key\">$module</a></b></tt>"
560 . "&nbsp;&nbsp;&nbsp;($text)</p>"
561 . $_;
Fred Drake9dcc5a91997-10-13 22:04:17 +0000562}
563
564sub do_cmd_seetext{
Fred Drake00dcfb21998-02-13 07:21:03 +0000565 "<p>" . @_[0];
Fred Drake9dcc5a91997-10-13 22:04:17 +0000566}
567
Fred Drake7c4cba81997-12-03 19:45:08 +0000568# These are located down here since they screw up fontlock.
569
570sub do_cmd_file{
Fred Drake00dcfb21998-02-13 07:21:03 +0000571 # This uses a weird HTML construct to adjust the font to be
572 # reasonable match that used in the printed form as much as
573 # possible. The expected behavior is that a browser that doesn't
574 # understand "<font face=...>" markup will use courier (or whatever
575 # the font is for <tt>).
576 local($_) = @_;
577 s/$any_next_pair_pr_rx/`<tt><font face=sans-serif>\2<\/font><\/tt>'/;
578 $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000579}
580
581sub do_cmd_samp{
Fred Drake00dcfb21998-02-13 07:21:03 +0000582 local($_) = @_;
583 s/$any_next_pair_pr_rx/`<samp>\2<\/samp>'/;
584 $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000585}
586
Guido van Rossum9e93fb61994-01-25 20:06:09 +00005871; # This must be the last line