blob: da9dbd1a84f15e27a6bc7fa446f59d34b6e5e258 [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 Drake20ee2061998-02-26 05:49:37 +000024$AUTHOR_ADDRESS = '(not specified)';
25$PYTHON_VERSION = '(not specified)';
26
27sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
28sub do_cmd_release{
29 local($_) = @_;
30 s/$any_next_pair_pr_rx//;
31 $PYTHON_VERSION = "$2";
32 $_;
33}
34
35sub do_cmd_authoraddress{
36 local($_) = @_;
37 s/$any_next_pair_pr_rx//;
38 $AUTHOR_ADDRESS = "$2";
39 $_;
40}
41
42sub do_cmd_hackscore{
43 local($_) = @_;
44 s/$any_next_pair_pr_rx/_/;
45 $_;
46}
47
Fred Drakec384d751996-11-11 16:04:35 +000048sub do_cmd_optional{
Fred Drake00dcfb21998-02-13 07:21:03 +000049 local($_) = @_;
50 s/$any_next_pair_pr_rx/<\/var><big>\[<\/big><var>\2<\/var><big>\]<\/big><var>/;
51 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000052}
53
Fred Drakec384d751996-11-11 16:04:35 +000054sub do_cmd_varvars{
Fred Drake00dcfb21998-02-13 07:21:03 +000055 local($_) = @_;
56 s/$any_next_pair_pr_rx/<var>\2<\/var>/;
57 $_;
Fred Drakec384d751996-11-11 16:04:35 +000058}
59
Fred Drake3e1fe891996-11-11 23:03:36 +000060# texinfo-like formatting commands: \code{...} etc.
61
Fred Drakec384d751996-11-11 16:04:35 +000062sub do_cmd_code{
Fred Drake00dcfb21998-02-13 07:21:03 +000063 local($_) = @_;
64 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
65 $_;
Fred Drakec384d751996-11-11 16:04:35 +000066}
67
68sub do_cmd_sectcode{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000069sub do_cmd_module{ &do_cmd_code(@_); }
70sub do_cmd_keyword{ &do_cmd_code(@_); }
71sub do_cmd_exception{ &do_cmd_code(@_); }
72sub do_cmd_class{ &do_cmd_code(@_); }
73sub do_cmd_function{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000074sub do_cmd_constant{ &do_cmd_code(@_); }
Fred Drake05ce5701998-02-19 17:26:48 +000075sub do_cmd_member{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000076sub do_cmd_method{ &do_cmd_code(@_); }
77sub do_cmd_email{ &do_cmd_code(@_); }
Fred Drake00dcfb21998-02-13 07:21:03 +000078sub do_cmd_program{ &do_cmd_code(@_); }
Fred Drake05ce5701998-02-19 17:26:48 +000079sub do_cmd_cfunction{ &do_cmd_code(@_); }
80sub do_cmd_cdata{ &do_cmd_code(@_); }
81sub do_cmd_ctype{ &do_cmd_code(@_); }
Fred Drakebceaf351998-01-22 16:13:44 +000082
Fred Drakece0e1751998-02-18 22:45:53 +000083sub do_cmd_email{
84 local($_) = @_;
85 s/$any_next_pair_pr_rx/<tt><font face=sans-serif>\2<\/font><\/tt>/;
86 $_;
87}
88
Fred Drakebceaf351998-01-22 16:13:44 +000089sub do_cmd_url{
90 # use the URL as both text and hyperlink
91 local($_) = @_;
Fred Drakece0e1751998-02-18 22:45:53 +000092 s/$any_next_pair_pr_rx//;
93 local($url) = $2;
Fred Drakec88aa351998-02-25 17:50:07 +000094 $url =~ s/~/&#126;/g;
Fred Drakece0e1751998-02-18 22:45:53 +000095 "<tt><font face=sans-serif><a href=\"$url\">$url</a></font></tt>" . $_;
Fred Drakebceaf351998-01-22 16:13:44 +000096}
97
98sub do_cmd_manpage{
99 # two parameters: \manpage{name}{section}
100 local($_) = @_;
101 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
102 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<em>\2<\/em>(\4)/;
103 $_;
104}
Fred Drakec384d751996-11-11 16:04:35 +0000105
Fred Drake42543631998-02-10 22:11:07 +0000106sub do_cmd_rfc{
107 local($_) = @_;
108 s/$next_pair_pr_rx//;
109 local($br_id,$rfcnumber) = ($1, $2);
110
111 # Save the reference
112 local($nstr) = &gen_index_id("RFC!RFC $rfcnumber", '');
113 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
114 "<a name=\"$br_id\">RFC $rfcnumber<\/a>" .$_;
115}
116
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000117sub do_cmd_kbd{
Fred Drake00dcfb21998-02-13 07:21:03 +0000118 local($_) = @_;
119 s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/;
120 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000121}
122
123sub do_cmd_key{
Fred Drake00dcfb21998-02-13 07:21:03 +0000124 local($_) = @_;
125 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
126 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000127}
128
129sub do_cmd_var{
Fred Drake00dcfb21998-02-13 07:21:03 +0000130 local($_) = @_;
131 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
132 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000133}
134
135sub do_cmd_dfn{
Fred Drake00dcfb21998-02-13 07:21:03 +0000136 local($_) = @_;
137 s/$any_next_pair_pr_rx/<i><dfn>\2<\/dfn><\/i>/;
138 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000139}
140
141sub do_cmd_emph{
Fred Drake00dcfb21998-02-13 07:21:03 +0000142 local($_) = @_;
143 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
144 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000145}
146
147sub do_cmd_strong{
Fred Drake00dcfb21998-02-13 07:21:03 +0000148 local($_) = @_;
149 s/$any_next_pair_pr_rx/<b>\2<\/b>/;
150 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000151}
152
Fred Drake7c4cba81997-12-03 19:45:08 +0000153# file and samp are at the end of this file since they screw up fontlock.
154
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000155# index commands
156
Fred Drake42543631998-02-10 22:11:07 +0000157$INDEX_SUBITEM = "";
158
Fred Drakef9fd4e81998-02-27 15:28:45 +0000159sub get_indexsubitem{
160 $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
161}
162
Fred Drake42543631998-02-10 22:11:07 +0000163sub do_cmd_setindexsubitem{
164 local($_) = @_;
165 s/$any_next_pair_pr_rx//;
166 $INDEX_SUBITEM = $2;
167 $_;
168}
169
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000170sub do_cmd_indexii{
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 join('', &make_index_entry($br_id1, "$str1 $str2"),
177 &make_index_entry($br_id2, "$str2, $str1"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000178}
179
180sub do_cmd_indexiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000181 local($_) = @_;
182 s/$next_pair_pr_rx//o;
183 local($br_id1, $str1) = ($1, $2);
184 s/$next_pair_pr_rx//o;
185 local($br_id2, $str2) = ($1, $2);
186 s/$next_pair_pr_rx//o;
187 local($br_id3, $str3) = ($1, $2);
188 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
189 &make_index_entry($br_id2, "$str2 $str3, $str1"),
190 &make_index_entry($br_id3, "$str3, $str1 $str2"),
191 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000192}
193
194sub do_cmd_indexiv{
Fred Drake00dcfb21998-02-13 07:21:03 +0000195 local($_) = @_;
196 s/$next_pair_pr_rx//o;
197 local($br_id1, $str1) = ($1, $2);
198 s/$next_pair_pr_rx//o;
199 local($br_id2, $str2) = ($1, $2);
200 s/$next_pair_pr_rx//o;
201 local($br_id3, $str3) = ($1, $2);
202 s/$next_pair_pr_rx//o;
203 local($br_id4, $str4) = ($1, $2);
204 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
205 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
206 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
207 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
208 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000209}
210
Fred Drake00dcfb21998-02-13 07:21:03 +0000211sub do_cmd_ttindex{ &do_cmd_index(@_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000212
213sub my_typed_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000214 local($word, $_) = @_;
215 s/$next_pair_pr_rx//o;
216 local($br_id, $str) = ($1, $2);
217 join('', &make_index_entry($br_id, "$str $word"),
218 &make_index_entry($br_id, "$word, $str"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000219}
220
221sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000222sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
223sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
224sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
225
226sub my_parword_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000227 local($word, $_) = @_;
228 s/$next_pair_pr_rx//o;
229 local($br_id, $str) = ($1, $2);
230 &make_index_entry($br_id, "$str ($word)") . $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000231}
232
Fred Drake42543631998-02-10 22:11:07 +0000233
234# Set this to true to strip out the <tt>...</tt> from index entries;
235# this is analogous to using the second definition of \idxcode{} from
236# myformat.sty.
237#
238# It is used from &make_mod_index_entry() and &make_str_index_entry().
239#
240$STRIP_INDEX_TT = 0;
241
Fred Drake25492491998-02-13 15:08:36 +0000242sub make_mod_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000243 local($br_id,$str,$define) = @_;
Fred Drakeab0b65d1998-01-13 04:05:11 +0000244 local($halfref) = &make_half_href("$CURRENT_FILE#$br_id");
245 # If TITLE is not yet available (i.e the \index command is in the title
246 # of the current section), use $ref_before.
Fred Drake84818d71997-12-17 02:59:39 +0000247 $TITLE = $ref_before unless $TITLE;
248 # Save the reference
Fred Drakeab0b65d1998-01-13 04:05:11 +0000249 if ($define eq "DEF") {
250 local($nstr,$garbage) = split / /, $str, 2;
251 $Modules{$nstr} .= $halfref;
252 }
Fred Drake84818d71997-12-17 02:59:39 +0000253 $str = &gen_index_id($str, $define);
Fred Drake42543631998-02-10 22:11:07 +0000254 if ($STRIP_INDEX_TT) {
255 $str =~ s/<tt>(.*)<\/tt>/\1/;
256 }
Fred Drakeab0b65d1998-01-13 04:05:11 +0000257 $index{$str} .= $halfref;
Fred Drake8da9e6a1997-12-18 14:14:16 +0000258 "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
Fred Drake84818d71997-12-17 02:59:39 +0000259}
260
261sub my_module_index_helper{
Fred Drakece0e1751998-02-18 22:45:53 +0000262 local($word, $_) = @_;
263 s/$next_pair_pr_rx[\n]*//o;
264 local($br_id, $str) = ($1, $2);
265 local($section_tag) = join('', @curr_sec_id);
266 &make_mod_index_entry("SECTION$section_tag",
267 "<tt>$str</tt> ($word module)", 'DEF');
268 $_;
269}
270
271sub ref_module_index_helper{
272 local($word, $_) = @_;
Fred Drake00dcfb21998-02-13 07:21:03 +0000273 s/$next_pair_pr_rx//o;
274 local($br_id, $str) = ($1, $2);
Fred Drakece0e1751998-02-18 22:45:53 +0000275 &make_mod_index_entry($br_id, "<tt>$str</tt> ($word module)", 'REF') . $_;
Fred Drake84818d71997-12-17 02:59:39 +0000276}
277
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000278sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
Fred Drakece0e1751998-02-18 22:45:53 +0000279sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_); }
280sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000281
Fred Drakece0e1751998-02-18 22:45:53 +0000282# these should be adjusted a bit....
283sub do_cmd_refbimodindex{ &ref_module_index_helper('built-in', @_); }
284sub do_cmd_refstmodindex{ &ref_module_index_helper('standard', @_); }
Fred Drake72df9bc1997-12-16 21:13:20 +0000285
Fred Drakec384d751996-11-11 16:04:35 +0000286sub do_cmd_nodename{ &do_cmd_label(@_); }
287
Fred Drake1af9e791998-01-12 23:15:29 +0000288sub init_myformat{
Fred Drake20ee2061998-02-26 05:49:37 +0000289 # XXX need some way for this to be called after &initialise; ???
Fred Drakef9fd4e81998-02-27 15:28:45 +0000290 $anchor_mark = '';
291 $icons{'anchor_mark'} = '';
Fred Drake1af9e791998-01-12 23:15:29 +0000292 # <<2>>...<<2>>
293 $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
294 $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
295 $any_next_pair_rx7 = "$O(\\d+)$C([\\s\\S]*)$O\\7$C";
296 $any_next_pair_rx9 = "$O(\\d+)$C([\\s\\S]*)$O\\9$C";
297 # <#2#>...<#2#>
298 $any_next_pair_pr_rx_3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
299 $any_next_pair_pr_rx_5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
300 $any_next_pair_pr_rx_7 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP";
301 $any_next_pair_pr_rx_9 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000302}
303
304&init_myformat;
Fred Drakec384d751996-11-11 16:04:35 +0000305
Fred Drake84818d71997-12-17 02:59:39 +0000306# similar to make_index_entry(), but includes the string in the result
307# instead of the dummy filler.
308#
Fred Drake25492491998-02-13 15:08:36 +0000309sub make_str_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000310 local($br_id,$str) = @_;
311 # If TITLE is not yet available (i.e the \index command is in the title
312 # of the current section), use $ref_before.
313 $TITLE = $ref_before unless $TITLE;
314 # Save the reference
315 local($nstr) = &gen_index_id($str, '');
Fred Drake42543631998-02-10 22:11:07 +0000316 if ($STRIP_INDEX_TT) {
317 $nstr =~ s/<tt>(.*)<\/tt>/\1/;
318 }
Fred Drake84818d71997-12-17 02:59:39 +0000319 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
320 "<a name=\"$br_id\">$str<\/a>";
321}
322
Fred Drakef9fd4e81998-02-27 15:28:45 +0000323# Changed from the stock version to indent {verbatim} sections,
324# and make them smaller, to better match the LaTeX version:
325
326# (Used with LaTeX2HTML 96.1*)
Fred Drake06e16641998-02-16 22:50:06 +0000327sub replace_verbatim {
328 # Modifies $_
Fred Drakef9fd4e81998-02-27 15:28:45 +0000329 s/$verbatim_mark(verbatim)(\d+)/<p><dl><dd><font size=\"-1\"><pre>$verbatim{$2}<\/pre><\/font><\/dl>/go;
Fred Drake06e16641998-02-16 22:50:06 +0000330 s/$verbatim_mark(rawhtml)(\d+)/$verbatim{$2}/ego; # Raw HTML
331}
Fred Drakef9fd4e81998-02-27 15:28:45 +0000332
333# (Used with LaTeX2HTML 98.1)
334sub replace_verbatim_hook{
335 # Modifies $_
336 s/$math_verbatim_rx/&put_comment("MATH: ".$verbatim{$1})/eg;
337# s/$verbatim_mark(verbatim\*?)(\d+)#/<PRE>\n$verbatim{$2}\n<\/PRE>/go;
338 s/$verbatim_mark(\w*[vV]erbatim\*?)(\d+)#/\n<p><dl><dd><font size=\"-1\">$verbatim{$2}<\/font><\/dl>\n/go;
339# s/$verbatim_mark(rawhtml)(\d+)#/$verbatim{$2}/eg; # Raw HTML
340 # Raw HTML, but replacements may have protected characters
341 s/$verbatim_mark(rawhtml)(\d+)#/&unprotect_raw_html($verbatim{$2})/eg;
342 s/$verbatim_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX
343 s/$unfinished_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX
344}
Fred Drake06e16641998-02-16 22:50:06 +0000345
Fred Drake7a7480d1996-10-29 15:56:57 +0000346sub do_env_cfuncdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000347 local($_) = @_;
348 local($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
349 local($cfuncdesc_rx) =
350 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
351 if (/$cfuncdesc_rx/o) {
352 $return_type = "$2";
353 $function_name = "$4";
354 $arg_list = "$6";
355 $idx = &make_str_index_entry($3,
356 "<tt>$function_name</tt>" . &get_indexsubitem);
357 $idx =~ s/ \(.*\)//;
358 }
359 "<dl><dt>$return_type <b>$idx</b>"
360 . "(<var>$arg_list</var>)\n<dd>$'\n</dl>"
Fred Drake7a7480d1996-10-29 15:56:57 +0000361}
362
Fred Drake9dcc5a91997-10-13 22:04:17 +0000363sub do_env_ctypedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000364 local($_) = @_;
365 local($type_name) = ('');
366 local($cfuncdesc_rx) = "$next_pair_rx";
367 if (/$cfuncdesc_rx/o) {
368 $type_name = "$2";
369 $idx = &make_str_index_entry($1,
370 "<tt>$type_name</tt>" . &get_indexsubitem);
371 $idx =~ s/ \(.*\)//;
372 }
373 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake9dcc5a91997-10-13 22:04:17 +0000374}
375
376sub do_env_cvardesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000377 local($_) = @_;
378 local($var_type,$var_name,$idx) = ('', '', '');
379 local($cfuncdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
380 if (/$cfuncdesc_rx/o) {
381 $var_type = "$2";
382 $var_name = "$4";
383 $idx = &make_str_index_entry($3,
384 "<tt>$var_name</tt>" . &get_indexsubitem);
385 $idx =~ s/ \(.*\)//;
386 }
387 "<dl><dt>$var_type <b>$idx</b>\n"
388 . "<dd>$'\n</dl>";
Fred Drake9dcc5a91997-10-13 22:04:17 +0000389}
390
Fred Drakec384d751996-11-11 16:04:35 +0000391sub do_env_funcdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000392 local($_) = @_;
393 local($function_name,$arg_list,$idx) = ('', '', '');
394 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
395 if (/$funcdesc_rx/o) {
396 $function_name = "$2";
397 $arg_list = "$4";
398 $idx = &make_str_index_entry($3,
399 "<tt>$function_name</tt>" . &get_indexsubitem);
400 $idx =~ s/ \(.*\)//;
401 }
402 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
Fred Drake1af9e791998-01-12 23:15:29 +0000403}
404
Fred Drake25492491998-02-13 15:08:36 +0000405sub do_env_funcdescni{
406 local($_) = @_;
407 local($function_name,$arg_list,$idx) = ('', '', '');
408 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
409 if (/$funcdesc_rx/o) {
410 $function_name = "$2";
411 $arg_list = "$4";
412 if ($STRIP_INDEX_TT) {
413 $idx = $function_name; }
414 else {
415 $idx = "<tt>$function_name</tt>"; }
416 }
417 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
418}
419
Fred Drake1af9e791998-01-12 23:15:29 +0000420sub do_cmd_funcline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000421 local($_) = @_;
422 local($funcdesc_rx) = "$next_pair_pr_rx$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000423
Fred Drake00dcfb21998-02-13 07:21:03 +0000424 s/$funcdesc_rx//o;
425 local($br_id, $function_name, $arg_list) = ($3, $2, $4);
426 local($idx) = &make_str_index_entry($br_id, "<tt>$function_name</tt>");
Fred Drake1af9e791998-01-12 23:15:29 +0000427
Fred Drake00dcfb21998-02-13 07:21:03 +0000428 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000429}
430
Fred Drake00dcfb21998-02-13 07:21:03 +0000431# Change this flag to index the opcode entries. I don't think it's very
432# useful to index them, since they're only presented to describe the dis
433# module.
434#
435$INDEX_OPCODES = 0;
436
Fred Drake7c4cba81997-12-03 19:45:08 +0000437sub do_env_opcodedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000438 local($_) = @_;
439 local($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
440 local($opcodedesc_rx) = "$next_pair_rx$any_next_pair_rx3";
441 if (/$opcodedesc_rx/o) {
442 $opcode_name = "$2";
443 $arg_list = "$4";
444 if ($INDEX_OPCODES) {
445 $idx = &make_str_index_entry($3,
446 "<tt>$opcode_name</tt> (byte code instruction)");
447 $idx =~ s/ \(byte code instruction\)//;
448 }
449 else {
450 $idx = "<tt>$opcode_name</tt>";
451 }
452 }
453 $stuff = "<dl><dt><b>$idx</b>";
454 if ($arg_list) {
455 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
456 }
457 $stuff . "\n<dd>$'\n</dl>";
Fred Drakec384d751996-11-11 16:04:35 +0000458}
459
460sub do_env_datadesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000461 local($_) = @_;
462 local($idx) = '';
463 if (/$next_pair_rx/o) {
464 $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
465 $idx =~ s/ \(.*\)//;
466 }
467 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake1af9e791998-01-12 23:15:29 +0000468}
469
Fred Drake25492491998-02-13 15:08:36 +0000470sub do_env_datadescni{
471 local($_) = @_;
472 local($idx) = '';
473 if (/$next_pair_rx/o) {
474 if ($STRING_INDEX_TT) {
475 $idx = "$2"; }
476 else {
477 $idx = "<tt>$2</tt>"; }
478 }
479 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
480}
481
Fred Drake1af9e791998-01-12 23:15:29 +0000482sub do_cmd_dataline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000483 local($_) = @_;
Fred Drake1af9e791998-01-12 23:15:29 +0000484
Fred Drake00dcfb21998-02-13 07:21:03 +0000485 s/$next_pair_pr_rx//o;
486 local($br_id, $data_name) = ($1, $2);
487 local($idx) = &make_str_index_entry($br_id, "<tt>$data_name</tt>"
488 . &get_indexsubitem);
489 $idx =~ s/ \(.*\)//;
Fred Drake1af9e791998-01-12 23:15:29 +0000490
Fred Drake00dcfb21998-02-13 07:21:03 +0000491 "<dt><b>$idx</b>\n<dd>" . $_;
Fred Drakec384d751996-11-11 16:04:35 +0000492}
493
494sub do_env_excdesc{ &do_env_datadesc(@_); }
Fred Drake05ce5701998-02-19 17:26:48 +0000495sub do_env_classdesc{ &do_env_funcdesc(@_); }
496sub do_env_fulllineitems{ &do_env_itemize(@_); }
Fred Drake00dcfb21998-02-13 07:21:03 +0000497
Fred Drakec384d751996-11-11 16:04:35 +0000498
Fred Drake9597daf1997-12-22 22:37:34 +0000499@col_aligns = ("<td>", "<td>", "<td>");
500
501sub setup_column_alignments{
Fred Drake00dcfb21998-02-13 07:21:03 +0000502 local($_) = @_;
503 local($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_);
504 local($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
505 $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>");
506 $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>");
507 $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>");
508 # return the aligned header start tags; only used for \begin{tableiii?}
509 $th1 = (($a1 eq "l") ? "<th align=left>"
510 : ($a1 eq "r" ? "<th align=right>" : "<th>"));
511 $th2 = (($a2 eq "l") ? "<th align=left>"
512 : ($a2 eq "r" ? "<th align=right>" : "<th>"));
513 $th3 = (($a3 eq "l") ? "<th align=left>"
514 : ($a3 eq "r" ? "<th align=right>" : "<th>"));
515 ($th1, $th2, $th3);
Fred Drake9597daf1997-12-22 22:37:34 +0000516}
517
518sub do_env_tableii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000519 local($_) = @_;
520 local($font,$h1,$h2) = ('', '', '');
521 local($tableiii_rx) =
522 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7";
523 if (/$tableiii_rx/o) {
524 $font = $4;
525 $h1 = $6;
526 $h2 = $8;
527 }
528 local($th1,$th2,$th3) = &setup_column_alignments($2);
529 $globals{"lineifont"} = $font;
Fred Drakef9fd4e81998-02-27 15:28:45 +0000530 "<table border align=center>"
531 . "\n <tr>$th1<b>$h1</b></th>"
532 . "\n $th2<b>$h2</b></th>$'"
533 . "\n</table>";
Fred Drake9597daf1997-12-22 22:37:34 +0000534}
535
536sub do_cmd_lineii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000537 local($_) = @_;
538 s/$next_pair_pr_rx//o;
539 local($c1) = $2;
540 s/$next_pair_pr_rx//o;
541 local($c2) = $2;
542 local($font) = $globals{"lineifont"};
543 local($c1align, $c2align) = @col_aligns[0,1];
544 "<tr>$c1align<$font>$c1</$font></td>\n"
545 . " $c2align$c2</td>$'";
Fred Drake9597daf1997-12-22 22:37:34 +0000546}
547
548sub do_env_tableiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000549 local($_) = @_;
550 local($font,$h1,$h2,$h3) = ('', '', '', '');
Fred Drake1af9e791998-01-12 23:15:29 +0000551
Fred Drake00dcfb21998-02-13 07:21:03 +0000552 local($tableiii_rx) =
553 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"
554 . "$any_next_pair_rx9";
555 if (/$tableiii_rx/o) {
556 $font = $4;
557 $h1 = $6;
558 $h2 = $8;
559 $h3 = $10;
560 }
561 local($th1,$th2,$th3) = &setup_column_alignments($2);
562 $globals{"lineifont"} = $font;
Fred Drakef9fd4e81998-02-27 15:28:45 +0000563 "<table border align=center>"
564 . "\n <tr>$th1<b>$h1</b></th>"
565 . "\n $th2<b>$h2</b></th>"
566 . "\n $th3<b>$h3</b></th>$'"
567 . "\n</table>";
Fred Drake9597daf1997-12-22 22:37:34 +0000568}
569
570sub do_cmd_lineiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000571 local($_) = @_;
572 s/$next_pair_pr_rx//o;
573 local($c1) = $2;
574 s/$next_pair_pr_rx//o;
575 local($c2) = $2;
576 s/$next_pair_pr_rx//o;
577 local($c3) = $2;
578 local($font) = $globals{"lineifont"};
579 local($c1align, $c2align, $c3align) = @col_aligns;
580 "<tr>$c1align<$font>$c1</$font></td>\n"
581 . " $c2align$c2</td>\n"
582 . " $c3align$c3</td>$'";
Fred Drake9597daf1997-12-22 22:37:34 +0000583}
584
Fred Drake9dcc5a91997-10-13 22:04:17 +0000585sub do_env_seealso{
Fred Drake00dcfb21998-02-13 07:21:03 +0000586 "<p><b>See Also:</b></p>\n" . @_[0];
Fred Drake9dcc5a91997-10-13 22:04:17 +0000587}
588
589sub do_cmd_seemodule{
Fred Drakece0e1751998-02-18 22:45:53 +0000590 # Insert the right magic to jump to the module definition. This should
591 # work most of the time, at least for repeat builds....
Fred Drake00dcfb21998-02-13 07:21:03 +0000592 local($_) = @_;
593 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drakece0e1751998-02-18 22:45:53 +0000594 s/$next_pair_pr_rx$any_next_pair_pr_rx3//;
595 local($module,$text,$node,$key) = ($2, $4, '', "module$2");
596 $key =~ s/_//g;
Fred Drake05ce5701998-02-19 17:26:48 +0000597 # XXX somewhat bogus computation of $node
Fred Drakece0e1751998-02-18 22:45:53 +0000598# $node = $external_labels{$key} unless
599# ($node = $ref_files{$key});
600 $node = $key;
Fred Drakece0e1751998-02-18 22:45:53 +0000601 "<p>Module <tt><b><a href=\"$node#$key\">$module</a></b></tt>"
602 . "&nbsp;&nbsp;&nbsp;($text)</p>"
603 . $_;
Fred Drake9dcc5a91997-10-13 22:04:17 +0000604}
605
606sub do_cmd_seetext{
Fred Drake00dcfb21998-02-13 07:21:03 +0000607 "<p>" . @_[0];
Fred Drake9dcc5a91997-10-13 22:04:17 +0000608}
609
Fred Drake7c4cba81997-12-03 19:45:08 +0000610# These are located down here since they screw up fontlock.
611
612sub do_cmd_file{
Fred Drake00dcfb21998-02-13 07:21:03 +0000613 # This uses a weird HTML construct to adjust the font to be
614 # reasonable match that used in the printed form as much as
615 # possible. The expected behavior is that a browser that doesn't
616 # understand "<font face=...>" markup will use courier (or whatever
617 # the font is for <tt>).
618 local($_) = @_;
619 s/$any_next_pair_pr_rx/`<tt><font face=sans-serif>\2<\/font><\/tt>'/;
620 $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000621}
622
623sub do_cmd_samp{
Fred Drake00dcfb21998-02-13 07:21:03 +0000624 local($_) = @_;
625 s/$any_next_pair_pr_rx/`<samp>\2<\/samp>'/;
626 $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000627}
628
Guido van Rossum9e93fb61994-01-25 20:06:09 +00006291; # This must be the last line