blob: ff0bd88548fc39e9ca6b7e7b65ecf5f37c40423b [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
Fred Drake08932051998-04-17 02:15:42 +000012sub next_argument{
Fred Drakeccc62721999-01-05 22:16:29 +000013 my $param;
14 $param = missing_braces()
15 unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
16 ||(s/$next_pair_rx/$param=$2;''/eo));
Fred Drake62e43691998-08-10 19:40:44 +000017 return $param;
Fred Drake08932051998-04-17 02:15:42 +000018}
19
20sub next_optional_argument{
21 my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
Fred Drake5ccf3301998-04-17 20:04:09 +000022 s/$rx/$param=$2;''/eo;
Fred Drake62e43691998-08-10 19:40:44 +000023 return $param;
Fred Drake08932051998-04-17 02:15:42 +000024}
25
26sub swallow_newline{
27 s/[\n]?//o;
28}
29
Fred Drakee16f6791998-05-15 04:28:37 +000030
31# This is a fairly simple hack; it supports \let when it is used to create
32# (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
Fred Drake5b73cdf1998-05-15 16:59:38 +000033# Many possible uses of \let aren't supported or aren't supported correctly.
Fred Drakee16f6791998-05-15 04:28:37 +000034#
35sub do_cmd_let{
36 local($_) = @_;
37 my $matched = 0;
Fred Drake7a4ad0f1998-05-15 13:45:54 +000038 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
Fred Drakee16f6791998-05-15 04:28:37 +000039 if ($matched) {
40 my($new, $old) = ($1, $3);
41 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
42 print "\ndefining handler for \\$new using \\$old\n";
43 }
Fred Drake7a4ad0f1998-05-15 13:45:54 +000044 else {
45 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
46 if ($matched) {
47 my($new, $char) = ($1, $3);
48 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
49 print "\ndefining handler for \\$new to insert '$char'\n";
50 }
51 else {
52 write_warnings("Could not interpret \\let construct...");
53 }
54 }
Fred Drake62e43691998-08-10 19:40:44 +000055 return $_;
Fred Drakee16f6791998-05-15 04:28:37 +000056}
57
58
Fred Drake6659c301998-03-03 22:02:19 +000059# words typeset in a special way (not in HTML though)
60
61sub do_cmd_ABC{ 'ABC' . @_[0]; }
62sub do_cmd_UNIX{ 'Unix'. @_[0]; }
63sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
64sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
65sub do_cmd_C{ 'C' . @_[0]; }
66sub do_cmd_Cpp{ 'C++' . @_[0]; }
67sub do_cmd_EOF{ 'EOF' . @_[0]; }
68sub do_cmd_NULL{ '<tt>NULL</tt>' . @_[0]; }
69
70sub do_cmd_e{ '&#92;' . @_[0]; }
71
Fred Draked07868a1998-05-14 21:00:28 +000072$DEVELOPER_ADDRESS = '';
Fred Drake6659c301998-03-03 22:02:19 +000073$PYTHON_VERSION = '';
74
75sub do_cmd_version{ $PYTHON_VERSION . @_[0]; }
76sub do_cmd_release{
77 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000078 $PYTHON_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000079 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000080}
81
82sub do_cmd_authoraddress{
83 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +000084 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000085 return $_;
Fred Drake6659c301998-03-03 22:02:19 +000086}
87
Fred Drakee16f6791998-05-15 04:28:37 +000088#sub do_cmd_developer{ do_cmd_author(@_[0]); }
89#sub do_cmd_developers{ do_cmd_author(@_[0]); }
90#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +000091
Fred Drake6659c301998-03-03 22:02:19 +000092sub do_cmd_hackscore{
93 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +000094 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +000095 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +000096}
97
Fred Drake08932051998-04-17 02:15:42 +000098sub use_wrappers{
99 local($_,$before,$after) = @_;
100 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000101 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +0000102}
103
Fred Drake62e43691998-08-10 19:40:44 +0000104sub use_current{
105 return use_wrappers(@_[0], '', '');
106}
107sub use_sans_serif{
Fred Drakeccc62721999-01-05 22:16:29 +0000108 return use_wrappers(@_[0], '<font face="sans-serif">', '</font>');
Fred Drake62e43691998-08-10 19:40:44 +0000109}
110sub use_italics{
111 return use_wrappers(@_[0], '<i>', '</i>');
112}
Fred Drake08932051998-04-17 02:15:42 +0000113
Fred Drake6659c301998-03-03 22:02:19 +0000114sub do_cmd_optional{
Fred Drake62e43691998-08-10 19:40:44 +0000115 return use_wrappers(@_[0], "</var><big>\[</big><var>",
116 "</var><big>\]</big><var>");
Fred Drake6659c301998-03-03 22:02:19 +0000117}
118
Fred Drakec9a44381998-03-17 06:29:13 +0000119# Logical formatting (some based on texinfo), needs to be converted to
120# minimalist HTML. The "minimalist" is primarily to reduce the size of
121# output files for users that read them over the network rather than
122# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000123
Fred Drake62e43691998-08-10 19:40:44 +0000124sub do_cmd_pytype{ return use_current(@_); }
125sub do_cmd_makevar{ return use_current(@_); }
126sub do_cmd_code{ return use_wrappers(@_[0], '<tt>', '</tt>'); }
127sub do_cmd_module{ return do_cmd_code(@_); }
128sub do_cmd_keyword{ return do_cmd_code(@_); }
129sub do_cmd_exception{ return do_cmd_code(@_); }
130sub do_cmd_class{ return do_cmd_code(@_); }
131sub do_cmd_function{ return do_cmd_code(@_); }
132sub do_cmd_constant{ return do_cmd_code(@_); }
133sub do_cmd_member{ return do_cmd_code(@_); }
134sub do_cmd_method{ return do_cmd_code(@_); }
135sub do_cmd_cfunction{ return do_cmd_code(@_); }
136sub do_cmd_cdata{ return do_cmd_code(@_); }
137sub do_cmd_ctype{ return do_cmd_code(@_); }
138sub do_cmd_regexp{ return do_cmd_code(@_); }
139sub do_cmd_character{ return do_cmd_samp(@_); }
140sub do_cmd_program{ return do_cmd_strong(@_); }
141sub do_cmd_email{ return use_sans_serif(@_); }
142sub do_cmd_mimetype{ return use_sans_serif(@_); }
143sub do_cmd_var{ return use_italics(@_); }
144sub do_cmd_dfn{ return use_italics(@_); } # make an index entry?
145sub do_cmd_emph{ return use_italics(@_); }
146sub do_cmd_file{ return use_wrappers(@_[0], '"<tt>', '</tt>"'); }
147sub do_cmd_samp{ return use_wrappers(@_[0], '"<tt>', '</tt>"'); }
148sub do_cmd_kbd{ return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
149sub do_cmd_strong{ return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drakec9a44381998-03-17 06:29:13 +0000150
Fred Drake1a7af391998-04-01 22:44:56 +0000151sub do_cmd_newsgroup{
152 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000153 my $newsgroup = next_argument();
Fred Drake1a7af391998-04-01 22:44:56 +0000154 my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>"
155 . "$newsgroup</font></a>";
Fred Drake62e43691998-08-10 19:40:44 +0000156 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000157}
Fred Drakefc16e781998-03-12 21:03:26 +0000158
159sub do_cmd_envvar{
160 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000161 my $envvar = next_argument();
162 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000163 # The <tt> here is really to keep buildindex.py from making
164 # the variable name case-insensitive.
165 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
166 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000167 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000168 return "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000169}
170
Fred Drake08932051998-04-17 02:15:42 +0000171
Fred Drake6659c301998-03-03 22:02:19 +0000172sub do_cmd_url{
173 # use the URL as both text and hyperlink
174 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000175 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000176 $url =~ s/~/&#126;/g;
Fred Drake62e43691998-08-10 19:40:44 +0000177 return "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000178}
179
180sub do_cmd_manpage{
181 # two parameters: \manpage{name}{section}
182 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000183 my $page = next_argument();
184 my $section = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000185 return "<i>$page</i>($section)" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000186}
187
188sub do_cmd_rfc{
189 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000190 my $rfcnumber = next_argument();
191 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake2eff3c51998-12-22 18:02:25 +0000192 my $href =
193 "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt";
Fred Drake6659c301998-03-03 22:02:19 +0000194 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000195 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000196 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
197 return "<a name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>" .$_;
Fred Drake6659c301998-03-03 22:02:19 +0000198}
199
Fred Drake6659c301998-03-03 22:02:19 +0000200sub do_cmd_deprecated{
201 # two parameters: \deprecated{version}{whattodo}
202 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000203 my $release = next_argument();
204 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000205 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000206}
207
Fred Drake897d12b1998-07-27 20:33:17 +0000208sub do_cmd_versionadded{
209 # one parameter: \versionadded{version}
210 local($_) = @_;
211 my $release = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000212 return "<b>New in version $release.</b><p>" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000213}
214
215sub do_cmd_versionchanged{
216 # one parameter: \versionchanged{version}
217 local($_) = @_;
218 my $release = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000219 return "<b>Changed in version $release.</b><p>" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000220}
221
Fred Drake6659c301998-03-03 22:02:19 +0000222# file and samp are at the end of this file since they screw up fontlock.
223
224# index commands
225
226$INDEX_SUBITEM = "";
227
228sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000229 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000230}
231
232sub do_cmd_setindexsubitem{
233 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000234 my $subitem = next_argument();
235 $INDEX_SUBITEM = $subitem;
Fred Drake62e43691998-08-10 19:40:44 +0000236 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000237}
238
Fred Drakefc16e781998-03-12 21:03:26 +0000239sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000240 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000241 # do things in the right order, but we need to at least strip this stuff
242 # out, and leave anything that the second argument expanded out to.
243 #
244 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000245 my $oldsubitem = $INDEX_SUBITEM;
246 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000247 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000248 my $br_id = ++$globals{'max_id'};
249 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000250 return
251 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000252 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000253 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000254}
255
Fred Drake08932051998-04-17 02:15:42 +0000256# This is the prologue macro which is required to start writing the
257# mod\jobname.idx file; we can just ignore it.
258#
Fred Drake62e43691998-08-10 19:40:44 +0000259sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000260
Fred Drake42b31a51998-03-27 05:16:10 +0000261# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000262#
Fred Drake08932051998-04-17 02:15:42 +0000263open(IDXFILE, '>index.dat') || die "\n$!\n";
264open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000265print INTLABELS "%internal_labels = ();\n";
266print INTLABELS "1; # hack in case there are no entries\n\n";
267
268# Using \0 for this is bad because we can't use common tools to work with the
269# resulting files. Things like grep can be useful with this stuff!
270#
271$IDXFILE_FIELD_SEP = "\1";
272
Fred Drakeccc62721999-01-05 22:16:29 +0000273sub write_idxfile{
274 my ($ahref, $str) = @_;
275 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000276}
277
Fred Drake42b31a51998-03-27 05:16:10 +0000278
279sub gen_link{
280 my($node,$target) = @_;
281 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drake62e43691998-08-10 19:40:44 +0000282 return "<a href=\"$node#$target\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000283}
284
285sub make_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000286 my($str) = @_;
287 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000288 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000289 return "$aname$anchor_invisible_mark</a>";
Fred Drake42b31a51998-03-27 05:16:10 +0000290}
291
292sub add_index_entry{
293 # add an entry to the index structures; ignore the return value
294 my($str,$ahref) = @_;
295 $str = gen_index_id($str, '');
296 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000297 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000298}
299
Fred Drakeccc62721999-01-05 22:16:29 +0000300sub new_link_info{
301 my $name = "l2h-" . ++$globals{'max_id'};
302 my $aname = '<a name="' . $name . '">';
Fred Drake42b31a51998-03-27 05:16:10 +0000303 my $ahref = gen_link($CURRENT_FILE, $name);
304 return ($name, $aname, $ahref);
305}
306
307sub do_cmd_index{
308 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000309 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000310 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000311 #
Fred Drakeccc62721999-01-05 22:16:29 +0000312 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000313 add_index_entry("$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000314 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000315}
316
Fred Drake2e7edb81998-05-11 18:31:17 +0000317sub do_cmd_kwindex{
318 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000319 my $str = next_argument();
Fred Drake2e7edb81998-05-11 18:31:17 +0000320 #
Fred Drakeccc62721999-01-05 22:16:29 +0000321 my($name,$aname,$ahref) = new_link_info();
Fred Drake2e7edb81998-05-11 18:31:17 +0000322 add_index_entry("<tt>$str</tt>!keyword", $ahref);
323 add_index_entry("keyword!<tt>$str</tt>", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000324 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake2e7edb81998-05-11 18:31:17 +0000325}
326
Fred Drake6659c301998-03-03 22:02:19 +0000327sub do_cmd_indexii{
328 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000329 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000330 my $str2 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000331 #
Fred Drakeccc62721999-01-05 22:16:29 +0000332 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000333 add_index_entry("$str1!$str2", $ahref);
334 add_index_entry("$str2!$str1", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000335 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000336}
337
338sub do_cmd_indexiii{
339 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000340 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000341 my $str2 = next_argument();
342 my $str3 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000343 #
Fred Drakeccc62721999-01-05 22:16:29 +0000344 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000345 add_index_entry("$str1!$str2 $str3", $ahref);
346 add_index_entry("$str2!$str3, $str1", $ahref);
347 add_index_entry("$str3!$str1 $str2", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000348 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000349}
350
351sub do_cmd_indexiv{
352 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000353 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000354 my $str2 = next_argument();
355 my $str3 = next_argument();
356 my $str4 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000357 #
Fred Drakeccc62721999-01-05 22:16:29 +0000358 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000359 add_index_entry("$str1!$str2 $str3 $str4", $ahref);
360 add_index_entry("$str2!$str3 $str4, $str1", $ahref);
361 add_index_entry("$str3!$str4, $str1 $str2", $ahref);
362 add_index_entry("$str4!$$str1 $str2 $str3", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000363 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000364}
365
Fred Drakec9a44381998-03-17 06:29:13 +0000366sub do_cmd_ttindex{
367 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000368 my $str = next_argument();
369 my $entry = $str . get_indexsubitem();
Fred Drake08932051998-04-17 02:15:42 +0000370 swallow_newline();
Fred Drakeccc62721999-01-05 22:16:29 +0000371 return make_index_entry($entry) . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000372}
Fred Drake6659c301998-03-03 22:02:19 +0000373
374sub my_typed_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000375 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000376 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000377 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000378 #
Fred Drakeccc62721999-01-05 22:16:29 +0000379 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000380 add_index_entry("$str $word", $ahref);
381 add_index_entry("$word!$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000382 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000383}
384
Fred Drake62e43691998-08-10 19:40:44 +0000385sub do_cmd_stindex{ return my_typed_index_helper('statement', @_); }
386sub do_cmd_opindex{ return my_typed_index_helper('operator', @_); }
387sub do_cmd_exindex{ return my_typed_index_helper('exception', @_); }
388sub do_cmd_obindex{ return my_typed_index_helper('object', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000389
390sub my_parword_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000391 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000392 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000393 swallow_newline();
Fred Drakeccc62721999-01-05 22:16:29 +0000394 return make_index_entry("$str ($word)") . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000395}
396
397
Fred Drake6659c301998-03-03 22:02:19 +0000398sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000399 my($str,$define) = @_;
400 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000401 # equivalent of add_index_entry() using $define instead of ''
402 $str = gen_index_id($str, $define);
403 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000404 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000405
Fred Drakec9a44381998-03-17 06:29:13 +0000406 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000407 # add to the module index
Fred Drakec9a44381998-03-17 06:29:13 +0000408 my($nstr,$garbage) = split / /, $str, 2;
Fred Drake42b31a51998-03-27 05:16:10 +0000409 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000410 }
Fred Drake62e43691998-08-10 19:40:44 +0000411 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000412}
413
Fred Drakec9a44381998-03-17 06:29:13 +0000414$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000415$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000416
Fred Drakea0f4c941998-07-24 22:16:04 +0000417sub define_module{
418 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000419 my $section_tag = join('', @curr_sec_id);
Fred Drake6659c301998-03-03 22:02:19 +0000420 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000421 $THIS_MODULE = "$name";
Fred Drakeccc62721999-01-05 22:16:29 +0000422 return make_mod_index_entry("<tt>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000423}
424
425sub my_module_index_helper{
426 local($word, $_) = @_;
427 my $name = next_argument();
428 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000429 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000430}
431
432sub ref_module_index_helper{
433 local($word, $_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000434 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000435 swallow_newline();
Fred Drake6659c301998-03-03 22:02:19 +0000436 $word = "$word " if $word;
Fred Drakeccc62721999-01-05 22:16:29 +0000437 return make_mod_index_entry("<tt>$str</tt> (${word}module)", 'REF') . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000438}
439
Fred Drakec9a44381998-03-17 06:29:13 +0000440sub do_cmd_bifuncindex{
441 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000442 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000443 my $fname = "<tt>$str()</tt>";
Fred Drakeccc62721999-01-05 22:16:29 +0000444 swallow_newline();
445 return make_index_entry("$fname (built-in function)") . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000446}
447
Fred Drake62e43691998-08-10 19:40:44 +0000448sub do_cmd_modindex{ return my_module_index_helper('', @_); }
449sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
450sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
451sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000452
453# these should be adjusted a bit....
Fred Drake62e43691998-08-10 19:40:44 +0000454sub do_cmd_refmodindex{ return ref_module_index_helper('', @_); }
455sub do_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
456sub do_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
457sub do_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000458
Fred Drake62e43691998-08-10 19:40:44 +0000459sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000460
461sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000462# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000463 $anchor_mark = '';
464 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000465}
Fred Drake42b31a51998-03-27 05:16:10 +0000466init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000467
468# similar to make_index_entry(), but includes the string in the result
469# instead of the dummy filler.
470#
471sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000472 my($str) = @_;
473 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000474 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000475 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000476}
477
Fred Drake6659c301998-03-03 22:02:19 +0000478sub do_env_cfuncdesc{
479 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000480 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000481 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000482 my $arg_list = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000483 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
484 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000485 $idx =~ s/ \(.*\)//;
486 $idx =~ s/\(\)//; # ????
Fred Drake62e43691998-08-10 19:40:44 +0000487 return "<dl><dt>$return_type <b>$idx</b>"
488 . "(<var>$arg_list</var>)\n<dd>"
489 . $_
490 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000491}
492
493sub do_env_ctypedesc{
494 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000495 my $type_name = next_argument();
496 my $idx = make_str_index_entry("<tt>$type_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000497 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000498 return "<dl><dt><b>$idx</b>\n<dd>"
499 . $_
500 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000501}
502
503sub do_env_cvardesc{
504 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000505 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000506 my $var_name = next_argument();
507 my $idx = make_str_index_entry("<tt>$var_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000508 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000509 return "<dl><dt>$var_type <b>$idx</b>\n"
510 . '<dd>'
511 . $_
512 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000513}
514
515sub do_env_funcdesc{
516 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000517 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000518 my $arg_list = next_argument();
519 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000520 . get_indexsubitem());
521 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000522 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000523 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000524}
525
526sub do_env_funcdescni{
527 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000528 my $function_name = next_argument();
529 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000530 return "<dl><dt><b><tt>$function_name</tt></b> (<var>$arg_list</var>)\n"
531 . "<dd>"
532 . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000533}
534
535sub do_cmd_funcline{
536 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000537 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000538 my $arg_list = next_argument();
539 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000540 . get_indexsubitem());
Fred Drakec9a44381998-03-17 06:29:13 +0000541 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000542 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000543}
544
545# Change this flag to index the opcode entries. I don't think it's very
546# useful to index them, since they're only presented to describe the dis
547# module.
548#
549$INDEX_OPCODES = 0;
550
551sub do_env_opcodedesc{
552 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000553 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000554 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000555 my $idx;
556 if ($INDEX_OPCODES) {
Fred Drakeccc62721999-01-05 22:16:29 +0000557 $idx = make_str_index_entry(
Fred Drake6659c301998-03-03 22:02:19 +0000558 "<tt>$opcode_name</tt> (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000559 $idx =~ s/ \(byte code instruction\)//;
560 }
561 else {
562 $idx = "<tt>$opcode_name</tt>";
563 }
564 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000565 if ($arg_list) {
566 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
567 }
Fred Drake62e43691998-08-10 19:40:44 +0000568 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000569}
570
571sub do_env_datadesc{
572 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000573 my $dataname = next_argument();
574 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000575 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000576 return "<dl><dt><b>$idx</b>\n<dd>"
577 . $_
578 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000579}
580
581sub do_env_datadescni{
582 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000583 my $idx = next_argument();
584 if (! $STRING_INDEX_TT) {
585 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000586 }
Fred Drake62e43691998-08-10 19:40:44 +0000587 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000588}
589
590sub do_cmd_dataline{
591 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000592 my $data_name = next_argument();
593 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000594 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000595 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000596}
597
Fred Drake42b31a51998-03-27 05:16:10 +0000598sub do_env_excdesc{
599 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000600 my $excname = next_argument();
601 my $idx = make_str_index_entry("<tt>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000602 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000603}
604
Fred Drake62e43691998-08-10 19:40:44 +0000605sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000606
607
Fred Drakec9a44381998-03-17 06:29:13 +0000608sub do_env_classdesc{
609 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000610 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000611 my $arg_list = next_argument();
612 $idx = make_str_index_entry(
Fred Drake08932051998-04-17 02:15:42 +0000613 "<tt>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
614 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000615 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000616}
617
Fred Drake42b31a51998-03-27 05:16:10 +0000618
619sub do_env_methoddesc{
620 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000621 my $class_name = next_optional_argument();
622 $class_name = $THIS_CLASS
623 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000624 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000625 my $arg_list = next_argument();
626 my $extra = '';
627 if ($class_name) {
628 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000629 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000630 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000631 $idx =~ s/ \(.*\)//;
632 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000633 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000634}
635
636
Fred Drake7d45f6d1999-01-05 14:39:27 +0000637sub do_cmd_methodline{
638 local($_) = @_;
639 my $class_name = next_optional_argument();
640 $class_name = $THIS_CLASS
641 unless $class_name;
642 my $method = next_argument();
643 my $arg_list = next_argument();
644 my $extra = '';
645 if ($class_name) {
646 $extra = " ($class_name method)";
647 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000648 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000649 $idx =~ s/ \(.*\)//;
650 $idx =~ s/\(\)//;
651 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
652 . $_;
653}
654
655
Fred Draked64a40d1998-09-10 18:59:13 +0000656sub do_cmd_methodlineni{
657 local($_) = @_;
658 next_optional_argument();
659 my $method = next_argument();
660 my $arg_list = next_argument();
661 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
662 . $_;
663}
664
Fred Drake42b31a51998-03-27 05:16:10 +0000665sub do_env_methoddescni{
666 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000667 next_optional_argument();
668 my $method = next_argument();
669 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000670 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
671 . $_
672 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000673}
674
675
676sub do_env_memberdesc{
677 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000678 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000679 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000680 $class = $THIS_CLASS
681 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000682 my $extra = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000683 $extra = " ($class_name attribute)"
Fred Drakea608feb1998-04-12 03:58:13 +0000684 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000685 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000686 $idx =~ s/ \(.*\)//;
687 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000688 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000689}
690
691
Fred Drake5ccf3301998-04-17 20:04:09 +0000692sub do_cmd_memberline{
693 local($_) = @_;
694 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000695 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000696 $class = $THIS_CLASS
697 unless $class;
698 my $extra = '';
699 $extra = " ($class_name attribute)"
700 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000701 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000702 $idx =~ s/ \(.*\)//;
703 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000704 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000705}
706
Fred Drake42b31a51998-03-27 05:16:10 +0000707sub do_env_memberdescni{
708 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000709 next_optional_argument();
710 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000711 return "<dl><dt><b>$member</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000712}
713
714
Fred Drake5ccf3301998-04-17 20:04:09 +0000715sub do_cmd_memberlineni{
716 local($_) = @_;
717 next_optional_argument();
718 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000719 return "<dt><b>$member</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000720}
721
Fred Drakea0f4c941998-07-24 22:16:04 +0000722@col_aligns = ("<td>", "<td>", "<td>", "<td>");
Fred Drake6659c301998-03-03 22:02:19 +0000723
724sub setup_column_alignments{
725 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000726 my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
727 my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>');
Fred Drake08932051998-04-17 02:15:42 +0000728 $col_aligns[0] = (($a1 eq 'c') ? '<td align=center>' : '<td>');
729 $col_aligns[1] = (($a2 eq 'c') ? '<td align=center>' : '<td>');
730 $col_aligns[2] = (($a3 eq 'c') ? '<td align=center>' : '<td>');
Fred Drakea0f4c941998-07-24 22:16:04 +0000731 $col_aligns[3] = (($a4 eq 'c') ? '<td align=center>' : '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000732 # return the aligned header start tags; only used for \begin{tableiii?}
Fred Drake08932051998-04-17 02:15:42 +0000733 $th1 = (($a1 eq 'l') ? '<th align=left>'
734 : ($a1 eq 'r' ? '<th align=right>' : '<th>'));
735 $th2 = (($a2 eq 'l') ? '<th align=left>'
736 : ($a2 eq 'r' ? '<th align=right>' : '<th>'));
737 $th3 = (($a3 eq 'l') ? '<th align=left>'
738 : ($a3 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drakea0f4c941998-07-24 22:16:04 +0000739 $th4 = (($a4 eq 'l') ? '<th align=left>'
740 : ($a4 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drake62e43691998-08-10 19:40:44 +0000741 return ($th1, $th2, $th3, $th4);
Fred Drake6659c301998-03-03 22:02:19 +0000742}
743
744sub do_env_tableii{
745 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000746 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000747 my $font = next_argument();
748 my $h1 = next_argument();
749 my $h2 = next_argument();
750 $font = ''
751 if ($font eq 'textrm');
752 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000753 return '<table border align=center>'
754 . "\n <tr>$th1<b>$h1</b></th>"
755 . "\n $th2<b>$h2</b></th>"
756 . $_
757 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000758}
759
760sub do_cmd_lineii{
761 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000762 my $c1 = next_argument();
763 my $c2 = next_argument();
764 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000765 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000766 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000767 $efont = "</$font>";
768 }
Fred Drakec9a44381998-03-17 06:29:13 +0000769 my($c1align,$c2align) = @col_aligns[0,1];
Fred Drake62e43691998-08-10 19:40:44 +0000770 return "<tr>$c1align$sfont$c1$efont</td>\n"
771 . " $c2align$c2</td>"
772 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000773}
774
775sub do_env_tableiii{
776 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000777 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000778 my $font = next_argument();
779 my $h1 = next_argument();
780 my $h2 = next_argument();
781 my $h3 = next_argument();
782 $font = ''
783 if ($font eq 'textrm');
784 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000785 return '<table border align=center>'
786 . "\n <tr>$th1<b>$h1</b></th>"
787 . "\n $th2<b>$h2</b></th>"
788 . "\n $th3<b>$h3</b></th>"
789 . $_
790 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000791}
792
793sub do_cmd_lineiii{
794 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000795 my $c1 = next_argument();
796 my $c2 = next_argument();
797 my $c3 = next_argument();
798 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000799 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000800 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000801 $efont = "</$font>";
802 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000803 my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
Fred Drake62e43691998-08-10 19:40:44 +0000804 return "<tr>$c1align$sfont$c1$efont</td>\n"
805 . " $c2align$c2</td>\n"
806 . " $c3align$c3</td>"
807 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000808}
809
Fred Drakea0f4c941998-07-24 22:16:04 +0000810sub do_env_tableiv{
811 local($_) = @_;
812 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
813 my $font = next_argument();
814 my $h1 = next_argument();
815 my $h2 = next_argument();
816 my $h3 = next_argument();
817 my $h4 = next_argument();
818 $font = ''
819 if ($font eq 'textrm');
820 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000821 return '<table border align=center>'
822 . "\n <tr>$th1<b>$h1</b></th>"
823 . "\n $th2<b>$h2</b></th>"
824 . "\n $th3<b>$h3</b></th>"
825 . "\n $th4<b>$h4</b></th>"
826 . $_
827 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000828}
829
Fred Drakea0f4c941998-07-24 22:16:04 +0000830sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +0000831 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000832 my $c1 = next_argument();
833 my $c2 = next_argument();
834 my $c3 = next_argument();
835 my $c4 = next_argument();
836 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
837 if ($font) {
838 $sfont = "<$font>";
839 $efont = "</$font>";
840 }
841 my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
Fred Drake62e43691998-08-10 19:40:44 +0000842 return "<tr>$c1align$sfont$c1$efont</td>\n"
843 . " $c2align$c2</td>\n"
844 . " $c3align$c3</td>\n"
845 . " $c4align$c4</td>"
846 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000847}
848
Fred Drake6659c301998-03-03 22:02:19 +0000849sub do_cmd_maketitle {
850 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000851 my $the_title = '';
Fred Drake6659c301998-03-03 22:02:19 +0000852 if ($t_title) {
Fred Drakec9a44381998-03-17 06:29:13 +0000853 $the_title .= "<h1 align=center>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +0000854 } else { write_warnings("\nThis document has no title."); }
Fred Drakec9a44381998-03-17 06:29:13 +0000855 $the_title .= "\n<center>";
Fred Drake6659c301998-03-03 22:02:19 +0000856 if ($t_author) {
857 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +0000858 my $href = translate_commands($t_authorURL);
859 $href = make_named_href('author', $href, "<strong>${t_author}</strong>");
Fred Drakec9a44381998-03-17 06:29:13 +0000860 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +0000861 } else {
Fred Drakec9a44381998-03-17 06:29:13 +0000862 $the_title .= "\n<p><strong>$t_author</strong></p>";
Fred Drake6659c301998-03-03 22:02:19 +0000863 }
Fred Drake08932051998-04-17 02:15:42 +0000864 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +0000865 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +0000866 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +0000867 if ($DEVELOPER_ADDRESS) {
868 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000869 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +0000870 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000871 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +0000872 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +0000873 if ($PYTHON_VERSION) {
874 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
875 $the_title .= "</p>"
876 }
Fred Drakec9a44381998-03-17 06:29:13 +0000877 $the_title .= "\n</center>";
Fred Drake6659c301998-03-03 22:02:19 +0000878 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +0000879 $the_title .= "\n<p>$t_address</p>";
880 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +0000881 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +0000882 $the_title .= "\n<p>$t_email</p>";
883 }# else { $the_title .= "</p>" }
Fred Drake62e43691998-08-10 19:40:44 +0000884 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +0000885}
886
887
Fred Drake885215c1998-05-20 21:32:09 +0000888#
Fred Drakea0f4c941998-07-24 22:16:04 +0000889# Module synopsis support
890#
891
892require SynopsisTable;
893
Fred Drakef7685d71998-07-25 03:31:46 +0000894sub get_chapter_id(){
895 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +0000896 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
897 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +0000898 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +0000899}
900
Fred Drakef7685d71998-07-25 03:31:46 +0000901%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
902
903sub get_synopsis_table($){
904 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000905 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +0000906 my $key;
907 foreach $key (keys %ModuleSynopses) {
908 if ($key eq $chap) {
909 return $ModuleSynopses{$chap};
910 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000911 }
Fred Drakef7685d71998-07-25 03:31:46 +0000912 $st = SynopsisTable->new();
913 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +0000914 return $st;
915}
916
Fred Drake62e43691998-08-10 19:40:44 +0000917sub do_cmd_moduleauthor{
918 local($_) = @_;
919 next_argument();
920 next_argument();
921 return $_;
922}
923
924sub do_cmd_sectionauthor{
925 local($_) = @_;
926 next_argument();
927 next_argument();
928 return $_;
929}
930
Fred Drakea0f4c941998-07-24 22:16:04 +0000931sub do_cmd_declaremodule{
932 local($_) = @_;
933 my $key = next_optional_argument();
934 my $type = next_argument();
935 my $name = next_argument();
936 my $st = get_synopsis_table(get_chapter_id());
937 #
938 $key = $name unless $key;
939 $type = 'built-in' if $type eq 'builtin';
940 $st->declare($name, $key, $type);
941 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +0000942 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +0000943}
944
945sub do_cmd_modulesynopsis{
946 local($_) = @_;
947 my $st = get_synopsis_table(get_chapter_id());
948 $st->set_synopsis($THIS_MODULE, next_argument());
949 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000950 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000951}
952
953sub do_cmd_localmoduletable{
954 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000955 my $chap = get_chapter_id();
Fred Drake62e43691998-08-10 19:40:44 +0000956 return "<tex2htmllocalmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000957}
958
959sub process_all_localmoduletables{
960 while (/<tex2htmllocalmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +0000961 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +0000962 my $chap = $1;
963 my $st = get_synopsis_table($chap);
964 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +0000965 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +0000966 }
967}
968
969
970#
971# "See also:" -- references placed at the end of a \section
972#
973
974sub do_env_seealso{
Fred Drake62e43691998-08-10 19:40:44 +0000975 return "<p><b>See Also:</b></p>\n" . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +0000976}
977
978sub do_cmd_seemodule{
979 # Insert the right magic to jump to the module definition. This should
980 # work most of the time, at least for repeat builds....
981 local($_) = @_;
982 my $key = next_optional_argument();
983 my $module = next_argument();
984 my $text = next_argument();
985 $key = $module
986 unless $key;
Fred Drake62e43691998-08-10 19:40:44 +0000987 return "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
988 . "&nbsp;&nbsp;&nbsp;($text)</p>"
989 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000990}
991
992sub do_cmd_seetext{
Fred Drake62e43691998-08-10 19:40:44 +0000993 return '<p>' . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +0000994}
995
996
997#
Fred Drake885215c1998-05-20 21:32:09 +0000998# Definition list support.
999#
1000
1001sub do_env_definitions{
1002 local($_) = @_;
1003 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +00001004 return "<dl>$_</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001005}
1006
1007sub do_cmd_term{
1008 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001009 my $term = next_argument();
1010 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001011 swallow_newline();
1012 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001013 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001014}
1015
1016
Fred Drake6659c301998-03-03 22:02:19 +000010171; # This must be the last line