blob: e3783a9c9350610d0a3eb39a9ed8255afcb4dc87 [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(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000055sub do_cmd_constant{ &do_cmd_code(@_); }
Fred Drake05ce5701998-02-19 17:26:48 +000056sub do_cmd_member{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000057sub 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 Drake05ce5701998-02-19 17:26:48 +000060sub do_cmd_cfunction{ &do_cmd_code(@_); }
61sub do_cmd_cdata{ &do_cmd_code(@_); }
62sub do_cmd_ctype{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000063
Fred Drakece0e1751998-02-18 22:45:53 +000064sub do_cmd_email{
65 local($_) = @_;
66 s/$any_next_pair_pr_rx/<tt><font face=sans-serif>\2<\/font><\/tt>/;
67 $_;
68}
69
Fred Drakebceaf351998-01-22 16:13:44 +000070sub do_cmd_url{
71 # use the URL as both text and hyperlink
72 local($_) = @_;
Fred Drakece0e1751998-02-18 22:45:53 +000073 s/$any_next_pair_pr_rx//;
74 local($url) = $2;
75 "<tt><font face=sans-serif><a href=\"$url\">$url</a></font></tt>" . $_;
Fred Drakebceaf351998-01-22 16:13:44 +000076}
77
78sub do_cmd_manpage{
79 # two parameters: \manpage{name}{section}
80 local($_) = @_;
81 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
82 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<em>\2<\/em>(\4)/;
83 $_;
84}
Fred Drakec384d751996-11-11 16:04:35 +000085
Fred Drake42543631998-02-10 22:11:07 +000086sub do_cmd_rfc{
87 local($_) = @_;
88 s/$next_pair_pr_rx//;
89 local($br_id,$rfcnumber) = ($1, $2);
90
91 # Save the reference
92 local($nstr) = &gen_index_id("RFC!RFC $rfcnumber", '');
93 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
94 "<a name=\"$br_id\">RFC $rfcnumber<\/a>" .$_;
95}
96
Guido van Rossum9e93fb61994-01-25 20:06:09 +000097sub do_cmd_kbd{
Fred Drake00dcfb21998-02-13 07:21:03 +000098 local($_) = @_;
99 s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/;
100 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000101}
102
103sub do_cmd_key{
Fred Drake00dcfb21998-02-13 07:21:03 +0000104 local($_) = @_;
105 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
106 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000107}
108
109sub do_cmd_var{
Fred Drake00dcfb21998-02-13 07:21:03 +0000110 local($_) = @_;
111 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
112 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000113}
114
115sub do_cmd_dfn{
Fred Drake00dcfb21998-02-13 07:21:03 +0000116 local($_) = @_;
117 s/$any_next_pair_pr_rx/<i><dfn>\2<\/dfn><\/i>/;
118 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000119}
120
121sub do_cmd_emph{
Fred Drake00dcfb21998-02-13 07:21:03 +0000122 local($_) = @_;
123 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
124 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000125}
126
127sub do_cmd_strong{
Fred Drake00dcfb21998-02-13 07:21:03 +0000128 local($_) = @_;
129 s/$any_next_pair_pr_rx/<b>\2<\/b>/;
130 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000131}
132
Fred Drake7c4cba81997-12-03 19:45:08 +0000133# file and samp are at the end of this file since they screw up fontlock.
134
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000135# index commands
136
Fred Drake42543631998-02-10 22:11:07 +0000137$INDEX_SUBITEM = "";
138
139sub do_cmd_setindexsubitem{
140 local($_) = @_;
141 s/$any_next_pair_pr_rx//;
142 $INDEX_SUBITEM = $2;
143 $_;
144}
145
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000146sub do_cmd_indexii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000147 local($_) = @_;
148 s/$next_pair_pr_rx//o;
149 local($br_id1, $str1) = ($1, $2);
150 s/$next_pair_pr_rx//o;
151 local($br_id2, $str2) = ($1, $2);
152 join('', &make_index_entry($br_id1, "$str1 $str2"),
153 &make_index_entry($br_id2, "$str2, $str1"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000154}
155
156sub do_cmd_indexiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000157 local($_) = @_;
158 s/$next_pair_pr_rx//o;
159 local($br_id1, $str1) = ($1, $2);
160 s/$next_pair_pr_rx//o;
161 local($br_id2, $str2) = ($1, $2);
162 s/$next_pair_pr_rx//o;
163 local($br_id3, $str3) = ($1, $2);
164 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
165 &make_index_entry($br_id2, "$str2 $str3, $str1"),
166 &make_index_entry($br_id3, "$str3, $str1 $str2"),
167 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000168}
169
170sub do_cmd_indexiv{
Fred Drake00dcfb21998-02-13 07:21:03 +0000171 local($_) = @_;
172 s/$next_pair_pr_rx//o;
173 local($br_id1, $str1) = ($1, $2);
174 s/$next_pair_pr_rx//o;
175 local($br_id2, $str2) = ($1, $2);
176 s/$next_pair_pr_rx//o;
177 local($br_id3, $str3) = ($1, $2);
178 s/$next_pair_pr_rx//o;
179 local($br_id4, $str4) = ($1, $2);
180 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
181 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
182 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
183 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
184 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000185}
186
Fred Drake00dcfb21998-02-13 07:21:03 +0000187sub do_cmd_ttindex{ &do_cmd_index(@_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000188
189sub my_typed_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000190 local($word, $_) = @_;
191 s/$next_pair_pr_rx//o;
192 local($br_id, $str) = ($1, $2);
193 join('', &make_index_entry($br_id, "$str $word"),
194 &make_index_entry($br_id, "$word, $str"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000195}
196
197sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000198sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
199sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
200sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
201
202sub my_parword_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000203 local($word, $_) = @_;
204 s/$next_pair_pr_rx//o;
205 local($br_id, $str) = ($1, $2);
206 &make_index_entry($br_id, "$str ($word)") . $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000207}
208
Fred Drake42543631998-02-10 22:11:07 +0000209
210# Set this to true to strip out the <tt>...</tt> from index entries;
211# this is analogous to using the second definition of \idxcode{} from
212# myformat.sty.
213#
214# It is used from &make_mod_index_entry() and &make_str_index_entry().
215#
216$STRIP_INDEX_TT = 0;
217
Fred Drake25492491998-02-13 15:08:36 +0000218sub make_mod_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000219 local($br_id,$str,$define) = @_;
Fred Drakeab0b65d1998-01-13 04:05:11 +0000220 local($halfref) = &make_half_href("$CURRENT_FILE#$br_id");
221 # If TITLE is not yet available (i.e the \index command is in the title
222 # of the current section), use $ref_before.
Fred Drake84818d71997-12-17 02:59:39 +0000223 $TITLE = $ref_before unless $TITLE;
224 # Save the reference
Fred Drakeab0b65d1998-01-13 04:05:11 +0000225 if ($define eq "DEF") {
226 local($nstr,$garbage) = split / /, $str, 2;
227 $Modules{$nstr} .= $halfref;
228 }
Fred Drake84818d71997-12-17 02:59:39 +0000229 $str = &gen_index_id($str, $define);
Fred Drake42543631998-02-10 22:11:07 +0000230 if ($STRIP_INDEX_TT) {
231 $str =~ s/<tt>(.*)<\/tt>/\1/;
232 }
Fred Drakeab0b65d1998-01-13 04:05:11 +0000233 $index{$str} .= $halfref;
Fred Drake8da9e6a1997-12-18 14:14:16 +0000234 "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
Fred Drake84818d71997-12-17 02:59:39 +0000235}
236
237sub my_module_index_helper{
Fred Drakece0e1751998-02-18 22:45:53 +0000238 local($word, $_) = @_;
239 s/$next_pair_pr_rx[\n]*//o;
240 local($br_id, $str) = ($1, $2);
241 local($section_tag) = join('', @curr_sec_id);
242 &make_mod_index_entry("SECTION$section_tag",
243 "<tt>$str</tt> ($word module)", 'DEF');
244 $_;
245}
246
247sub ref_module_index_helper{
248 local($word, $_) = @_;
Fred Drake00dcfb21998-02-13 07:21:03 +0000249 s/$next_pair_pr_rx//o;
250 local($br_id, $str) = ($1, $2);
Fred Drakece0e1751998-02-18 22:45:53 +0000251 &make_mod_index_entry($br_id, "<tt>$str</tt> ($word module)", 'REF') . $_;
Fred Drake84818d71997-12-17 02:59:39 +0000252}
253
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000254sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
Fred Drakece0e1751998-02-18 22:45:53 +0000255sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_); }
256sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000257
Fred Drakece0e1751998-02-18 22:45:53 +0000258# these should be adjusted a bit....
259sub do_cmd_refbimodindex{ &ref_module_index_helper('built-in', @_); }
260sub do_cmd_refstmodindex{ &ref_module_index_helper('standard', @_); }
Fred Drake72df9bc1997-12-16 21:13:20 +0000261
Fred Drakec384d751996-11-11 16:04:35 +0000262sub do_cmd_nodename{ &do_cmd_label(@_); }
263
Fred Drake1af9e791998-01-12 23:15:29 +0000264sub init_myformat{
265 # XXX need some way for this to be called after &initialise;
Fred Drakece0e1751998-02-18 22:45:53 +0000266 $anchor_mark = '';
267 $icons{'anchor_mark'} = '';
Fred Drake1af9e791998-01-12 23:15:29 +0000268 # <<2>>...<<2>>
269 $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
270 $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
271 $any_next_pair_rx7 = "$O(\\d+)$C([\\s\\S]*)$O\\7$C";
272 $any_next_pair_rx9 = "$O(\\d+)$C([\\s\\S]*)$O\\9$C";
273 # <#2#>...<#2#>
274 $any_next_pair_pr_rx_3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
275 $any_next_pair_pr_rx_5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
276 $any_next_pair_pr_rx_7 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP";
277 $any_next_pair_pr_rx_9 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000278}
279
280&init_myformat;
Fred Drakec384d751996-11-11 16:04:35 +0000281
282sub get_indexsubitem{
Fred Drake00dcfb21998-02-13 07:21:03 +0000283 local($result) = $INDEX_SUBITEM;
Fred Drakec384d751996-11-11 16:04:35 +0000284 #print "\nget_indexsubitem ==> $result\n";
Fred Drake9597daf1997-12-22 22:37:34 +0000285 $result ? " $result" : '';
Fred Drakec384d751996-11-11 16:04:35 +0000286}
287
Fred Drake84818d71997-12-17 02:59:39 +0000288# similar to make_index_entry(), but includes the string in the result
289# instead of the dummy filler.
290#
Fred Drake25492491998-02-13 15:08:36 +0000291sub make_str_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000292 local($br_id,$str) = @_;
293 # If TITLE is not yet available (i.e the \index command is in the title
294 # of the current section), use $ref_before.
295 $TITLE = $ref_before unless $TITLE;
296 # Save the reference
297 local($nstr) = &gen_index_id($str, '');
Fred Drake42543631998-02-10 22:11:07 +0000298 if ($STRIP_INDEX_TT) {
299 $nstr =~ s/<tt>(.*)<\/tt>/\1/;
300 }
Fred Drake84818d71997-12-17 02:59:39 +0000301 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
302 "<a name=\"$br_id\">$str<\/a>";
303}
304
Fred Drake06e16641998-02-16 22:50:06 +0000305# Changed from the stock version to indent {verbatim} sections:
306sub replace_verbatim {
307 # Modifies $_
308 s/$verbatim_mark(verbatim)(\d+)/<dl><dd><pre>$verbatim{$2}<\/pre><\/dl>/go;
309 s/$verbatim_mark(rawhtml)(\d+)/$verbatim{$2}/ego; # Raw HTML
310}
311
Fred Drake7a7480d1996-10-29 15:56:57 +0000312sub do_env_cfuncdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000313 local($_) = @_;
314 local($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
315 local($cfuncdesc_rx) =
316 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
317 if (/$cfuncdesc_rx/o) {
318 $return_type = "$2";
319 $function_name = "$4";
320 $arg_list = "$6";
321 $idx = &make_str_index_entry($3,
322 "<tt>$function_name</tt>" . &get_indexsubitem);
323 $idx =~ s/ \(.*\)//;
324 }
325 "<dl><dt>$return_type <b>$idx</b>"
326 . "(<var>$arg_list</var>)\n<dd>$'\n</dl>"
Fred Drake7a7480d1996-10-29 15:56:57 +0000327}
328
Fred Drake9dcc5a91997-10-13 22:04:17 +0000329sub do_env_ctypedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000330 local($_) = @_;
331 local($type_name) = ('');
332 local($cfuncdesc_rx) = "$next_pair_rx";
333 if (/$cfuncdesc_rx/o) {
334 $type_name = "$2";
335 $idx = &make_str_index_entry($1,
336 "<tt>$type_name</tt>" . &get_indexsubitem);
337 $idx =~ s/ \(.*\)//;
338 }
339 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake9dcc5a91997-10-13 22:04:17 +0000340}
341
342sub do_env_cvardesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000343 local($_) = @_;
344 local($var_type,$var_name,$idx) = ('', '', '');
345 local($cfuncdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
346 if (/$cfuncdesc_rx/o) {
347 $var_type = "$2";
348 $var_name = "$4";
349 $idx = &make_str_index_entry($3,
350 "<tt>$var_name</tt>" . &get_indexsubitem);
351 $idx =~ s/ \(.*\)//;
352 }
353 "<dl><dt>$var_type <b>$idx</b>\n"
354 . "<dd>$'\n</dl>";
Fred Drake9dcc5a91997-10-13 22:04:17 +0000355}
356
Fred Drakec384d751996-11-11 16:04:35 +0000357sub do_env_funcdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000358 local($_) = @_;
359 local($function_name,$arg_list,$idx) = ('', '', '');
360 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
361 if (/$funcdesc_rx/o) {
362 $function_name = "$2";
363 $arg_list = "$4";
364 $idx = &make_str_index_entry($3,
365 "<tt>$function_name</tt>" . &get_indexsubitem);
366 $idx =~ s/ \(.*\)//;
367 }
368 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
Fred Drake1af9e791998-01-12 23:15:29 +0000369}
370
Fred Drake25492491998-02-13 15:08:36 +0000371sub do_env_funcdescni{
372 local($_) = @_;
373 local($function_name,$arg_list,$idx) = ('', '', '');
374 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
375 if (/$funcdesc_rx/o) {
376 $function_name = "$2";
377 $arg_list = "$4";
378 if ($STRIP_INDEX_TT) {
379 $idx = $function_name; }
380 else {
381 $idx = "<tt>$function_name</tt>"; }
382 }
383 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
384}
385
Fred Drake1af9e791998-01-12 23:15:29 +0000386sub do_cmd_funcline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000387 local($_) = @_;
388 local($funcdesc_rx) = "$next_pair_pr_rx$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000389
Fred Drake00dcfb21998-02-13 07:21:03 +0000390 s/$funcdesc_rx//o;
391 local($br_id, $function_name, $arg_list) = ($3, $2, $4);
392 local($idx) = &make_str_index_entry($br_id, "<tt>$function_name</tt>");
Fred Drake1af9e791998-01-12 23:15:29 +0000393
Fred Drake00dcfb21998-02-13 07:21:03 +0000394 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000395}
396
Fred Drake00dcfb21998-02-13 07:21:03 +0000397# Change this flag to index the opcode entries. I don't think it's very
398# useful to index them, since they're only presented to describe the dis
399# module.
400#
401$INDEX_OPCODES = 0;
402
Fred Drake7c4cba81997-12-03 19:45:08 +0000403sub do_env_opcodedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000404 local($_) = @_;
405 local($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
406 local($opcodedesc_rx) = "$next_pair_rx$any_next_pair_rx3";
407 if (/$opcodedesc_rx/o) {
408 $opcode_name = "$2";
409 $arg_list = "$4";
410 if ($INDEX_OPCODES) {
411 $idx = &make_str_index_entry($3,
412 "<tt>$opcode_name</tt> (byte code instruction)");
413 $idx =~ s/ \(byte code instruction\)//;
414 }
415 else {
416 $idx = "<tt>$opcode_name</tt>";
417 }
418 }
419 $stuff = "<dl><dt><b>$idx</b>";
420 if ($arg_list) {
421 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
422 }
423 $stuff . "\n<dd>$'\n</dl>";
Fred Drakec384d751996-11-11 16:04:35 +0000424}
425
426sub do_env_datadesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000427 local($_) = @_;
428 local($idx) = '';
429 if (/$next_pair_rx/o) {
430 $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
431 $idx =~ s/ \(.*\)//;
432 }
433 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake1af9e791998-01-12 23:15:29 +0000434}
435
Fred Drake25492491998-02-13 15:08:36 +0000436sub do_env_datadescni{
437 local($_) = @_;
438 local($idx) = '';
439 if (/$next_pair_rx/o) {
440 if ($STRING_INDEX_TT) {
441 $idx = "$2"; }
442 else {
443 $idx = "<tt>$2</tt>"; }
444 }
445 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
446}
447
Fred Drake1af9e791998-01-12 23:15:29 +0000448sub do_cmd_dataline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000449 local($_) = @_;
Fred Drake1af9e791998-01-12 23:15:29 +0000450
Fred Drake00dcfb21998-02-13 07:21:03 +0000451 s/$next_pair_pr_rx//o;
452 local($br_id, $data_name) = ($1, $2);
453 local($idx) = &make_str_index_entry($br_id, "<tt>$data_name</tt>"
454 . &get_indexsubitem);
455 $idx =~ s/ \(.*\)//;
Fred Drake1af9e791998-01-12 23:15:29 +0000456
Fred Drake00dcfb21998-02-13 07:21:03 +0000457 "<dt><b>$idx</b>\n<dd>" . $_;
Fred Drakec384d751996-11-11 16:04:35 +0000458}
459
460sub do_env_excdesc{ &do_env_datadesc(@_); }
Fred Drake05ce5701998-02-19 17:26:48 +0000461sub do_env_classdesc{ &do_env_funcdesc(@_); }
462sub do_env_fulllineitems{ &do_env_itemize(@_); }
Fred Drake00dcfb21998-02-13 07:21:03 +0000463
Fred Drakec384d751996-11-11 16:04:35 +0000464
Fred Drake9597daf1997-12-22 22:37:34 +0000465@col_aligns = ("<td>", "<td>", "<td>");
466
467sub setup_column_alignments{
Fred Drake00dcfb21998-02-13 07:21:03 +0000468 local($_) = @_;
469 local($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_);
470 local($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
471 $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>");
472 $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>");
473 $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>");
474 # return the aligned header start tags; only used for \begin{tableiii?}
475 $th1 = (($a1 eq "l") ? "<th align=left>"
476 : ($a1 eq "r" ? "<th align=right>" : "<th>"));
477 $th2 = (($a2 eq "l") ? "<th align=left>"
478 : ($a2 eq "r" ? "<th align=right>" : "<th>"));
479 $th3 = (($a3 eq "l") ? "<th align=left>"
480 : ($a3 eq "r" ? "<th align=right>" : "<th>"));
481 ($th1, $th2, $th3);
Fred Drake9597daf1997-12-22 22:37:34 +0000482}
483
484sub do_env_tableii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000485 local($_) = @_;
486 local($font,$h1,$h2) = ('', '', '');
487 local($tableiii_rx) =
488 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7";
489 if (/$tableiii_rx/o) {
490 $font = $4;
491 $h1 = $6;
492 $h2 = $8;
493 }
494 local($th1,$th2,$th3) = &setup_column_alignments($2);
495 $globals{"lineifont"} = $font;
496 "<table border align=center>\n <tr>$th1$h1</th>\n $th2$h2</th>$'\n"
497 . "</table>";
Fred Drake9597daf1997-12-22 22:37:34 +0000498}
499
500sub do_cmd_lineii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000501 local($_) = @_;
502 s/$next_pair_pr_rx//o;
503 local($c1) = $2;
504 s/$next_pair_pr_rx//o;
505 local($c2) = $2;
506 local($font) = $globals{"lineifont"};
507 local($c1align, $c2align) = @col_aligns[0,1];
508 "<tr>$c1align<$font>$c1</$font></td>\n"
509 . " $c2align$c2</td>$'";
Fred Drake9597daf1997-12-22 22:37:34 +0000510}
511
512sub do_env_tableiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000513 local($_) = @_;
514 local($font,$h1,$h2,$h3) = ('', '', '', '');
Fred Drake1af9e791998-01-12 23:15:29 +0000515
Fred Drake00dcfb21998-02-13 07:21:03 +0000516 local($tableiii_rx) =
517 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"
518 . "$any_next_pair_rx9";
519 if (/$tableiii_rx/o) {
520 $font = $4;
521 $h1 = $6;
522 $h2 = $8;
523 $h3 = $10;
524 }
525 local($th1,$th2,$th3) = &setup_column_alignments($2);
526 $globals{"lineifont"} = $font;
527 "<table border align=center>\n <tr>$th1$h1</th>\n $th2$h2</th>"
528 . "\n $th3$h3</th>$'\n"
529 . "</table>";
Fred Drake9597daf1997-12-22 22:37:34 +0000530}
531
532sub do_cmd_lineiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000533 local($_) = @_;
534 s/$next_pair_pr_rx//o;
535 local($c1) = $2;
536 s/$next_pair_pr_rx//o;
537 local($c2) = $2;
538 s/$next_pair_pr_rx//o;
539 local($c3) = $2;
540 local($font) = $globals{"lineifont"};
541 local($c1align, $c2align, $c3align) = @col_aligns;
542 "<tr>$c1align<$font>$c1</$font></td>\n"
543 . " $c2align$c2</td>\n"
544 . " $c3align$c3</td>$'";
Fred Drake9597daf1997-12-22 22:37:34 +0000545}
546
Fred Drake9dcc5a91997-10-13 22:04:17 +0000547sub do_env_seealso{
Fred Drake00dcfb21998-02-13 07:21:03 +0000548 "<p><b>See Also:</b></p>\n" . @_[0];
Fred Drake9dcc5a91997-10-13 22:04:17 +0000549}
550
551sub do_cmd_seemodule{
Fred Drakece0e1751998-02-18 22:45:53 +0000552 # Insert the right magic to jump to the module definition. This should
553 # work most of the time, at least for repeat builds....
Fred Drake00dcfb21998-02-13 07:21:03 +0000554 local($_) = @_;
555 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drakece0e1751998-02-18 22:45:53 +0000556 s/$next_pair_pr_rx$any_next_pair_pr_rx3//;
557 local($module,$text,$node,$key) = ($2, $4, '', "module$2");
558 $key =~ s/_//g;
Fred Drake05ce5701998-02-19 17:26:48 +0000559 # XXX somewhat bogus computation of $node
Fred Drakece0e1751998-02-18 22:45:53 +0000560# $node = $external_labels{$key} unless
561# ($node = $ref_files{$key});
562 $node = $key;
Fred Drakece0e1751998-02-18 22:45:53 +0000563 "<p>Module <tt><b><a href=\"$node#$key\">$module</a></b></tt>"
564 . "&nbsp;&nbsp;&nbsp;($text)</p>"
565 . $_;
Fred Drake9dcc5a91997-10-13 22:04:17 +0000566}
567
568sub do_cmd_seetext{
Fred Drake00dcfb21998-02-13 07:21:03 +0000569 "<p>" . @_[0];
Fred Drake9dcc5a91997-10-13 22:04:17 +0000570}
571
Fred Drake7c4cba81997-12-03 19:45:08 +0000572# These are located down here since they screw up fontlock.
573
574sub do_cmd_file{
Fred Drake00dcfb21998-02-13 07:21:03 +0000575 # This uses a weird HTML construct to adjust the font to be
576 # reasonable match that used in the printed form as much as
577 # possible. The expected behavior is that a browser that doesn't
578 # understand "<font face=...>" markup will use courier (or whatever
579 # the font is for <tt>).
580 local($_) = @_;
581 s/$any_next_pair_pr_rx/`<tt><font face=sans-serif>\2<\/font><\/tt>'/;
582 $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000583}
584
585sub do_cmd_samp{
Fred Drake00dcfb21998-02-13 07:21:03 +0000586 local($_) = @_;
587 s/$any_next_pair_pr_rx/`<samp>\2<\/samp>'/;
588 $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000589}
590
Guido van Rossum9e93fb61994-01-25 20:06:09 +00005911; # This must be the last line