blob: 13f929b2d6f3659066c7333b500264776c90cb08 [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
61sub do_cmd_url{
62 # use the URL as both text and hyperlink
63 local($_) = @_;
Fred Drake00dcfb21998-02-13 07:21:03 +000064 s/$any_next_pair_pr_rx/<tt><a href="\2">\2<\/a><\/tt>/;
Fred Drakebceaf351998-01-22 16:13:44 +000065 $_;
66}
67
68sub do_cmd_manpage{
69 # two parameters: \manpage{name}{section}
70 local($_) = @_;
71 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
72 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<em>\2<\/em>(\4)/;
73 $_;
74}
Fred Drakec384d751996-11-11 16:04:35 +000075
Fred Drake42543631998-02-10 22:11:07 +000076sub do_cmd_rfc{
77 local($_) = @_;
78 s/$next_pair_pr_rx//;
79 local($br_id,$rfcnumber) = ($1, $2);
80
81 # Save the reference
82 local($nstr) = &gen_index_id("RFC!RFC $rfcnumber", '');
83 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
84 "<a name=\"$br_id\">RFC $rfcnumber<\/a>" .$_;
85}
86
Guido van Rossum9e93fb61994-01-25 20:06:09 +000087sub do_cmd_kbd{
Fred Drake00dcfb21998-02-13 07:21:03 +000088 local($_) = @_;
89 s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/;
90 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000091}
92
93sub do_cmd_key{
Fred Drake00dcfb21998-02-13 07:21:03 +000094 local($_) = @_;
95 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
96 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000097}
98
99sub do_cmd_var{
Fred Drake00dcfb21998-02-13 07:21:03 +0000100 local($_) = @_;
101 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
102 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000103}
104
105sub do_cmd_dfn{
Fred Drake00dcfb21998-02-13 07:21:03 +0000106 local($_) = @_;
107 s/$any_next_pair_pr_rx/<i><dfn>\2<\/dfn><\/i>/;
108 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000109}
110
111sub do_cmd_emph{
Fred Drake00dcfb21998-02-13 07:21:03 +0000112 local($_) = @_;
113 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
114 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000115}
116
117sub do_cmd_strong{
Fred Drake00dcfb21998-02-13 07:21:03 +0000118 local($_) = @_;
119 s/$any_next_pair_pr_rx/<b>\2<\/b>/;
120 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000121}
122
Fred Drake7c4cba81997-12-03 19:45:08 +0000123# file and samp are at the end of this file since they screw up fontlock.
124
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000125# index commands
126
Fred Drake42543631998-02-10 22:11:07 +0000127$INDEX_SUBITEM = "";
128
129sub do_cmd_setindexsubitem{
130 local($_) = @_;
131 s/$any_next_pair_pr_rx//;
132 $INDEX_SUBITEM = $2;
133 $_;
134}
135
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000136sub do_cmd_indexii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000137 local($_) = @_;
138 s/$next_pair_pr_rx//o;
139 local($br_id1, $str1) = ($1, $2);
140 s/$next_pair_pr_rx//o;
141 local($br_id2, $str2) = ($1, $2);
142 join('', &make_index_entry($br_id1, "$str1 $str2"),
143 &make_index_entry($br_id2, "$str2, $str1"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000144}
145
146sub do_cmd_indexiii{
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 s/$next_pair_pr_rx//o;
153 local($br_id3, $str3) = ($1, $2);
154 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
155 &make_index_entry($br_id2, "$str2 $str3, $str1"),
156 &make_index_entry($br_id3, "$str3, $str1 $str2"),
157 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000158}
159
160sub do_cmd_indexiv{
Fred Drake00dcfb21998-02-13 07:21:03 +0000161 local($_) = @_;
162 s/$next_pair_pr_rx//o;
163 local($br_id1, $str1) = ($1, $2);
164 s/$next_pair_pr_rx//o;
165 local($br_id2, $str2) = ($1, $2);
166 s/$next_pair_pr_rx//o;
167 local($br_id3, $str3) = ($1, $2);
168 s/$next_pair_pr_rx//o;
169 local($br_id4, $str4) = ($1, $2);
170 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
171 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
172 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
173 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
174 $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000175}
176
Fred Drake00dcfb21998-02-13 07:21:03 +0000177sub do_cmd_ttindex{ &do_cmd_index(@_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000178
179sub my_typed_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000180 local($word, $_) = @_;
181 s/$next_pair_pr_rx//o;
182 local($br_id, $str) = ($1, $2);
183 join('', &make_index_entry($br_id, "$str $word"),
184 &make_index_entry($br_id, "$word, $str"), $_);
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000185}
186
187sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000188sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
189sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
190sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
191
192sub my_parword_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000193 local($word, $_) = @_;
194 s/$next_pair_pr_rx//o;
195 local($br_id, $str) = ($1, $2);
196 &make_index_entry($br_id, "$str ($word)") . $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000197}
198
Fred Drake42543631998-02-10 22:11:07 +0000199
200# Set this to true to strip out the <tt>...</tt> from index entries;
201# this is analogous to using the second definition of \idxcode{} from
202# myformat.sty.
203#
204# It is used from &make_mod_index_entry() and &make_str_index_entry().
205#
206$STRIP_INDEX_TT = 0;
207
Fred Drake25492491998-02-13 15:08:36 +0000208sub make_mod_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000209 local($br_id,$str,$define) = @_;
Fred Drakeab0b65d1998-01-13 04:05:11 +0000210 local($halfref) = &make_half_href("$CURRENT_FILE#$br_id");
211 # If TITLE is not yet available (i.e the \index command is in the title
212 # of the current section), use $ref_before.
Fred Drake84818d71997-12-17 02:59:39 +0000213 $TITLE = $ref_before unless $TITLE;
214 # Save the reference
Fred Drakeab0b65d1998-01-13 04:05:11 +0000215 if ($define eq "DEF") {
216 local($nstr,$garbage) = split / /, $str, 2;
217 $Modules{$nstr} .= $halfref;
218 }
Fred Drake84818d71997-12-17 02:59:39 +0000219 $str = &gen_index_id($str, $define);
Fred Drake42543631998-02-10 22:11:07 +0000220 if ($STRIP_INDEX_TT) {
221 $str =~ s/<tt>(.*)<\/tt>/\1/;
222 }
Fred Drakeab0b65d1998-01-13 04:05:11 +0000223 $index{$str} .= $halfref;
Fred Drake8da9e6a1997-12-18 14:14:16 +0000224 "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
Fred Drake84818d71997-12-17 02:59:39 +0000225}
226
227sub my_module_index_helper{
Fred Drake00dcfb21998-02-13 07:21:03 +0000228 local($word, $_, $define) = @_;
229 s/$next_pair_pr_rx//o;
230 local($br_id, $str) = ($1, $2);
231 &make_mod_index_entry($br_id, "<tt>$str</tt> ($word module)",
232 $define) . $_;
Fred Drake84818d71997-12-17 02:59:39 +0000233}
234
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000235sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
Fred Drake84818d71997-12-17 02:59:39 +0000236sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_, 'DEF'); }
237sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_, 'DEF'); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000238
Fred Drake84818d71997-12-17 02:59:39 +0000239sub do_cmd_refbimodindex{ &my_module_index_helper('built-in', @_, 'REF'); }
240sub do_cmd_refstmodindex{ &my_module_index_helper('standard', @_, 'REF'); }
Fred Drake72df9bc1997-12-16 21:13:20 +0000241
Fred Drakec384d751996-11-11 16:04:35 +0000242sub do_cmd_nodename{ &do_cmd_label(@_); }
243
Fred Drake1af9e791998-01-12 23:15:29 +0000244sub init_myformat{
245 # XXX need some way for this to be called after &initialise;
246 # <<2>>...<<2>>
247 $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
248 $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
249 $any_next_pair_rx7 = "$O(\\d+)$C([\\s\\S]*)$O\\7$C";
250 $any_next_pair_rx9 = "$O(\\d+)$C([\\s\\S]*)$O\\9$C";
251 # <#2#>...<#2#>
252 $any_next_pair_pr_rx_3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
253 $any_next_pair_pr_rx_5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
254 $any_next_pair_pr_rx_7 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP";
255 $any_next_pair_pr_rx_9 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000256}
257
258&init_myformat;
Fred Drakec384d751996-11-11 16:04:35 +0000259
260sub get_indexsubitem{
Fred Drake00dcfb21998-02-13 07:21:03 +0000261 local($result) = $INDEX_SUBITEM;
Fred Drakec384d751996-11-11 16:04:35 +0000262 #print "\nget_indexsubitem ==> $result\n";
Fred Drake9597daf1997-12-22 22:37:34 +0000263 $result ? " $result" : '';
Fred Drakec384d751996-11-11 16:04:35 +0000264}
265
Fred Drake84818d71997-12-17 02:59:39 +0000266# similar to make_index_entry(), but includes the string in the result
267# instead of the dummy filler.
268#
Fred Drake25492491998-02-13 15:08:36 +0000269sub make_str_index_entry{
Fred Drake84818d71997-12-17 02:59:39 +0000270 local($br_id,$str) = @_;
271 # If TITLE is not yet available (i.e the \index command is in the title
272 # of the current section), use $ref_before.
273 $TITLE = $ref_before unless $TITLE;
274 # Save the reference
275 local($nstr) = &gen_index_id($str, '');
Fred Drake42543631998-02-10 22:11:07 +0000276 if ($STRIP_INDEX_TT) {
277 $nstr =~ s/<tt>(.*)<\/tt>/\1/;
278 }
Fred Drake84818d71997-12-17 02:59:39 +0000279 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
280 "<a name=\"$br_id\">$str<\/a>";
281}
282
Fred Drake06e16641998-02-16 22:50:06 +0000283# Changed from the stock version to indent {verbatim} sections:
284sub replace_verbatim {
285 # Modifies $_
286 s/$verbatim_mark(verbatim)(\d+)/<dl><dd><pre>$verbatim{$2}<\/pre><\/dl>/go;
287 s/$verbatim_mark(rawhtml)(\d+)/$verbatim{$2}/ego; # Raw HTML
288}
289
Fred Drake7a7480d1996-10-29 15:56:57 +0000290sub do_env_cfuncdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000291 local($_) = @_;
292 local($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
293 local($cfuncdesc_rx) =
294 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
295 if (/$cfuncdesc_rx/o) {
296 $return_type = "$2";
297 $function_name = "$4";
298 $arg_list = "$6";
299 $idx = &make_str_index_entry($3,
300 "<tt>$function_name</tt>" . &get_indexsubitem);
301 $idx =~ s/ \(.*\)//;
302 }
303 "<dl><dt>$return_type <b>$idx</b>"
304 . "(<var>$arg_list</var>)\n<dd>$'\n</dl>"
Fred Drake7a7480d1996-10-29 15:56:57 +0000305}
306
Fred Drake9dcc5a91997-10-13 22:04:17 +0000307sub do_env_ctypedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000308 local($_) = @_;
309 local($type_name) = ('');
310 local($cfuncdesc_rx) = "$next_pair_rx";
311 if (/$cfuncdesc_rx/o) {
312 $type_name = "$2";
313 $idx = &make_str_index_entry($1,
314 "<tt>$type_name</tt>" . &get_indexsubitem);
315 $idx =~ s/ \(.*\)//;
316 }
317 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake9dcc5a91997-10-13 22:04:17 +0000318}
319
320sub do_env_cvardesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000321 local($_) = @_;
322 local($var_type,$var_name,$idx) = ('', '', '');
323 local($cfuncdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
324 if (/$cfuncdesc_rx/o) {
325 $var_type = "$2";
326 $var_name = "$4";
327 $idx = &make_str_index_entry($3,
328 "<tt>$var_name</tt>" . &get_indexsubitem);
329 $idx =~ s/ \(.*\)//;
330 }
331 "<dl><dt>$var_type <b>$idx</b>\n"
332 . "<dd>$'\n</dl>";
Fred Drake9dcc5a91997-10-13 22:04:17 +0000333}
334
Fred Drakec384d751996-11-11 16:04:35 +0000335sub do_env_funcdesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000336 local($_) = @_;
337 local($function_name,$arg_list,$idx) = ('', '', '');
338 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
339 if (/$funcdesc_rx/o) {
340 $function_name = "$2";
341 $arg_list = "$4";
342 $idx = &make_str_index_entry($3,
343 "<tt>$function_name</tt>" . &get_indexsubitem);
344 $idx =~ s/ \(.*\)//;
345 }
346 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
Fred Drake1af9e791998-01-12 23:15:29 +0000347}
348
Fred Drake25492491998-02-13 15:08:36 +0000349sub do_env_funcdescni{
350 local($_) = @_;
351 local($function_name,$arg_list,$idx) = ('', '', '');
352 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
353 if (/$funcdesc_rx/o) {
354 $function_name = "$2";
355 $arg_list = "$4";
356 if ($STRIP_INDEX_TT) {
357 $idx = $function_name; }
358 else {
359 $idx = "<tt>$function_name</tt>"; }
360 }
361 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
362}
363
Fred Drake1af9e791998-01-12 23:15:29 +0000364sub do_cmd_funcline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000365 local($_) = @_;
366 local($funcdesc_rx) = "$next_pair_pr_rx$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake1af9e791998-01-12 23:15:29 +0000367
Fred Drake00dcfb21998-02-13 07:21:03 +0000368 s/$funcdesc_rx//o;
369 local($br_id, $function_name, $arg_list) = ($3, $2, $4);
370 local($idx) = &make_str_index_entry($br_id, "<tt>$function_name</tt>");
Fred Drake1af9e791998-01-12 23:15:29 +0000371
Fred Drake00dcfb21998-02-13 07:21:03 +0000372 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000373}
374
Fred Drake00dcfb21998-02-13 07:21:03 +0000375# Change this flag to index the opcode entries. I don't think it's very
376# useful to index them, since they're only presented to describe the dis
377# module.
378#
379$INDEX_OPCODES = 0;
380
Fred Drake7c4cba81997-12-03 19:45:08 +0000381sub do_env_opcodedesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000382 local($_) = @_;
383 local($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
384 local($opcodedesc_rx) = "$next_pair_rx$any_next_pair_rx3";
385 if (/$opcodedesc_rx/o) {
386 $opcode_name = "$2";
387 $arg_list = "$4";
388 if ($INDEX_OPCODES) {
389 $idx = &make_str_index_entry($3,
390 "<tt>$opcode_name</tt> (byte code instruction)");
391 $idx =~ s/ \(byte code instruction\)//;
392 }
393 else {
394 $idx = "<tt>$opcode_name</tt>";
395 }
396 }
397 $stuff = "<dl><dt><b>$idx</b>";
398 if ($arg_list) {
399 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
400 }
401 $stuff . "\n<dd>$'\n</dl>";
Fred Drakec384d751996-11-11 16:04:35 +0000402}
403
404sub do_env_datadesc{
Fred Drake00dcfb21998-02-13 07:21:03 +0000405 local($_) = @_;
406 local($idx) = '';
407 if (/$next_pair_rx/o) {
408 $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
409 $idx =~ s/ \(.*\)//;
410 }
411 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
Fred Drake1af9e791998-01-12 23:15:29 +0000412}
413
Fred Drake25492491998-02-13 15:08:36 +0000414sub do_env_datadescni{
415 local($_) = @_;
416 local($idx) = '';
417 if (/$next_pair_rx/o) {
418 if ($STRING_INDEX_TT) {
419 $idx = "$2"; }
420 else {
421 $idx = "<tt>$2</tt>"; }
422 }
423 "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>"
424}
425
Fred Drake1af9e791998-01-12 23:15:29 +0000426sub do_cmd_dataline{
Fred Drake00dcfb21998-02-13 07:21:03 +0000427 local($_) = @_;
Fred Drake1af9e791998-01-12 23:15:29 +0000428
Fred Drake00dcfb21998-02-13 07:21:03 +0000429 s/$next_pair_pr_rx//o;
430 local($br_id, $data_name) = ($1, $2);
431 local($idx) = &make_str_index_entry($br_id, "<tt>$data_name</tt>"
432 . &get_indexsubitem);
433 $idx =~ s/ \(.*\)//;
Fred Drake1af9e791998-01-12 23:15:29 +0000434
Fred Drake00dcfb21998-02-13 07:21:03 +0000435 "<dt><b>$idx</b>\n<dd>" . $_;
Fred Drakec384d751996-11-11 16:04:35 +0000436}
437
438sub do_env_excdesc{ &do_env_datadesc(@_); }
Fred Drake00dcfb21998-02-13 07:21:03 +0000439sub do_env_codesample{ &do_env_verbatim(@_); }
440
Fred Drakec384d751996-11-11 16:04:35 +0000441
Fred Drake9597daf1997-12-22 22:37:34 +0000442@col_aligns = ("<td>", "<td>", "<td>");
443
444sub setup_column_alignments{
Fred Drake00dcfb21998-02-13 07:21:03 +0000445 local($_) = @_;
446 local($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_);
447 local($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
448 $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>");
449 $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>");
450 $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>");
451 # return the aligned header start tags; only used for \begin{tableiii?}
452 $th1 = (($a1 eq "l") ? "<th align=left>"
453 : ($a1 eq "r" ? "<th align=right>" : "<th>"));
454 $th2 = (($a2 eq "l") ? "<th align=left>"
455 : ($a2 eq "r" ? "<th align=right>" : "<th>"));
456 $th3 = (($a3 eq "l") ? "<th align=left>"
457 : ($a3 eq "r" ? "<th align=right>" : "<th>"));
458 ($th1, $th2, $th3);
Fred Drake9597daf1997-12-22 22:37:34 +0000459}
460
461sub do_env_tableii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000462 local($_) = @_;
463 local($font,$h1,$h2) = ('', '', '');
464 local($tableiii_rx) =
465 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7";
466 if (/$tableiii_rx/o) {
467 $font = $4;
468 $h1 = $6;
469 $h2 = $8;
470 }
471 local($th1,$th2,$th3) = &setup_column_alignments($2);
472 $globals{"lineifont"} = $font;
473 "<table border align=center>\n <tr>$th1$h1</th>\n $th2$h2</th>$'\n"
474 . "</table>";
Fred Drake9597daf1997-12-22 22:37:34 +0000475}
476
477sub do_cmd_lineii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000478 local($_) = @_;
479 s/$next_pair_pr_rx//o;
480 local($c1) = $2;
481 s/$next_pair_pr_rx//o;
482 local($c2) = $2;
483 local($font) = $globals{"lineifont"};
484 local($c1align, $c2align) = @col_aligns[0,1];
485 "<tr>$c1align<$font>$c1</$font></td>\n"
486 . " $c2align$c2</td>$'";
Fred Drake9597daf1997-12-22 22:37:34 +0000487}
488
489sub do_env_tableiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000490 local($_) = @_;
491 local($font,$h1,$h2,$h3) = ('', '', '', '');
Fred Drake1af9e791998-01-12 23:15:29 +0000492
Fred Drake00dcfb21998-02-13 07:21:03 +0000493 local($tableiii_rx) =
494 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"
495 . "$any_next_pair_rx9";
496 if (/$tableiii_rx/o) {
497 $font = $4;
498 $h1 = $6;
499 $h2 = $8;
500 $h3 = $10;
501 }
502 local($th1,$th2,$th3) = &setup_column_alignments($2);
503 $globals{"lineifont"} = $font;
504 "<table border align=center>\n <tr>$th1$h1</th>\n $th2$h2</th>"
505 . "\n $th3$h3</th>$'\n"
506 . "</table>";
Fred Drake9597daf1997-12-22 22:37:34 +0000507}
508
509sub do_cmd_lineiii{
Fred Drake00dcfb21998-02-13 07:21:03 +0000510 local($_) = @_;
511 s/$next_pair_pr_rx//o;
512 local($c1) = $2;
513 s/$next_pair_pr_rx//o;
514 local($c2) = $2;
515 s/$next_pair_pr_rx//o;
516 local($c3) = $2;
517 local($font) = $globals{"lineifont"};
518 local($c1align, $c2align, $c3align) = @col_aligns;
519 "<tr>$c1align<$font>$c1</$font></td>\n"
520 . " $c2align$c2</td>\n"
521 . " $c3align$c3</td>$'";
Fred Drake9597daf1997-12-22 22:37:34 +0000522}
523
Fred Drake9dcc5a91997-10-13 22:04:17 +0000524sub do_env_seealso{
Fred Drake00dcfb21998-02-13 07:21:03 +0000525 "<p><b>See Also:</b></p>\n" . @_[0];
Fred Drake9dcc5a91997-10-13 22:04:17 +0000526}
527
528sub do_cmd_seemodule{
Fred Drake00dcfb21998-02-13 07:21:03 +0000529 local($_) = @_;
530 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
531 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<p><tt><b>\2<\/b><\/tt> (\4)<\/p>/;
532 $_;
Fred Drake9dcc5a91997-10-13 22:04:17 +0000533}
534
535sub do_cmd_seetext{
Fred Drake00dcfb21998-02-13 07:21:03 +0000536 "<p>" . @_[0];
Fred Drake9dcc5a91997-10-13 22:04:17 +0000537}
538
Fred Drake7c4cba81997-12-03 19:45:08 +0000539# These are located down here since they screw up fontlock.
540
541sub do_cmd_file{
Fred Drake00dcfb21998-02-13 07:21:03 +0000542 # This uses a weird HTML construct to adjust the font to be
543 # reasonable match that used in the printed form as much as
544 # possible. The expected behavior is that a browser that doesn't
545 # understand "<font face=...>" markup will use courier (or whatever
546 # the font is for <tt>).
547 local($_) = @_;
548 s/$any_next_pair_pr_rx/`<tt><font face=sans-serif>\2<\/font><\/tt>'/;
549 $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000550}
551
552sub do_cmd_samp{
Fred Drake00dcfb21998-02-13 07:21:03 +0000553 local($_) = @_;
554 s/$any_next_pair_pr_rx/`<samp>\2<\/samp>'/;
555 $_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000556}
557
Guido van Rossum9e93fb61994-01-25 20:06:09 +00005581; # This must be the last line