blob: 4c1f2f782529a62690b05a6e9e74c4be2284a546 [file] [log] [blame]
Fred Drake6659c301998-03-03 22:02:19 +00001# python.perl by Fred L. Drake, Jr. <fdrake@acm.org> -*- perl -*-
2#
3# Heavily based on Guido van Rossum's myformat.perl (now obsolete).
4#
5# Extension to LaTeX2HTML for documents using myformat.sty.
6# Subroutines of the form do_cmd_<name> here define translations
7# for LaTeX commands \<name> defined in the corresponding .sty file.
8
9package main;
10
11
12# words typeset in a special way (not in HTML though)
13
14sub do_cmd_ABC{ 'ABC' . @_[0]; }
15sub do_cmd_UNIX{ 'Unix'. @_[0]; }
16sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
17sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
18sub do_cmd_C{ 'C' . @_[0]; }
19sub do_cmd_Cpp{ 'C++' . @_[0]; }
20sub do_cmd_EOF{ 'EOF' . @_[0]; }
21sub do_cmd_NULL{ '<tt>NULL</tt>' . @_[0]; }
22
23sub do_cmd_e{ '&#92;' . @_[0]; }
24
25$AUTHOR_ADDRESS = '';
26$PYTHON_VERSION = '';
27
28sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
29sub do_cmd_release{
30 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000031 s/$next_pair_pr_rx//;
Fred Drake6659c301998-03-03 22:02:19 +000032 $PYTHON_VERSION = "$2";
33 $_;
34}
35
36sub do_cmd_authoraddress{
37 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000038 s/$next_pair_pr_rx//;
Fred Drake6659c301998-03-03 22:02:19 +000039 $AUTHOR_ADDRESS = "$2";
40 $_;
41}
42
43sub do_cmd_hackscore{
44 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000045 s/$next_pair_pr_rx/_/;
Fred Drake6659c301998-03-03 22:02:19 +000046 $_;
47}
48
49sub do_cmd_optional{
50 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000051 s|$next_pair_pr_rx|</var><big>\[</big><var>\2</var><big>\]</big><var>|;
Fred Drake6659c301998-03-03 22:02:19 +000052 $_;
53}
54
55sub do_cmd_varvars{
56 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000057 s|$next_pair_pr_rx|<var>\2</var>|;
Fred Drake6659c301998-03-03 22:02:19 +000058 $_;
59}
60
Fred Drakec9a44381998-03-17 06:29:13 +000061# Logical formatting (some based on texinfo), needs to be converted to
62# minimalist HTML. The "minimalist" is primarily to reduce the size of
63# output files for users that read them over the network rather than
64# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +000065
66sub do_cmd_code{
67 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +000068 s|$next_pair_pr_rx|<tt>\2</tt>|;
69 $_;
70}
71
72sub use_sans_serif{
73 local($_) = @_;
74 s|$next_pair_pr_rx|<font face=sans-serif>\2</font>|;
75 $_;
76}
77
78sub use_italics{
79 local($_) = @_;
80 s|$next_pair_pr_rx|<i>\2</i>|;
Fred Drake6659c301998-03-03 22:02:19 +000081 $_;
82}
83
84sub do_cmd_sectcode{ &do_cmd_code(@_); }
85sub do_cmd_module{ &do_cmd_code(@_); }
86sub do_cmd_keyword{ &do_cmd_code(@_); }
87sub do_cmd_exception{ &do_cmd_code(@_); }
88sub do_cmd_class{ &do_cmd_code(@_); }
89sub do_cmd_function{ &do_cmd_code(@_); }
90sub do_cmd_constant{ &do_cmd_code(@_); }
91sub do_cmd_member{ &do_cmd_code(@_); }
92sub do_cmd_method{ &do_cmd_code(@_); }
Fred Drake6659c301998-03-03 22:02:19 +000093sub do_cmd_cfunction{ &do_cmd_code(@_); }
94sub do_cmd_cdata{ &do_cmd_code(@_); }
95sub do_cmd_ctype{ &do_cmd_code(@_); }
Fred Drakec9a44381998-03-17 06:29:13 +000096sub do_cmd_regexp{ &do_cmd_code(@_); }
97sub do_cmd_key{ &do_cmd_code(@_); }
Fred Drake6659c301998-03-03 22:02:19 +000098
Fred Drakefc16e781998-03-12 21:03:26 +000099sub do_cmd_character{ &do_cmd_samp(@_); }
100
Fred Drakec9a44381998-03-17 06:29:13 +0000101sub do_cmd_program{ &do_cmd_strong(@_); }
102
103sub do_cmd_email{ &use_sans_serif(@_); }
104sub do_cmd_mimetype{ &use_sans_serif(@_); }
105
106sub do_cmd_var{ &use_italics(@_); }
Fred Drake42b31a51998-03-27 05:16:10 +0000107sub do_cmd_dfn{ &use_italics(@_); } # make an index entry?
Fred Drakec9a44381998-03-17 06:29:13 +0000108sub do_cmd_emph{ &use_italics(@_); }
109
Fred Drake1a7af391998-04-01 22:44:56 +0000110sub do_cmd_newsgroup{
111 local($_) = @_;
112 s/$next_pair_pr_rx//o;
113 my $newsgroup = $2;
114 my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>"
115 . "$newsgroup</font></a>";
116 $stuff . $_;
117}
Fred Drakefc16e781998-03-12 21:03:26 +0000118
119sub do_cmd_envvar{
120 local($_) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000121 s/$next_pair_pr_rx//;
122 my($br_id,$envvar) = ($1, $2);
123 my($name,$aname,$ahref) = link_info($br_id);
124 add_index_entry("environment variables!$envvar@\$$envvar", $ahref);
125 add_index_entry("$envvar@\$$envvar", $ahref);
126 "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000127}
128
Fred Drake6659c301998-03-03 22:02:19 +0000129sub do_cmd_url{
130 # use the URL as both text and hyperlink
131 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000132 s/$next_pair_pr_rx//;
133 my $url = $2;
Fred Drake6659c301998-03-03 22:02:19 +0000134 $url =~ s/~/&#126;/g;
Fred Drakec9a44381998-03-17 06:29:13 +0000135 "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000136}
137
138sub do_cmd_manpage{
139 # two parameters: \manpage{name}{section}
140 local($_) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000141 my $rx = "$next_pair_pr_rx$any_next_pair_pr_rx3";
142 s|$rx|<i>\2</i>(\4)|;
Fred Drake6659c301998-03-03 22:02:19 +0000143 $_;
144}
145
146sub do_cmd_rfc{
147 local($_) = @_;
148 s/$next_pair_pr_rx//;
Fred Drakec9a44381998-03-17 06:29:13 +0000149 my($br_id,$rfcnumber) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000150
151 # Save the reference
Fred Drakec9a44381998-03-17 06:29:13 +0000152 my $nstr = &gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drake6659c301998-03-03 22:02:19 +0000153 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
Fred Drakec9a44381998-03-17 06:29:13 +0000154 "<a name=$br_id>RFC $rfcnumber</a>" .$_;
Fred Drake6659c301998-03-03 22:02:19 +0000155}
156
157sub do_cmd_kbd{
158 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000159 s|$next_pair_pr_rx|<kbd>\2</kbd>|;
Fred Drake6659c301998-03-03 22:02:19 +0000160 $_;
161}
162
163sub do_cmd_strong{
164 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000165 s|$next_pair_pr_rx|<b>\2</b>|;
Fred Drake6659c301998-03-03 22:02:19 +0000166 $_;
167}
168
169sub do_cmd_deprecated{
170 # two parameters: \deprecated{version}{whattodo}
171 local($_) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000172 my $rx = "$next_pair_pr_rx$any_next_pair_pr_rx3";
173 s|$rx|<b>Deprecated since release \2.</b>\n\4<p>|;
174 $_;
Fred Drake6659c301998-03-03 22:02:19 +0000175}
176
177# file and samp are at the end of this file since they screw up fontlock.
178
179# index commands
180
181$INDEX_SUBITEM = "";
182
183sub get_indexsubitem{
Fred Drakefc16e781998-03-12 21:03:26 +0000184 #$INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
185 '';
Fred Drake6659c301998-03-03 22:02:19 +0000186}
187
188sub do_cmd_setindexsubitem{
189 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000190 s/$next_pair_pr_rx//;
Fred Drake6659c301998-03-03 22:02:19 +0000191 $INDEX_SUBITEM = $2;
192 $_;
193}
194
Fred Drakefc16e781998-03-12 21:03:26 +0000195sub do_cmd_withsubitem{
196 # We can't really do the right right thing, because LaTeX2HTML doesn't
197 # do things in the right order, but we need to at least strip this stuff
198 # out, and leave anything that the second argument expanded out to.
199 #
200 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000201 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drakefc16e781998-03-12 21:03:26 +0000202 s/$next_pair_pr_rx$any_next_pair_pr_rx3/\4/;
Fred Drake42b31a51998-03-27 05:16:10 +0000203 $INDEX_SUBITEM = $2;
Fred Drakefc16e781998-03-12 21:03:26 +0000204 $_;
205}
206
207sub do_cmd_makemodindex{ @_[0]; }
208
Fred Drake42b31a51998-03-27 05:16:10 +0000209# We're in the document subdirectory when this happens!
210open(IDXFILE, ">index.dat") || die "\n$!\n";
211open(INTLABELS, ">intlabels.pl") || die "\n$!\n";
212print INTLABELS
213 "%internal_labels = ();\n1; # hack in case there are no entries\n\n";
214
215sub gen_target_name{
216 "l2h-" . @_[0];
217}
218
219sub gen_target{
220 "<a name=\"" . @_[0] . "\">";
221}
222
223sub gen_link{
224 my($node,$target) = @_;
225 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
226 "<a href=\"$node#$target\">";
227}
228
229sub make_index_entry{
230 my($br_id,$str) = @_;
231 my($name,$aname,$ahref) = link_info($br_id);
232 add_index_entry($str, $ahref);
233 "$aname$anchor_invisible_mark</a>";
234}
235
236sub add_index_entry{
237 # add an entry to the index structures; ignore the return value
238 my($str,$ahref) = @_;
239 $str = gen_index_id($str, '');
240 $index{$str} .= $ahref;
241 print IDXFILE $ahref, "\0", $str, "\n";
242}
243
244sub link_info{
245 my $name = gen_target_name(@_[0]);
246 my $aname = gen_target($name);
247 my $ahref = gen_link($CURRENT_FILE, $name);
248 return ($name, $aname, $ahref);
249}
250
251sub do_cmd_index{
252 local($_) = @_;
253 s/$next_pair_pr_rx[\n]?//o;
254 my($br_id,$str) = ($1, $2);
255 #
256 my($name,$aname,$ahref) = link_info($br_id);
257 add_index_entry("$str", $ahref);
258 "$aname$anchor_invisible_mark</a>" . $_;
259}
260
Fred Drake6659c301998-03-03 22:02:19 +0000261sub do_cmd_indexii{
262 local($_) = @_;
263 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000264 my($br_id1,$str1) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000265 s/$next_pair_pr_rx[\n]?//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000266 my($br_id2,$str2) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000267 #
268 my($name,$aname,$ahref) = link_info($br_id1);
269 add_index_entry("$str1!$str2", $ahref);
270 add_index_entry("$str2!$str1", $ahref);
271 "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000272}
273
274sub do_cmd_indexiii{
275 local($_) = @_;
276 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000277 my($br_id1,$str1) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000278 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000279 my($br_id2,$str2) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000280 s/$next_pair_pr_rx[\n]?//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000281 my($br_id3,$str3) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000282 #
283 my($name,$aname,$ahref) = link_info($br_id1);
284 add_index_entry("$str1!$str2 $str3", $ahref);
285 add_index_entry("$str2!$str3, $str1", $ahref);
286 add_index_entry("$str3!$str1 $str2", $ahref);
287 "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000288}
289
290sub do_cmd_indexiv{
291 local($_) = @_;
292 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000293 my($br_id1,$str1) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000294 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000295 my($br_id2,$str2) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000296 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000297 my($br_id3,$str3) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000298 s/$next_pair_pr_rx[\n]?//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000299 my($br_id4,$str4) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000300 #
301 my($name,$aname,$ahref) = link_info($br_id1);
302 add_index_entry("$str1!$str2 $str3 $str4", $ahref);
303 add_index_entry("$str2!$str3 $str4, $str1", $ahref);
304 add_index_entry("$str3!$str4, $str1 $str2", $ahref);
305 add_index_entry("$str4!$$str1 $str2 $str3", $ahref);
306 "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000307}
308
Fred Drakec9a44381998-03-17 06:29:13 +0000309sub do_cmd_ttindex{
310 local($_) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000311 s/$next_pair_pr_rx[\n]?//;
Fred Drakec9a44381998-03-17 06:29:13 +0000312 my($br_id,$str) = ($1, $2);
313 &make_index_entry($br_id, $str . &get_indexsubitem) . $_;
314}
Fred Drake6659c301998-03-03 22:02:19 +0000315
316sub my_typed_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000317 local($word,$_) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000318 s/$next_pair_pr_rx[\n]?//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000319 my($br_id,$str) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000320 #
321 my($name,$aname,$ahref) = link_info($br_id1);
322 add_index_entry("$str $word", $ahref);
323 add_index_entry("$word!$str", $ahref);
324 "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000325}
326
327sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
328sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
329sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
330sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
331
332sub my_parword_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000333 local($word,$_) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000334 s/$next_pair_pr_rx[\n]?//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000335 my($br_id,$str) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000336 make_index_entry($br_id, "$str ($word)") . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000337}
338
339
340# Set this to true to strip out the <tt>...</tt> from index entries;
341# this is analogous to using the second definition of \idxcode{} from
342# myformat.sty.
343#
344# It is used from &make_mod_index_entry() and &make_str_index_entry().
345#
346$STRIP_INDEX_TT = 0;
347
348sub make_mod_index_entry{
Fred Drakec9a44381998-03-17 06:29:13 +0000349 my($br_id,$str,$define) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000350 my($name,$aname,$ahref) = link_info($br_id);
351 $str =~ s|<tt>(.*)</tt>|\1|
352 if $STRIP_INDEX_TT;
353 # equivalent of add_index_entry() using $define instead of ''
354 $str = gen_index_id($str, $define);
355 $index{$str} .= $ahref;
356 print IDXFILE $ahref, "\0", $str, "\n";
357
Fred Drakec9a44381998-03-17 06:29:13 +0000358 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000359 # add to the module index
Fred Drakec9a44381998-03-17 06:29:13 +0000360 my($nstr,$garbage) = split / /, $str, 2;
Fred Drake42b31a51998-03-27 05:16:10 +0000361 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000362 }
Fred Drake42b31a51998-03-27 05:16:10 +0000363 "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000364}
365
Fred Drakec9a44381998-03-17 06:29:13 +0000366$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000367$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000368
Fred Drake6659c301998-03-03 22:02:19 +0000369sub my_module_index_helper{
370 local($word, $_) = @_;
371 s/$next_pair_pr_rx[\n]*//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000372 my($br_id, $str) = ($1, $2);
373 my $section_tag = join('', @curr_sec_id);
Fred Drake6659c301998-03-03 22:02:19 +0000374 $word = "$word " if $word;
Fred Drakec9a44381998-03-17 06:29:13 +0000375 $THIS_MODULE = "$str";
Fred Drake42b31a51998-03-27 05:16:10 +0000376 make_mod_index_entry("SECTION$section_tag",
377 "<tt>$str</tt> (${word}module)", 'DEF') . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000378}
379
380sub ref_module_index_helper{
381 local($word, $_) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000382 s/$next_pair_pr_rx[\n]?//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000383 my($br_id, $str) = ($1, $2);
Fred Drake6659c301998-03-03 22:02:19 +0000384 $word = "$word " if $word;
Fred Drake42b31a51998-03-27 05:16:10 +0000385 make_mod_index_entry($br_id, "<tt>$str</tt> (${word}module)", 'REF') . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000386}
387
Fred Drakec9a44381998-03-17 06:29:13 +0000388sub do_cmd_bifuncindex{
389 local($_) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000390 s/$next_pair_pr_rx[\n]?//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000391 my($br_id,$str,$fname) = ($1, $2, "<tt>$2()</tt>");
392 $fname = "$str()"
393 if $STRIP_INDEX_TT;
Fred Drake42b31a51998-03-27 05:16:10 +0000394 make_index_entry($br_id, "$fname (built-in function)") . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000395}
396
Fred Drake42b31a51998-03-27 05:16:10 +0000397sub do_cmd_modindex{ my_module_index_helper('', @_); }
398sub do_cmd_bimodindex{ my_module_index_helper('built-in', @_); }
399sub do_cmd_exmodindex{ my_module_index_helper('extension', @_); }
400sub do_cmd_stmodindex{ my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000401
402# these should be adjusted a bit....
Fred Drake42b31a51998-03-27 05:16:10 +0000403sub do_cmd_refmodindex{ ref_module_index_helper('', @_); }
404sub do_cmd_refbimodindex{ ref_module_index_helper('built-in', @_); }
405sub do_cmd_refexmodindex{ ref_module_index_helper('extension', @_); }
406sub do_cmd_refstmodindex{ ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000407
Fred Drake42b31a51998-03-27 05:16:10 +0000408sub do_cmd_nodename{ do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000409
410sub init_myformat{
411 # XXX need some way for this to be called after &initialise; ???
412 $anchor_mark = '';
413 $icons{'anchor_mark'} = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000414 my $cmark = "(?:$comment_mark)?";
Fred Drake6659c301998-03-03 22:02:19 +0000415 # <<2>>...<<2>>
Fred Drake42b31a51998-03-27 05:16:10 +0000416 $next_pair_rx = "^[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\1$C";
417 $any_next_pair_rx3 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\3$C";
418 $any_next_pair_rx5 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\5$C";
419 $any_next_pair_rx7 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\7$C";
420 $any_next_pair_rx9 = "[\\s\n%]*$O(\\d+)$C([\\s\\S]*)$O\\9$C";
Fred Drake6659c301998-03-03 22:02:19 +0000421 # <#2#>...<#2#>
Fred Drake42b31a51998-03-27 05:16:10 +0000422 $next_pair_pr_rx = "^[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\1$CP$cmark";
423 $any_next_pair_pr_rx3 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP$cmark";
424 $any_next_pair_pr_rx5 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP$cmark";
425 $any_next_pair_pr_rx7 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP$cmark";
426 $any_next_pair_pr_rx9 = "[\\s\n%]*$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP$cmark";
Fred Drake6659c301998-03-03 22:02:19 +0000427}
Fred Drake42b31a51998-03-27 05:16:10 +0000428init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000429
430# similar to make_index_entry(), but includes the string in the result
431# instead of the dummy filler.
432#
433sub make_str_index_entry{
Fred Drakec9a44381998-03-17 06:29:13 +0000434 my($br_id,$str) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000435 my($name,$aname,$ahref) = link_info($br_id);
436 $str =~ s|<tt>(.*)</tt>|\1|
437 if $STRIP_INDEX_TT;
438 add_index_entry($str, $ahref);
439 "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000440}
441
442# Changed from the stock version to indent {verbatim} sections,
443# and make them smaller, to better match the LaTeX version:
444
445# (Used with LaTeX2HTML 96.1*)
446sub replace_verbatim {
447 # Modifies $_
Fred Drakec9a44381998-03-17 06:29:13 +0000448 my($prefix,$suffix) = ("\n<p><dl><dd><pre>\n", "</pre></dl>");
Fred Drake6659c301998-03-03 22:02:19 +0000449 s/$verbatim_mark(verbatim)(\d+)/$prefix$verbatim{$2}$suffix/go;
450 s/$verbatim_mark(rawhtml)(\d+)/$verbatim{$2}/ego; # Raw HTML
451}
452
453# (Used with LaTeX2HTML 98.1)
Fred Drake42b31a51998-03-27 05:16:10 +0000454# The HTML this produces is bad; the <PRE> is on the outside of the <dl>,
455# but I haven't found a workaround yet.
Fred Drake6659c301998-03-03 22:02:19 +0000456sub replace_verbatim_hook{
457 # Modifies $_
Fred Drakec9a44381998-03-17 06:29:13 +0000458 my($prefix,$suffix) = ("\n<p><dl><dd>", "</dl>");
Fred Drake6659c301998-03-03 22:02:19 +0000459 s/$math_verbatim_rx/&put_comment("MATH: ".$verbatim{$1})/eg;
460 s/$verbatim_mark(\w*[vV]erbatim\*?)(\d+)\#/$prefix$verbatim{$2}$suffix/go;
461 # Raw HTML, but replacements may have protected characters
462 s/$verbatim_mark(rawhtml)(\d+)#/&unprotect_raw_html($verbatim{$2})/eg;
463 s/$verbatim_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX
464 s/$unfinished_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX
465}
466
467sub do_env_cfuncdesc{
468 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000469 my($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
470 my $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
471 my $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C";
472 my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
Fred Drake6659c301998-03-03 22:02:19 +0000473 if (/$cfuncdesc_rx/o) {
474 $return_type = "$2";
475 $function_name = "$4";
476 $arg_list = "$6";
Fred Drake42b31a51998-03-27 05:16:10 +0000477 $idx = make_str_index_entry($3,
Fred Drakec9a44381998-03-17 06:29:13 +0000478 "<tt>$function_name()</tt>" . &get_indexsubitem);
Fred Drake6659c301998-03-03 22:02:19 +0000479 $idx =~ s/ \(.*\)//;
Fred Drakec9a44381998-03-17 06:29:13 +0000480 $idx =~ s/\(\)//;
Fred Drake6659c301998-03-03 22:02:19 +0000481 }
482 "<dl><dt>$return_type <b>$idx</b>"
Fred Drake42b31a51998-03-27 05:16:10 +0000483 . "(<var>$arg_list</var>)\n<dd>$'</dl>"
Fred Drake6659c301998-03-03 22:02:19 +0000484}
485
486sub do_env_ctypedesc{
487 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000488 my $type_name = ('');
489 my $cfuncdesc_rx = "$next_pair_rx";
Fred Drake6659c301998-03-03 22:02:19 +0000490 if (/$cfuncdesc_rx/o) {
491 $type_name = "$2";
Fred Drake42b31a51998-03-27 05:16:10 +0000492 $idx = make_str_index_entry($1,
Fred Drake6659c301998-03-03 22:02:19 +0000493 "<tt>$type_name</tt>" . &get_indexsubitem);
494 $idx =~ s/ \(.*\)//;
495 }
Fred Drake42b31a51998-03-27 05:16:10 +0000496 "<dl><dt><b>$idx</b>\n<dd>$'</dl>"
Fred Drake6659c301998-03-03 22:02:19 +0000497}
498
499sub do_env_cvardesc{
500 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000501 my($var_type,$var_name,$idx) = ('', '', '');
502 my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3";
Fred Drake6659c301998-03-03 22:02:19 +0000503 if (/$cfuncdesc_rx/o) {
504 $var_type = "$2";
505 $var_name = "$4";
Fred Drake42b31a51998-03-27 05:16:10 +0000506 $idx = make_str_index_entry($3,
Fred Drake6659c301998-03-03 22:02:19 +0000507 "<tt>$var_name</tt>" . &get_indexsubitem);
508 $idx =~ s/ \(.*\)//;
509 }
510 "<dl><dt>$var_type <b>$idx</b>\n"
Fred Drake42b31a51998-03-27 05:16:10 +0000511 . "<dd>$'</dl>";
Fred Drake6659c301998-03-03 22:02:19 +0000512}
513
514sub do_env_funcdesc{
515 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000516 my($function_name,$arg_list,$idx) = ('', '', '');
517 my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3";
Fred Drake6659c301998-03-03 22:02:19 +0000518 if (/$funcdesc_rx/o) {
519 $function_name = "$2";
520 $arg_list = "$4";
Fred Drake42b31a51998-03-27 05:16:10 +0000521 $idx = make_str_index_entry($3, "<tt>$function_name()</tt>"
Fred Drakec9a44381998-03-17 06:29:13 +0000522 . &get_indexsubitem);
Fred Drake6659c301998-03-03 22:02:19 +0000523 $idx =~ s/ \(.*\)//;
Fred Drakec9a44381998-03-17 06:29:13 +0000524 $idx =~ s/\(\)//;
Fred Drake6659c301998-03-03 22:02:19 +0000525 }
Fred Drake42b31a51998-03-27 05:16:10 +0000526 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
Fred Drake6659c301998-03-03 22:02:19 +0000527}
528
529sub do_env_funcdescni{
530 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000531 my($function_name,$arg_list,$idx) = ('', '', '');
532 my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3";
Fred Drake6659c301998-03-03 22:02:19 +0000533 if (/$funcdesc_rx/o) {
534 $function_name = "$2";
535 $arg_list = "$4";
536 if ($STRIP_INDEX_TT) {
Fred Drakec9a44381998-03-17 06:29:13 +0000537 $idx = "$function_name"; }
Fred Drake6659c301998-03-03 22:02:19 +0000538 else {
539 $idx = "<tt>$function_name</tt>"; }
540 }
Fred Drake42b31a51998-03-27 05:16:10 +0000541 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
Fred Drake6659c301998-03-03 22:02:19 +0000542}
543
544sub do_cmd_funcline{
545 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000546 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake6659c301998-03-03 22:02:19 +0000547
Fred Drakec9a44381998-03-17 06:29:13 +0000548 s/$next_pair_pr_rx//o;
549 my $function_name = $2;
550 s/$next_pair_pr_rx//o;
551 my($br_id,$arg_list) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000552 my $idx = make_str_index_entry($br_id, "<tt>$function_name()</tt>"
553 . &get_indexsubitem);
Fred Drakec9a44381998-03-17 06:29:13 +0000554 $idx =~ s/\(\)//;
Fred Drake6659c301998-03-03 22:02:19 +0000555
556 "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
557}
558
559# Change this flag to index the opcode entries. I don't think it's very
560# useful to index them, since they're only presented to describe the dis
561# module.
562#
563$INDEX_OPCODES = 0;
564
565sub do_env_opcodedesc{
566 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000567 my($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
Fred Drakec9a44381998-03-17 06:29:13 +0000568 my $opcodedesc_rx = "$next_pair_rx$any_next_pair_rx3";
Fred Drake6659c301998-03-03 22:02:19 +0000569 if (/$opcodedesc_rx/o) {
570 $opcode_name = "$2";
571 $arg_list = "$4";
572 if ($INDEX_OPCODES) {
Fred Drake42b31a51998-03-27 05:16:10 +0000573 $idx = make_str_index_entry($3,
Fred Drake6659c301998-03-03 22:02:19 +0000574 "<tt>$opcode_name</tt> (byte code instruction)");
575 $idx =~ s/ \(byte code instruction\)//;
576 }
577 else {
578 $idx = "<tt>$opcode_name</tt>";
579 }
580 }
581 $stuff = "<dl><dt><b>$idx</b>";
582 if ($arg_list) {
583 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
584 }
Fred Drake42b31a51998-03-27 05:16:10 +0000585 $stuff . "\n<dd>$'</dl>";
Fred Drake6659c301998-03-03 22:02:19 +0000586}
587
588sub do_env_datadesc{
589 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000590 my $idx = '';
Fred Drake6659c301998-03-03 22:02:19 +0000591 if (/$next_pair_rx/o) {
Fred Drake42b31a51998-03-27 05:16:10 +0000592 $idx = make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem);
Fred Drake6659c301998-03-03 22:02:19 +0000593 $idx =~ s/ \(.*\)//;
594 }
Fred Drake42b31a51998-03-27 05:16:10 +0000595 "<dl><dt><b>$idx</b>\n<dd>$'</dl>"
Fred Drake6659c301998-03-03 22:02:19 +0000596}
597
598sub do_env_datadescni{
599 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000600 my $idx = '';
Fred Drake6659c301998-03-03 22:02:19 +0000601 if (/$next_pair_rx/o) {
602 if ($STRING_INDEX_TT) {
603 $idx = "$2"; }
604 else {
605 $idx = "<tt>$2</tt>"; }
606 }
Fred Drake42b31a51998-03-27 05:16:10 +0000607 "<dl><dt><b>$idx</b>\n<dd>$'</dl>"
Fred Drake6659c301998-03-03 22:02:19 +0000608}
609
610sub do_cmd_dataline{
611 local($_) = @_;
612
613 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000614 my($br_id, $data_name) = ($1, $2);
Fred Drake42b31a51998-03-27 05:16:10 +0000615 my $idx = make_str_index_entry($br_id, "<tt>$data_name</tt>"
616 . &get_indexsubitem);
Fred Drake6659c301998-03-03 22:02:19 +0000617 $idx =~ s/ \(.*\)//;
618
Fred Drake42b31a51998-03-27 05:16:10 +0000619 "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000620}
621
Fred Drake42b31a51998-03-27 05:16:10 +0000622sub do_env_excdesc{
623 local($_) = @_;
624 /$next_pair_rx/o;
625 my($br_id,$excname,$rest) = ($1, $2, $');
626 my $idx = make_str_index_entry($br_id,
627 "<tt>$excname</tt> (exception in $THIS_MODULE)");
628 $idx =~ s/ \(.*\)//;
629 "<dl><dt><b>$idx</b>\n<dd>$rest</dl>"
630}
631
632sub do_env_fulllineitems{ do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000633
634
Fred Drakec9a44381998-03-17 06:29:13 +0000635sub do_env_classdesc{
636 local($_) = @_;
Fred Drake42b31a51998-03-27 05:16:10 +0000637 my($class_name,$arg_list,$idx) = ('', '', '');
Fred Drakec9a44381998-03-17 06:29:13 +0000638 my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3";
639 if (/$funcdesc_rx/o) {
Fred Drake42b31a51998-03-27 05:16:10 +0000640 $class_name = "$2";
Fred Drakec9a44381998-03-17 06:29:13 +0000641 $arg_list = "$4";
Fred Drake42b31a51998-03-27 05:16:10 +0000642 $THIS_CLASS = $class_name;
643 $idx = make_str_index_entry($3,
644 "<tt>$class_name</tt> (class in $THIS_MODULE)" );
Fred Drakec9a44381998-03-17 06:29:13 +0000645 $idx =~ s/ \(.*\)//;
646 }
Fred Drake42b31a51998-03-27 05:16:10 +0000647 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
Fred Drakec9a44381998-03-17 06:29:13 +0000648}
649
Fred Drake42b31a51998-03-27 05:16:10 +0000650
651sub do_env_methoddesc{
652 local($_) = @_;
653 my($class_name,$arg_list,$idx,$extra);
654 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
655 # require the argument to be there.
656 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
657 my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3$any_next_pair_rx5";
658 if (/$funcdesc_rx/o) {
659 $class_name = $2;
660 $class_name = $THIS_CLASS
661 unless $class_name;
662 $method_name = $4;
663 $arg_list = $6;
664 if ($class_name) {
665 $extra = " ($class_name method)";
666 }
667 $idx = make_str_index_entry($3, "<tt>$method_name()</tt>$extra");
668 $idx =~ s/ \(.*\)//;
669 $idx =~ s/\(\)//;
670 }
671 "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
672}
673
674
675sub do_env_methoddescni{
676 local($_) = @_;
677 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
678 # require the argument to be there.
679 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
680 my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3$any_next_pair_rx5";
681 /$funcdesc_rx/o;
682 my $method = $4;
683 my $arg_list = $6;
684 "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>$'</dl>";
685}
686
687
688sub do_env_memberdesc{
689 local($_) = @_;
690 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
691 # require the argument to be there.
692 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
693 my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3$any_next_pair_rx5";
694 /$funcdesc_rx/o;
695 my($class,$member,$arg_list) = ($2, $4, $6);
696 $class = $THIS_CLASS
697 unless $class;
698 $extra = " ($class_name attribute)"
699 if $class;
700 my $idx = make_str_index_entry($3, "<tt>$member()</tt>$extra");
701 $idx =~ s/ \(.*\)//;
702 $idx =~ s/\(\)//;
703 "<dl><dt><b>$idx</b>\n<dd>$'</dl>";
704}
705
706
707sub do_env_memberdescni{
708 local($_) = @_;
709 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
710 # require the argument to be there.
711 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
712 my $funcdesc_rx = "$opt_arg_rx$any_next_pair_rx3";
713 /$funcdesc_rx/o;
714 my $member = $4;
715 "<dl><dt><b>$member</b>\n<dd>$'</dl>";
716}
717
718
Fred Drake6659c301998-03-03 22:02:19 +0000719@col_aligns = ("<td>", "<td>", "<td>");
720
721sub setup_column_alignments{
722 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000723 my($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_);
724 my($th1,$th2,$th3) = ('<th>', '<th>', '<th>');
Fred Drake6659c301998-03-03 22:02:19 +0000725 $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>");
726 $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>");
727 $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>");
728 # return the aligned header start tags; only used for \begin{tableiii?}
729 $th1 = (($a1 eq "l") ? "<th align=left>"
730 : ($a1 eq "r" ? "<th align=right>" : "<th>"));
731 $th2 = (($a2 eq "l") ? "<th align=left>"
732 : ($a2 eq "r" ? "<th align=right>" : "<th>"));
733 $th3 = (($a3 eq "l") ? "<th align=left>"
734 : ($a3 eq "r" ? "<th align=right>" : "<th>"));
735 ($th1, $th2, $th3);
736}
737
738sub do_env_tableii{
739 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000740 my($font,$h1,$h2) = ('', '', '');
741 my $tableiii_rx =
Fred Drake6659c301998-03-03 22:02:19 +0000742 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7";
743 if (/$tableiii_rx/o) {
744 $font = $4;
Fred Drake58b2bfd1998-04-02 20:14:04 +0000745 $font = ''
746 if ($font eq 'textrm');
Fred Drake6659c301998-03-03 22:02:19 +0000747 $h1 = $6;
748 $h2 = $8;
749 }
Fred Drake42b31a51998-03-27 05:16:10 +0000750 my($th1,$th2,$th3) = setup_column_alignments($2);
Fred Drake6659c301998-03-03 22:02:19 +0000751 $globals{"lineifont"} = $font;
752 "<table border align=center>"
753 . "\n <tr>$th1<b>$h1</b></th>"
754 . "\n $th2<b>$h2</b></th>$'"
755 . "\n</table>";
756}
757
758sub do_cmd_lineii{
759 local($_) = @_;
760 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000761 my $c1 = $2;
Fred Drake6659c301998-03-03 22:02:19 +0000762 s/$next_pair_pr_rx//o;
Fred Drake58b2bfd1998-04-02 20:14:04 +0000763 my($c2,$font,$efont) = ($2, $globals{"lineifont"}, '');
764 if ($font) {
765 $font = "<$font>";
766 $efont = "</$font>";
767 }
Fred Drakec9a44381998-03-17 06:29:13 +0000768 my($c1align,$c2align) = @col_aligns[0,1];
Fred Drake58b2bfd1998-04-02 20:14:04 +0000769 "<tr>$c1align$font$c1$efont</td>\n"
Fred Drake6659c301998-03-03 22:02:19 +0000770 . " $c2align$c2</td>$'";
771}
772
773sub do_env_tableiii{
774 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000775 my($font,$h1,$h2,$h3) = ('', '', '', '');
Fred Drake6659c301998-03-03 22:02:19 +0000776
Fred Drakec9a44381998-03-17 06:29:13 +0000777 my $tableiii_rx =
Fred Drake6659c301998-03-03 22:02:19 +0000778 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"
779 . "$any_next_pair_rx9";
780 if (/$tableiii_rx/o) {
781 $font = $4;
Fred Drake58b2bfd1998-04-02 20:14:04 +0000782 $font = ''
783 if ($font eq 'textrm');
Fred Drake6659c301998-03-03 22:02:19 +0000784 $h1 = $6;
785 $h2 = $8;
786 $h3 = $10;
787 }
Fred Drake42b31a51998-03-27 05:16:10 +0000788 my($th1,$th2,$th3) = setup_column_alignments($2);
Fred Drake6659c301998-03-03 22:02:19 +0000789 $globals{"lineifont"} = $font;
790 "<table border align=center>"
791 . "\n <tr>$th1<b>$h1</b></th>"
792 . "\n $th2<b>$h2</b></th>"
793 . "\n $th3<b>$h3</b></th>$'"
794 . "\n</table>";
795}
796
797sub do_cmd_lineiii{
798 local($_) = @_;
799 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000800 my $c1 = $2;
Fred Drake6659c301998-03-03 22:02:19 +0000801 s/$next_pair_pr_rx//o;
Fred Drakec9a44381998-03-17 06:29:13 +0000802 my $c2 = $2;
Fred Drake6659c301998-03-03 22:02:19 +0000803 s/$next_pair_pr_rx//o;
Fred Drake58b2bfd1998-04-02 20:14:04 +0000804 my($c3,$font,$efont) = ($2, $globals{"lineifont"}, '');
805 if ($font) {
806 $font = "<$font>";
807 $efont = "</$font>";
808 }
Fred Drakec9a44381998-03-17 06:29:13 +0000809 my($c1align, $c2align, $c3align) = @col_aligns;
Fred Drake58b2bfd1998-04-02 20:14:04 +0000810 "<tr>$c1align$font$c1$efont</td>\n"
Fred Drake6659c301998-03-03 22:02:19 +0000811 . " $c2align$c2</td>\n"
812 . " $c3align$c3</td>$'";
813}
814
815sub do_env_seealso{
816 "<p><b>See Also:</b></p>\n" . @_[0];
817}
818
819sub do_cmd_seemodule{
820 # Insert the right magic to jump to the module definition. This should
821 # work most of the time, at least for repeat builds....
822 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000823 my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
824 my $any_next_pair_pr_rx5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP";
825 # Predefined $opt_arg_rx & $optional_arg_rx don't work because they
826 # require the argument to be there.
827 my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?";
828 s/$opt_arg_rx$any_next_pair_pr_rx3$any_next_pair_pr_rx5//;
829 my($key,$module,$text) = ($2, $4, $6);
830 $key = $module unless $key;
Fred Drakeb3c9bca1998-03-06 21:20:08 +0000831 "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
Fred Drake6659c301998-03-03 22:02:19 +0000832 . "&nbsp;&nbsp;&nbsp;($text)</p>"
833 . $_;
834}
835
836sub do_cmd_seetext{
837 "<p>" . @_[0];
838}
839
840
841sub do_cmd_maketitle {
842 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000843 my $the_title = '';
Fred Drake6659c301998-03-03 22:02:19 +0000844 if ($t_title) {
Fred Drakec9a44381998-03-17 06:29:13 +0000845 $the_title .= "<h1 align=center>$t_title</h1>";
Fred Drake6659c301998-03-03 22:02:19 +0000846 } else { &write_warnings("\nThis document has no title."); }
Fred Drakec9a44381998-03-17 06:29:13 +0000847 $the_title .= "\n<center>";
Fred Drake6659c301998-03-03 22:02:19 +0000848 if ($t_author) {
849 if ($t_authorURL) {
Fred Drakec9a44381998-03-17 06:29:13 +0000850 my $href = &translate_commands($t_authorURL);
Fred Drake6659c301998-03-03 22:02:19 +0000851 $href = &make_named_href('author', $href, "<strong>${t_author}</strong>");
Fred Drakec9a44381998-03-17 06:29:13 +0000852 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +0000853 } else {
Fred Drakec9a44381998-03-17 06:29:13 +0000854 $the_title .= "\n<p><strong>$t_author</strong></p>";
Fred Drake6659c301998-03-03 22:02:19 +0000855 }
856 } else { &write_warnings("\nThere is no author for this document."); }
857 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +0000858 $the_title .= "\n<p>$t_institute</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000859 if ($AUTHOR_ADDRESS) {
Fred Drakec9a44381998-03-17 06:29:13 +0000860 $the_title .= "\n<p>$AUTHOR_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000861 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +0000862 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000863 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +0000864 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +0000865 if ($PYTHON_VERSION) {
866 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
867 $the_title .= "</p>"
868 }
Fred Drakec9a44381998-03-17 06:29:13 +0000869 $the_title .= "\n</center>";
Fred Drake6659c301998-03-03 22:02:19 +0000870 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +0000871 $the_title .= "\n<p>$t_address</p>";
872 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +0000873 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +0000874 $the_title .= "\n<p>$t_email</p>";
875 }# else { $the_title .= "</p>" }
876 $the_title . "<hr>\n" . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +0000877}
878
879
Fred Drake42b31a51998-03-27 05:16:10 +0000880# sub do_cmd_indexlabel{
881# "genindex" . @_[0];
882# }
Fred Drakec9a44381998-03-17 06:29:13 +0000883
Fred Drakefc16e781998-03-12 21:03:26 +0000884
885# These are located down here since they screw up fontlock. -- used to.
Fred Drake6659c301998-03-03 22:02:19 +0000886
887sub do_cmd_file{
888 # This uses a weird HTML construct to adjust the font to be
889 # reasonable match that used in the printed form as much as
890 # possible. The expected behavior is that a browser that doesn't
891 # understand "<font face=...>" markup will use courier (or whatever
892 # the font is for <tt>).
893 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000894 s|$next_pair_pr_rx|\"<tt>\2</tt>\"|;
Fred Drake6659c301998-03-03 22:02:19 +0000895 $_;
896}
897
898sub do_cmd_samp{
899 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000900 s|$next_pair_pr_rx|\"<tt>\2</tt>\"|;
Fred Drake6659c301998-03-03 22:02:19 +0000901 $_;
902}
903
9041; # This must be the last line