blob: d68489776ebb8c46bad0b90d68f8d28125c94c70 [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
Guido van Rossum9e93fb61994-01-25 20:06:09 +000011# words typeset in a special way (not in HTML though)
12
13sub do_cmd_ABC{ join('', 'ABC', @_[0]); }
14sub do_cmd_UNIX{ join('', 'Unix', @_[0]); }
15sub do_cmd_ASCII{ join('', 'ASCII', @_[0]); }
Fred Drakebceaf351998-01-22 16:13:44 +000016sub do_cmd_POSIX{ join('', 'POSIX', @_[0]); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000017sub do_cmd_C{ join('', 'C', @_[0]); }
Guido van Rossumb8b264b1994-08-12 13:13:50 +000018sub do_cmd_Cpp{ join('', 'C++', @_[0]); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000019sub do_cmd_EOF{ join('', 'EOF', @_[0]); }
Fred Drake00dcfb21998-02-13 07:21:03 +000020sub do_cmd_NULL{ join('', '<tt>NULL</tt>', @_[0]); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000021
Fred Drake3e1fe891996-11-11 23:03:36 +000022sub do_cmd_e{ local($_) = @_; '&#92;' . $_; }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000023
Fred Drakec384d751996-11-11 16:04:35 +000024sub do_cmd_optional{
Fred Drake00dcfb21998-02-13 07:21:03 +000025 local($_) = @_;
26 s/$any_next_pair_pr_rx/<\/var><big>\[<\/big><var>\2<\/var><big>\]<\/big><var>/;
27 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000028}
29
Fred Drakec384d751996-11-11 16:04:35 +000030sub do_cmd_varvars{
Fred Drake00dcfb21998-02-13 07:21:03 +000031 local($_) = @_;
32 s/$any_next_pair_pr_rx/<var>\2<\/var>/;
33 $_;
Fred Drakec384d751996-11-11 16:04:35 +000034}
35
Fred Drake3e1fe891996-11-11 23:03:36 +000036# texinfo-like formatting commands: \code{...} etc.
37
Fred Drakec384d751996-11-11 16:04:35 +000038sub do_cmd_code{
Fred Drake00dcfb21998-02-13 07:21:03 +000039 local($_) = @_;
40 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
41 $_;
Fred Drakec384d751996-11-11 16:04:35 +000042}
43
44sub do_cmd_sectcode{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000045sub do_cmd_module{ &do_cmd_code(@_); }
46sub do_cmd_keyword{ &do_cmd_code(@_); }
47sub do_cmd_exception{ &do_cmd_code(@_); }
48sub do_cmd_class{ &do_cmd_code(@_); }
49sub do_cmd_function{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000050sub do_cmd_constant{ &do_cmd_code(@_); }
Fred Drake05ce5701998-02-19 17:26:48 +000051sub do_cmd_member{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000052sub do_cmd_method{ &do_cmd_code(@_); }
53sub do_cmd_email{ &do_cmd_code(@_); }
Fred Drake00dcfb21998-02-13 07:21:03 +000054sub do_cmd_program{ &do_cmd_code(@_); }
Fred Drake05ce5701998-02-19 17:26:48 +000055sub do_cmd_cfunction{ &do_cmd_code(@_); }
56sub do_cmd_cdata{ &do_cmd_code(@_); }
57sub do_cmd_ctype{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000058
Fred Drakece0e1751998-02-18 22:45:53 +000059sub do_cmd_email{
60 local($_) = @_;
61 s/$any_next_pair_pr_rx/<tt><font face=sans-serif>\2<\/font><\/tt>/;
62 $_;
63}
64
Fred Drakebceaf351998-01-22 16:13:44 +000065sub do_cmd_url{
66 # use the URL as both text and hyperlink
67 local($_) = @_;
Fred Drakece0e1751998-02-18 22:45:53 +000068 s/$any_next_pair_pr_rx//;
69 local($url) = $2;
Fred Drakec88aa351998-02-25 17:50:07 +000070 $url =~ s/~/&#126;/g;
Fred Drakece0e1751998-02-18 22:45:53 +000071 "<tt><font face=sans-serif><a href=\"$url\">$url</a></font></tt>" . $_;
Fred Drakebceaf351998-01-22 16:13:44 +000072}
73
74sub do_cmd_manpage{
75 # two parameters: \manpage{name}{section}
76 local($_) = @_;
77 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
78 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<em>\2<\/em>(\4)/;
79 $_;
80}
Fred Drakec384d751996-11-11 16:04:35 +000081
Fred Drake42543631998-02-10 22:11:07 +000082sub do_cmd_rfc{
83 local($_) = @_;
84 s/$next_pair_pr_rx//;
85 local($br_id,$rfcnumber) = ($1, $2);
86
87 # Save the reference
88 local($nstr) = &gen_index_id("RFC!RFC $rfcnumber", '');
89 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
90 "<a name=\"$br_id\">RFC $rfcnumber<\/a>" .$_;
91}
92
Guido van Rossum9e93fb61994-01-25 20:06:09 +000093sub do_cmd_kbd{
Fred Drake00dcfb21998-02-13 07:21:03 +000094 local($_) = @_;
95 s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/;
96 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000097}
98
99sub do_cmd_key{
Fred Drake00dcfb21998-02-13 07:21:03 +0000100 local($_) = @_;
101 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
102 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000103}
104
105sub do_cmd_var{
Fred Drake00dcfb21998-02-13 07:21:03 +0000106 local($_) = @_;
107 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
108 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000109}
110
111sub do_cmd_dfn{
Fred Drake00dcfb21998-02-13 07:21:03 +0000112 local($_) = @_;
113 s/$any_next_pair_pr_rx/<i><dfn>\2<\/dfn><\/i>/;
114 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000115}
116
117sub do_cmd_emph{
Fred Drake00dcfb21998-02-13 07:21:03 +0000118 local($_) = @_;
119 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
120 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000121}
122
123sub do_cmd_strong{
Fred Drake00dcfb21998-02-13 07:21:03 +0000124 local($_) = @_;
125 s/$any_next_pair_pr_rx/<b>\2<\/b>/;
126 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000127}
128
Fred Drake7c4cba81997-12-03 19:45:08 +0000129# file and samp are at the end of this file since they screw up fontlock.
130
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000131# index commands
132
Fred Drake42543631998-02-10 22:11:07 +0000133$INDEX_SUBITEM = "";
134
135sub do_cmd_setindexsubitem{
136 local($_) = @_;
137 s/$any_next_pair_pr_rx//;
138 $INDEX_SUBITEM = $2;
139 $_;
140}
141
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000142sub do_cmd_indexii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000143 local($_) = @_;
144 s/$next_pair_pr_rx//o;
145 local($br_id1, $str1) = ($1, $2);
146 s/$next_pair_pr_rx//o;
147 local($br_id2, $str2) = ($1, $2);
148 join('', &make_index_entry($br_id1, "$str1 $str2"),
149 &make_index_entry($br_id2, "$str2, $str1"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000150}
151
152sub do_cmd_indexiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000153 local($_) = @_;
154 s/$next_pair_pr_rx//o;
155 local($br_id1, $str1) = ($1, $2);
156 s/$next_pair_pr_rx//o;
157 local($br_id2, $str2) = ($1, $2);
158 s/$next_pair_pr_rx//o;
159 local($br_id3, $str3) = ($1, $2);
160 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
161 &make_index_entry($br_id2, "$str2 $str3, $str1"),
162 &make_index_entry($br_id3, "$str3, $str1 $str2"),
163 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000164}
165
166sub do_cmd_indexiv{
Fred Drake00dcfb21998-02-13 07:21:03 +0000167 local($_) = @_;
168 s/$next_pair_pr_rx//o;
169 local($br_id1, $str1) = ($1, $2);
170 s/$next_pair_pr_rx//o;
171 local($br_id2, $str2) = ($1, $2);
172 s/$next_pair_pr_rx//o;
173 local($br_id3, $str3) = ($1, $2);
174 s/$next_pair_pr_rx//o;
175 local($br_id4, $str4) = ($1, $2);
176 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
177 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
178 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
179 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
180 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000181}
182
Fred Drake00dcfb21998-02-13 07:21:03 +0000183sub do_cmd_ttindex{ &do_cmd_index(@_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000184
185sub my_typed_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000186 local($word, $_) = @_;
187 s/$next_pair_pr_rx//o;
188 local($br_id, $str) = ($1, $2);
189 join('', &make_index_entry($br_id, "$str $word"),
190 &make_index_entry($br_id, "$word, $str"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000191}
192
193sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000194sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
195sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
196sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
197
198sub my_parword_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000199 local($word, $_) = @_;
200 s/$next_pair_pr_rx//o;
201 local($br_id, $str) = ($1, $2);
202 &make_index_entry($br_id, "$str ($word)") . $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000203}
204
Fred Drake42543631998-02-10 22:11:07 +0000205
206# Set this to true to strip out the <tt>...</tt> from index entries;
207# this is analogous to using the second definition of \idxcode{} from
208# myformat.sty.
209#
210# It is used from &make_mod_index_entry() and &make_str_index_entry().
211#
212$STRIP_INDEX_TT = 0;
213
Fred Drake25492491998-02-13 15:08:36 +0000214sub make_mod_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000215 local($br_id,$str,$define) = @_;
Fred Drakeab0b65d1998-01-13 04:05:11 +0000216 local($halfref) = &make_half_href("$CURRENT_FILE#$br_id");
217 # If TITLE is not yet available (i.e the \index command is in the title
218 # of the current section), use $ref_before.
Fred Drake84818d71997-12-17 02:59:39 +0000219 $TITLE = $ref_before unless $TITLE;
220 # Save the reference
Fred Drakeab0b65d1998-01-13 04:05:11 +0000221 if ($define eq "DEF") {
222 local($nstr,$garbage) = split / /, $str, 2;
223 $Modules{$nstr} .= $halfref;
224 }
Fred Drake84818d71997-12-17 02:59:39 +0000225 $str = &gen_index_id($str, $define);
Fred Drake42543631998-02-10 22:11:07 +0000226 if ($STRIP_INDEX_TT) {
227 $str =~ s/<tt>(.*)<\/tt>/\1/;
228 }
Fred Drakeab0b65d1998-01-13 04:05:11 +0000229 $index{$str} .= $halfref;
Fred Drake8da9e6a1997-12-18 14:14:16 +0000230 "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
Fred Drake84818d71997-12-17 02:59:39 +0000231}
232
233sub my_module_index_helper{
Fred Drakece0e1751998-02-18 22:45:53 +0000234 local($word, $_) = @_;
235 s/$next_pair_pr_rx[\n]*//o;
236 local($br_id, $str) = ($1, $2);
237 local($section_tag) = join('', @curr_sec_id);
238 &make_mod_index_entry("SECTION$section_tag",
239 "<tt>$str</tt> ($word module)", 'DEF');
240 $_;
241}
242
243sub ref_module_index_helper{
244 local($word, $_) = @_;
Fred Drake00dcfb21998-02-13 07:21:03 +0000245 s/$next_pair_pr_rx//o;
246 local($br_id, $str) = ($1, $2);
Fred Drakece0e1751998-02-18 22:45:53 +0000247 &make_mod_index_entry($br_id, "<tt>$str</tt> ($word module)", 'REF') . $_;
Fred Drake84818d71997-12-17 02:59:39 +0000248}
249
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000250sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
Fred Drakece0e1751998-02-18 22:45:53 +0000251sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_); }
252sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000253
Fred Drakece0e1751998-02-18 22:45:53 +0000254# these should be adjusted a bit....
255sub do_cmd_refbimodindex{ &ref_module_index_helper('built-in', @_); }
256sub do_cmd_refstmodindex{ &ref_module_index_helper('standard', @_); }
Fred Drake72df9bc1997-12-16 21:13:20 +0000257
Fred Drakec384d751996-11-11 16:04:35 +0000258sub do_cmd_nodename{ &do_cmd_label(@_); }
259
Fred Drake1af9e791998-01-12 23:15:29 +0000260sub init_myformat{
261 # XXX need some way for this to be called after &initialise;
Fred Drakece0e1751998-02-18 22:45:53 +0000262 $anchor_mark = '';
263 $icons{'anchor_mark'} = '';
Fred Drake1af9e791998-01-12 23:15:29 +0000264 # <<2>>...<<2>>
265 $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
266 $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
267 $any_next_pair_rx7 = "$O(\\d+)$C([\\s\\S]*)$O\\7$C";
268 $any_next_pair_rx9 = "$O(\\d+)$C([\\s\\S]*)$O\\9$C";
269 # <#2#>...<#2#>
270 $any_next_pair_pr_rx_3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
271 $any_next_pair_pr_rx_5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
272 $any_next_pair_pr_rx_7 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP";
273 $any_next_pair_pr_rx_9 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000274}
275
276&init_myformat;
Fred Drakec384d751996-11-11 16:04:35 +0000277
278sub get_indexsubitem{
Fred Drake00dcfb21998-02-13 07:21:03 +0000279 local($result) = $INDEX_SUBITEM;
Fred Drakec384d751996-11-11 16:04:35 +0000280 #print "\nget_indexsubitem ==> $result\n";
Fred Drake9597daf1997-12-22 22:37:34 +0000281 $result ? " $result" : '';
Fred Drakec384d751996-11-11 16:04:35 +0000282}
283
Fred Drake84818d71997-12-17 02:59:39 +0000284# similar to make_index_entry(), but includes the string in the result
285# instead of the dummy filler.
286#
Fred Drake25492491998-02-13 15:08:36 +0000287sub make_str_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000288 local($br_id,$str) = @_;
289 # If TITLE is not yet available (i.e the \index command is in the title
290 # of the current section), use $ref_before.
291 $TITLE = $ref_before unless $TITLE;
292 # Save the reference
293 local($nstr) = &gen_index_id($str, '');
Fred Drake42543631998-02-10 22:11:07 +0000294 if ($STRIP_INDEX_TT) {
295 $nstr =~ s/<tt>(.*)<\/tt>/\1/;
296 }
Fred Drake84818d71997-12-17 02:59:39 +0000297 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
298 "<a name=\"$br_id\">$str<\/a>";
299}
300
Fred Drake06e16641998-02-16 22:50:06 +0000301# Changed from the stock version to indent {verbatim} sections:
302sub replace_verbatim {
303 # Modifies $_
Fred Drakec88aa351998-02-25 17:50:07 +0000304 s/$verbatim_mark(verbatim)(\d+)/<p><dl><dd><pre>$verbatim{$2}<\/pre><\/dl>/go;
Fred Drake06e16641998-02-16 22:50:06 +0000305 s/$verbatim_mark(rawhtml)(\d+)/$verbatim{$2}/ego; # Raw HTML
306}
307
Fred Drake7a7480d1996-10-29 15:56:57 +0000308sub do_env_cfuncdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000309 local($_) = @_;
310 local($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
311 local($cfuncdesc_rx) =
312 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
313 if (/$cfuncdesc_rx/o) {
314 $return_type = "$2";
315 $function_name = "$4";
316 $arg_list = "$6";
317 $idx = &make_str_index_entry($3,
318 "<tt>$function_name</tt>" . &get_indexsubitem);
319 $idx =~ s/ \(.*\)//;
320 }
321 "<dl><dt>$return_type <b>$idx</b>"
322 . "(<var>$arg_list</var>)\n<dd>$'\n</dl>"
Fred Drake7a7480d1996-10-29 15:56:57 +0000323}
324
Fred Drake9dcc5a91997-10-13 22:04:17 +0000325sub do_env_ctypedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000326 local($_) = @_;
327 local($type_name) = ('');
328 local($cfuncdesc_rx) = "$next_pair_rx";
329 if (/$cfuncdesc_rx/o) {
330 $type_name = "$2";
331 $idx = &make_str_index_entry($1,
332 "<tt>$type_name</tt>" . &get_indexsubitem);
333 $idx =~ s/ \(.*\)//;
334 }
335 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake9dcc5a91997-10-13 22:04:17 +0000336}
337
338sub do_env_cvardesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000339 local($_) = @_;
340 local($var_type,$var_name,$idx) = ('', '', '');
341 local($cfuncdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
342 if (/$cfuncdesc_rx/o) {
343 $var_type = "$2";
344 $var_name = "$4";
345 $idx = &make_str_index_entry($3,
346 "<tt>$var_name</tt>" . &get_indexsubitem);
347 $idx =~ s/ \(.*\)//;
348 }
349 "<dl><dt>$var_type <b>$idx</b>\n"
350 . "<dd>$'\n</dl>";
Fred Drake9dcc5a91997-10-13 22:04:17 +0000351}
352
Fred Drakec384d751996-11-11 16:04:35 +0000353sub do_env_funcdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000354 local($_) = @_;
355 local($function_name,$arg_list,$idx) = ('', '', '');
356 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
357 if (/$funcdesc_rx/o) {
358 $function_name = "$2";
359 $arg_list = "$4";
360 $idx = &make_str_index_entry($3,
361 "<tt>$function_name</tt>" . &get_indexsubitem);
362 $idx =~ s/ \(.*\)//;
363 }
364 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
Fred Drake1af9e791998-01-12 23:15:29 +0000365}
366
Fred Drake25492491998-02-13 15:08:36 +0000367sub do_env_funcdescni{
368 local($_) = @_;
369 local($function_name,$arg_list,$idx) = ('', '', '');
370 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
371 if (/$funcdesc_rx/o) {
372 $function_name = "$2";
373 $arg_list = "$4";
374 if ($STRIP_INDEX_TT) {
375 $idx = $function_name; }
376 else {
377 $idx = "<tt>$function_name</tt>"; }
378 }
379 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
380}
381
Fred Drake1af9e791998-01-12 23:15:29 +0000382sub do_cmd_funcline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000383 local($_) = @_;
384 local($funcdesc_rx) = "$next_pair_pr_rx$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000385
Fred Drake00dcfb21998-02-13 07:21:03 +0000386 s/$funcdesc_rx//o;
387 local($br_id, $function_name, $arg_list) = ($3, $2, $4);
388 local($idx) = &make_str_index_entry($br_id, "<tt>$function_name</tt>");
Fred Drake1af9e791998-01-12 23:15:29 +0000389
Fred Drake00dcfb21998-02-13 07:21:03 +0000390 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000391}
392
Fred Drake00dcfb21998-02-13 07:21:03 +0000393# Change this flag to index the opcode entries. I don't think it's very
394# useful to index them, since they're only presented to describe the dis
395# module.
396#
397$INDEX_OPCODES = 0;
398
Fred Drake7c4cba81997-12-03 19:45:08 +0000399sub do_env_opcodedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000400 local($_) = @_;
401 local($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
402 local($opcodedesc_rx) = "$next_pair_rx$any_next_pair_rx3";
403 if (/$opcodedesc_rx/o) {
404 $opcode_name = "$2";
405 $arg_list = "$4";
406 if ($INDEX_OPCODES) {
407 $idx = &make_str_index_entry($3,
408 "<tt>$opcode_name</tt> (byte code instruction)");
409 $idx =~ s/ \(byte code instruction\)//;
410 }
411 else {
412 $idx = "<tt>$opcode_name</tt>";
413 }
414 }
415 $stuff = "<dl><dt><b>$idx</b>";
416 if ($arg_list) {
417 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
418 }
419 $stuff . "\n<dd>$'\n</dl>";
Fred Drakec384d751996-11-11 16:04:35 +0000420}
421
422sub do_env_datadesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000423 local($_) = @_;
424 local($idx) = '';
425 if (/$next_pair_rx/o) {
426 $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
427 $idx =~ s/ \(.*\)//;
428 }
429 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake1af9e791998-01-12 23:15:29 +0000430}
431
Fred Drake25492491998-02-13 15:08:36 +0000432sub do_env_datadescni{
433 local($_) = @_;
434 local($idx) = '';
435 if (/$next_pair_rx/o) {
436 if ($STRING_INDEX_TT) {
437 $idx = "$2"; }
438 else {
439 $idx = "<tt>$2</tt>"; }
440 }
441 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
442}
443
Fred Drake1af9e791998-01-12 23:15:29 +0000444sub do_cmd_dataline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000445 local($_) = @_;
Fred Drake1af9e791998-01-12 23:15:29 +0000446
Fred Drake00dcfb21998-02-13 07:21:03 +0000447 s/$next_pair_pr_rx//o;
448 local($br_id, $data_name) = ($1, $2);
449 local($idx) = &make_str_index_entry($br_id, "<tt>$data_name</tt>"
450 . &get_indexsubitem);
451 $idx =~ s/ \(.*\)//;
Fred Drake1af9e791998-01-12 23:15:29 +0000452
Fred Drake00dcfb21998-02-13 07:21:03 +0000453 "<dt><b>$idx</b>\n<dd>" . $_;
Fred Drakec384d751996-11-11 16:04:35 +0000454}
455
456sub do_env_excdesc{ &do_env_datadesc(@_); }
Fred Drake05ce5701998-02-19 17:26:48 +0000457sub do_env_classdesc{ &do_env_funcdesc(@_); }
458sub do_env_fulllineitems{ &do_env_itemize(@_); }
Fred Drake00dcfb21998-02-13 07:21:03 +0000459
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;
Fred Drake05ce5701998-02-19 17:26:48 +0000555 # XXX somewhat bogus computation of $node
Fred Drakece0e1751998-02-18 22:45:53 +0000556# $node = $external_labels{$key} unless
557# ($node = $ref_files{$key});
558 $node = $key;
Fred Drakece0e1751998-02-18 22:45:53 +0000559 "<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