blob: d982f563866b187705af8636d9749aa0973bfd50 [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 Drake25817041999-01-13 17:06:34 +0000151sub do_cmd_refmodule{
152 # Insert the right magic to jump to the module definition.
153 local($_) = @_;
154 my $key = next_optional_argument();
155 my $module = next_argument();
156 $key = $module
157 unless $key;
158 return "<tt><a href=\"module-$key.html\">$module</a></tt>" . $_;
159}
160
Fred Drake1a7af391998-04-01 22:44:56 +0000161sub do_cmd_newsgroup{
162 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000163 my $newsgroup = next_argument();
Fred Drake1a7af391998-04-01 22:44:56 +0000164 my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>"
165 . "$newsgroup</font></a>";
Fred Drake62e43691998-08-10 19:40:44 +0000166 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000167}
Fred Drakefc16e781998-03-12 21:03:26 +0000168
169sub do_cmd_envvar{
170 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000171 my $envvar = next_argument();
172 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000173 # The <tt> here is really to keep buildindex.py from making
174 # the variable name case-insensitive.
175 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
176 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000177 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000178 return "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000179}
180
Fred Drake08932051998-04-17 02:15:42 +0000181
Fred Drake6659c301998-03-03 22:02:19 +0000182sub do_cmd_url{
183 # use the URL as both text and hyperlink
184 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000185 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000186 $url =~ s/~/&#126;/g;
Fred Drake62e43691998-08-10 19:40:44 +0000187 return "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000188}
189
190sub do_cmd_manpage{
191 # two parameters: \manpage{name}{section}
192 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000193 my $page = next_argument();
194 my $section = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000195 return "<i>$page</i>($section)" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000196}
197
198sub do_cmd_rfc{
199 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000200 my $rfcnumber = next_argument();
201 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake2eff3c51998-12-22 18:02:25 +0000202 my $href =
203 "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt";
Fred Drake6659c301998-03-03 22:02:19 +0000204 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000205 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000206 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
207 return "<a name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>" .$_;
Fred Drake6659c301998-03-03 22:02:19 +0000208}
209
Fred Drake6659c301998-03-03 22:02:19 +0000210sub do_cmd_deprecated{
211 # two parameters: \deprecated{version}{whattodo}
212 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000213 my $release = next_argument();
214 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000215 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000216}
217
Fred Drake897d12b1998-07-27 20:33:17 +0000218sub do_cmd_versionadded{
219 # one parameter: \versionadded{version}
220 local($_) = @_;
221 my $release = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000222 return "<b>New in version $release.</b><p>" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000223}
224
225sub do_cmd_versionchanged{
226 # one parameter: \versionchanged{version}
227 local($_) = @_;
228 my $release = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000229 return "<b>Changed in version $release.</b><p>" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000230}
231
Fred Drake6659c301998-03-03 22:02:19 +0000232# file and samp are at the end of this file since they screw up fontlock.
233
234# index commands
235
236$INDEX_SUBITEM = "";
237
238sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000239 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000240}
241
242sub do_cmd_setindexsubitem{
243 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000244 my $subitem = next_argument();
245 $INDEX_SUBITEM = $subitem;
Fred Drake62e43691998-08-10 19:40:44 +0000246 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000247}
248
Fred Drakefc16e781998-03-12 21:03:26 +0000249sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000250 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000251 # do things in the right order, but we need to at least strip this stuff
252 # out, and leave anything that the second argument expanded out to.
253 #
254 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000255 my $oldsubitem = $INDEX_SUBITEM;
256 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000257 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000258 my $br_id = ++$globals{'max_id'};
259 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000260 return
261 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000262 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000263 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000264}
265
Fred Drake08932051998-04-17 02:15:42 +0000266# This is the prologue macro which is required to start writing the
267# mod\jobname.idx file; we can just ignore it.
268#
Fred Drake62e43691998-08-10 19:40:44 +0000269sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000270
Fred Drake42b31a51998-03-27 05:16:10 +0000271# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000272#
Fred Drake08932051998-04-17 02:15:42 +0000273open(IDXFILE, '>index.dat') || die "\n$!\n";
274open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000275print INTLABELS "%internal_labels = ();\n";
276print INTLABELS "1; # hack in case there are no entries\n\n";
277
278# Using \0 for this is bad because we can't use common tools to work with the
279# resulting files. Things like grep can be useful with this stuff!
280#
281$IDXFILE_FIELD_SEP = "\1";
282
Fred Drakeccc62721999-01-05 22:16:29 +0000283sub write_idxfile{
284 my ($ahref, $str) = @_;
285 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000286}
287
Fred Drake42b31a51998-03-27 05:16:10 +0000288
289sub gen_link{
290 my($node,$target) = @_;
291 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drake62e43691998-08-10 19:40:44 +0000292 return "<a href=\"$node#$target\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000293}
294
295sub make_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000296 my($str) = @_;
297 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000298 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000299 return "$aname$anchor_invisible_mark</a>";
Fred Drake42b31a51998-03-27 05:16:10 +0000300}
301
302sub add_index_entry{
303 # add an entry to the index structures; ignore the return value
304 my($str,$ahref) = @_;
305 $str = gen_index_id($str, '');
306 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000307 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000308}
309
Fred Drakeccc62721999-01-05 22:16:29 +0000310sub new_link_info{
311 my $name = "l2h-" . ++$globals{'max_id'};
312 my $aname = '<a name="' . $name . '">';
Fred Drake42b31a51998-03-27 05:16:10 +0000313 my $ahref = gen_link($CURRENT_FILE, $name);
314 return ($name, $aname, $ahref);
315}
316
317sub do_cmd_index{
318 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000319 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000320 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000321 #
Fred Drakeccc62721999-01-05 22:16:29 +0000322 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000323 add_index_entry("$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000324 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000325}
326
Fred Drake2e7edb81998-05-11 18:31:17 +0000327sub do_cmd_kwindex{
328 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000329 my $str = next_argument();
Fred Drake2e7edb81998-05-11 18:31:17 +0000330 #
Fred Drakeccc62721999-01-05 22:16:29 +0000331 my($name,$aname,$ahref) = new_link_info();
Fred Drake2e7edb81998-05-11 18:31:17 +0000332 add_index_entry("<tt>$str</tt>!keyword", $ahref);
333 add_index_entry("keyword!<tt>$str</tt>", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000334 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake2e7edb81998-05-11 18:31:17 +0000335}
336
Fred Drake6659c301998-03-03 22:02:19 +0000337sub do_cmd_indexii{
338 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000339 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000340 my $str2 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000341 #
Fred Drakeccc62721999-01-05 22:16:29 +0000342 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000343 add_index_entry("$str1!$str2", $ahref);
344 add_index_entry("$str2!$str1", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000345 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000346}
347
348sub do_cmd_indexiii{
349 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000350 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000351 my $str2 = next_argument();
352 my $str3 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000353 #
Fred Drakeccc62721999-01-05 22:16:29 +0000354 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000355 add_index_entry("$str1!$str2 $str3", $ahref);
356 add_index_entry("$str2!$str3, $str1", $ahref);
357 add_index_entry("$str3!$str1 $str2", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000358 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000359}
360
361sub do_cmd_indexiv{
362 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000363 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000364 my $str2 = next_argument();
365 my $str3 = next_argument();
366 my $str4 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000367 #
Fred Drakeccc62721999-01-05 22:16:29 +0000368 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000369 add_index_entry("$str1!$str2 $str3 $str4", $ahref);
370 add_index_entry("$str2!$str3 $str4, $str1", $ahref);
371 add_index_entry("$str3!$str4, $str1 $str2", $ahref);
372 add_index_entry("$str4!$$str1 $str2 $str3", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000373 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000374}
375
Fred Drakec9a44381998-03-17 06:29:13 +0000376sub do_cmd_ttindex{
377 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000378 my $str = next_argument();
379 my $entry = $str . get_indexsubitem();
Fred Drake08932051998-04-17 02:15:42 +0000380 swallow_newline();
Fred Drakeccc62721999-01-05 22:16:29 +0000381 return make_index_entry($entry) . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000382}
Fred Drake6659c301998-03-03 22:02:19 +0000383
384sub my_typed_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000385 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000386 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000387 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000388 #
Fred Drakeccc62721999-01-05 22:16:29 +0000389 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000390 add_index_entry("$str $word", $ahref);
391 add_index_entry("$word!$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000392 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000393}
394
Fred Drake62e43691998-08-10 19:40:44 +0000395sub do_cmd_stindex{ return my_typed_index_helper('statement', @_); }
396sub do_cmd_opindex{ return my_typed_index_helper('operator', @_); }
397sub do_cmd_exindex{ return my_typed_index_helper('exception', @_); }
398sub do_cmd_obindex{ return my_typed_index_helper('object', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000399
400sub my_parword_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000401 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000402 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000403 swallow_newline();
Fred Drakeccc62721999-01-05 22:16:29 +0000404 return make_index_entry("$str ($word)") . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000405}
406
407
Fred Drake6659c301998-03-03 22:02:19 +0000408sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000409 my($str,$define) = @_;
410 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000411 # equivalent of add_index_entry() using $define instead of ''
412 $str = gen_index_id($str, $define);
413 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000414 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000415
Fred Drakec9a44381998-03-17 06:29:13 +0000416 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000417 # add to the module index
Fred Drakec9a44381998-03-17 06:29:13 +0000418 my($nstr,$garbage) = split / /, $str, 2;
Fred Drake42b31a51998-03-27 05:16:10 +0000419 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000420 }
Fred Drake62e43691998-08-10 19:40:44 +0000421 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000422}
423
Fred Drakec9a44381998-03-17 06:29:13 +0000424$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000425$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000426
Fred Drakea0f4c941998-07-24 22:16:04 +0000427sub define_module{
428 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000429 my $section_tag = join('', @curr_sec_id);
Fred Drake6659c301998-03-03 22:02:19 +0000430 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000431 $THIS_MODULE = "$name";
Fred Drakeccc62721999-01-05 22:16:29 +0000432 return make_mod_index_entry("<tt>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000433}
434
435sub my_module_index_helper{
436 local($word, $_) = @_;
437 my $name = next_argument();
438 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000439 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000440}
441
442sub ref_module_index_helper{
443 local($word, $_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000444 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000445 swallow_newline();
Fred Drake6659c301998-03-03 22:02:19 +0000446 $word = "$word " if $word;
Fred Drakeccc62721999-01-05 22:16:29 +0000447 return make_mod_index_entry("<tt>$str</tt> (${word}module)", 'REF') . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000448}
449
Fred Drakec9a44381998-03-17 06:29:13 +0000450sub do_cmd_bifuncindex{
451 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000452 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000453 my $fname = "<tt>$str()</tt>";
Fred Drakeccc62721999-01-05 22:16:29 +0000454 swallow_newline();
455 return make_index_entry("$fname (built-in function)") . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000456}
457
Fred Drake62e43691998-08-10 19:40:44 +0000458sub do_cmd_modindex{ return my_module_index_helper('', @_); }
459sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
460sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
461sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000462
463# these should be adjusted a bit....
Fred Drake62e43691998-08-10 19:40:44 +0000464sub do_cmd_refmodindex{ return ref_module_index_helper('', @_); }
465sub do_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
466sub do_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
467sub do_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000468
Fred Drake62e43691998-08-10 19:40:44 +0000469sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000470
471sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000472# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000473 $anchor_mark = '';
474 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000475}
Fred Drake42b31a51998-03-27 05:16:10 +0000476init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000477
478# similar to make_index_entry(), but includes the string in the result
479# instead of the dummy filler.
480#
481sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000482 my($str) = @_;
483 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000484 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000485 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000486}
487
Fred Drake6659c301998-03-03 22:02:19 +0000488sub do_env_cfuncdesc{
489 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000490 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000491 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000492 my $arg_list = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000493 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
494 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000495 $idx =~ s/ \(.*\)//;
496 $idx =~ s/\(\)//; # ????
Fred Drake62e43691998-08-10 19:40:44 +0000497 return "<dl><dt>$return_type <b>$idx</b>"
498 . "(<var>$arg_list</var>)\n<dd>"
499 . $_
500 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000501}
502
503sub do_env_ctypedesc{
504 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000505 my $type_name = next_argument();
506 my $idx = make_str_index_entry("<tt>$type_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000507 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000508 return "<dl><dt><b>$idx</b>\n<dd>"
509 . $_
510 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000511}
512
513sub do_env_cvardesc{
514 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000515 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000516 my $var_name = next_argument();
517 my $idx = make_str_index_entry("<tt>$var_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000518 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000519 return "<dl><dt>$var_type <b>$idx</b>\n"
520 . '<dd>'
521 . $_
522 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000523}
524
525sub do_env_funcdesc{
526 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000527 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000528 my $arg_list = next_argument();
529 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000530 . get_indexsubitem());
531 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000532 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000533 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000534}
535
536sub do_env_funcdescni{
537 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000538 my $function_name = next_argument();
539 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000540 return "<dl><dt><b><tt>$function_name</tt></b> (<var>$arg_list</var>)\n"
541 . "<dd>"
542 . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000543}
544
545sub do_cmd_funcline{
546 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000547 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000548 my $arg_list = next_argument();
549 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000550 . get_indexsubitem());
Fred Drakec9a44381998-03-17 06:29:13 +0000551 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000552 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000553}
554
555# Change this flag to index the opcode entries. I don't think it's very
556# useful to index them, since they're only presented to describe the dis
557# module.
558#
559$INDEX_OPCODES = 0;
560
561sub do_env_opcodedesc{
562 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000563 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000564 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000565 my $idx;
566 if ($INDEX_OPCODES) {
Fred Drakeccc62721999-01-05 22:16:29 +0000567 $idx = make_str_index_entry(
Fred Drake6659c301998-03-03 22:02:19 +0000568 "<tt>$opcode_name</tt> (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000569 $idx =~ s/ \(byte code instruction\)//;
570 }
571 else {
572 $idx = "<tt>$opcode_name</tt>";
573 }
574 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000575 if ($arg_list) {
576 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
577 }
Fred Drake62e43691998-08-10 19:40:44 +0000578 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000579}
580
581sub do_env_datadesc{
582 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000583 my $dataname = next_argument();
584 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000585 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000586 return "<dl><dt><b>$idx</b>\n<dd>"
587 . $_
588 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000589}
590
591sub do_env_datadescni{
592 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000593 my $idx = next_argument();
594 if (! $STRING_INDEX_TT) {
595 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000596 }
Fred Drake62e43691998-08-10 19:40:44 +0000597 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000598}
599
600sub do_cmd_dataline{
601 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000602 my $data_name = next_argument();
603 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000604 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000605 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000606}
607
Fred Drake42b31a51998-03-27 05:16:10 +0000608sub do_env_excdesc{
609 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000610 my $excname = next_argument();
611 my $idx = make_str_index_entry("<tt>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000612 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000613}
614
Fred Drake62e43691998-08-10 19:40:44 +0000615sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000616
617
Fred Drakec9a44381998-03-17 06:29:13 +0000618sub do_env_classdesc{
619 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000620 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000621 my $arg_list = next_argument();
622 $idx = make_str_index_entry(
Fred Drake08932051998-04-17 02:15:42 +0000623 "<tt>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
624 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000625 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000626}
627
Fred Drake42b31a51998-03-27 05:16:10 +0000628
629sub do_env_methoddesc{
630 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000631 my $class_name = next_optional_argument();
632 $class_name = $THIS_CLASS
633 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000634 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000635 my $arg_list = next_argument();
636 my $extra = '';
637 if ($class_name) {
638 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000639 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000640 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000641 $idx =~ s/ \(.*\)//;
642 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000643 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000644}
645
646
Fred Drake7d45f6d1999-01-05 14:39:27 +0000647sub do_cmd_methodline{
648 local($_) = @_;
649 my $class_name = next_optional_argument();
650 $class_name = $THIS_CLASS
651 unless $class_name;
652 my $method = next_argument();
653 my $arg_list = next_argument();
654 my $extra = '';
655 if ($class_name) {
656 $extra = " ($class_name method)";
657 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000658 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000659 $idx =~ s/ \(.*\)//;
660 $idx =~ s/\(\)//;
661 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
662 . $_;
663}
664
665
Fred Draked64a40d1998-09-10 18:59:13 +0000666sub do_cmd_methodlineni{
667 local($_) = @_;
668 next_optional_argument();
669 my $method = next_argument();
670 my $arg_list = next_argument();
671 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
672 . $_;
673}
674
Fred Drake42b31a51998-03-27 05:16:10 +0000675sub do_env_methoddescni{
676 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000677 next_optional_argument();
678 my $method = next_argument();
679 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000680 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
681 . $_
682 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000683}
684
685
686sub do_env_memberdesc{
687 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000688 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000689 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000690 $class = $THIS_CLASS
691 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000692 my $extra = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000693 $extra = " ($class_name attribute)"
Fred Drakea608feb1998-04-12 03:58:13 +0000694 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000695 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000696 $idx =~ s/ \(.*\)//;
697 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000698 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000699}
700
701
Fred Drake5ccf3301998-04-17 20:04:09 +0000702sub do_cmd_memberline{
703 local($_) = @_;
704 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000705 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000706 $class = $THIS_CLASS
707 unless $class;
708 my $extra = '';
709 $extra = " ($class_name attribute)"
710 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000711 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000712 $idx =~ s/ \(.*\)//;
713 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000714 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000715}
716
Fred Drake42b31a51998-03-27 05:16:10 +0000717sub do_env_memberdescni{
718 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000719 next_optional_argument();
720 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000721 return "<dl><dt><b>$member</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000722}
723
724
Fred Drake5ccf3301998-04-17 20:04:09 +0000725sub do_cmd_memberlineni{
726 local($_) = @_;
727 next_optional_argument();
728 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000729 return "<dt><b>$member</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000730}
731
Fred Drakea0f4c941998-07-24 22:16:04 +0000732@col_aligns = ("<td>", "<td>", "<td>", "<td>");
Fred Drake6659c301998-03-03 22:02:19 +0000733
734sub setup_column_alignments{
735 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000736 my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
737 my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>');
Fred Drake08932051998-04-17 02:15:42 +0000738 $col_aligns[0] = (($a1 eq 'c') ? '<td align=center>' : '<td>');
739 $col_aligns[1] = (($a2 eq 'c') ? '<td align=center>' : '<td>');
740 $col_aligns[2] = (($a3 eq 'c') ? '<td align=center>' : '<td>');
Fred Drakea0f4c941998-07-24 22:16:04 +0000741 $col_aligns[3] = (($a4 eq 'c') ? '<td align=center>' : '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000742 # return the aligned header start tags; only used for \begin{tableiii?}
Fred Drake08932051998-04-17 02:15:42 +0000743 $th1 = (($a1 eq 'l') ? '<th align=left>'
744 : ($a1 eq 'r' ? '<th align=right>' : '<th>'));
745 $th2 = (($a2 eq 'l') ? '<th align=left>'
746 : ($a2 eq 'r' ? '<th align=right>' : '<th>'));
747 $th3 = (($a3 eq 'l') ? '<th align=left>'
748 : ($a3 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drakea0f4c941998-07-24 22:16:04 +0000749 $th4 = (($a4 eq 'l') ? '<th align=left>'
750 : ($a4 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drake62e43691998-08-10 19:40:44 +0000751 return ($th1, $th2, $th3, $th4);
Fred Drake6659c301998-03-03 22:02:19 +0000752}
753
754sub do_env_tableii{
755 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000756 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000757 my $font = next_argument();
758 my $h1 = next_argument();
759 my $h2 = next_argument();
760 $font = ''
761 if ($font eq 'textrm');
762 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000763 return '<table border align=center>'
764 . "\n <tr>$th1<b>$h1</b></th>"
765 . "\n $th2<b>$h2</b></th>"
766 . $_
767 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000768}
769
770sub do_cmd_lineii{
771 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000772 my $c1 = next_argument();
773 my $c2 = next_argument();
774 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000775 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000776 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000777 $efont = "</$font>";
778 }
Fred Drakec9a44381998-03-17 06:29:13 +0000779 my($c1align,$c2align) = @col_aligns[0,1];
Fred Drake62e43691998-08-10 19:40:44 +0000780 return "<tr>$c1align$sfont$c1$efont</td>\n"
781 . " $c2align$c2</td>"
782 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000783}
784
785sub do_env_tableiii{
786 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000787 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000788 my $font = next_argument();
789 my $h1 = next_argument();
790 my $h2 = next_argument();
791 my $h3 = next_argument();
792 $font = ''
793 if ($font eq 'textrm');
794 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000795 return '<table border align=center>'
796 . "\n <tr>$th1<b>$h1</b></th>"
797 . "\n $th2<b>$h2</b></th>"
798 . "\n $th3<b>$h3</b></th>"
799 . $_
800 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000801}
802
803sub do_cmd_lineiii{
804 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000805 my $c1 = next_argument();
806 my $c2 = next_argument();
807 my $c3 = next_argument();
808 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000809 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000810 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000811 $efont = "</$font>";
812 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000813 my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
Fred Drake62e43691998-08-10 19:40:44 +0000814 return "<tr>$c1align$sfont$c1$efont</td>\n"
815 . " $c2align$c2</td>\n"
816 . " $c3align$c3</td>"
817 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000818}
819
Fred Drakea0f4c941998-07-24 22:16:04 +0000820sub do_env_tableiv{
821 local($_) = @_;
822 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
823 my $font = next_argument();
824 my $h1 = next_argument();
825 my $h2 = next_argument();
826 my $h3 = next_argument();
827 my $h4 = next_argument();
828 $font = ''
829 if ($font eq 'textrm');
830 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000831 return '<table border align=center>'
832 . "\n <tr>$th1<b>$h1</b></th>"
833 . "\n $th2<b>$h2</b></th>"
834 . "\n $th3<b>$h3</b></th>"
835 . "\n $th4<b>$h4</b></th>"
836 . $_
837 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000838}
839
Fred Drakea0f4c941998-07-24 22:16:04 +0000840sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +0000841 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000842 my $c1 = next_argument();
843 my $c2 = next_argument();
844 my $c3 = next_argument();
845 my $c4 = next_argument();
846 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
847 if ($font) {
848 $sfont = "<$font>";
849 $efont = "</$font>";
850 }
851 my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
Fred Drake62e43691998-08-10 19:40:44 +0000852 return "<tr>$c1align$sfont$c1$efont</td>\n"
853 . " $c2align$c2</td>\n"
854 . " $c3align$c3</td>\n"
855 . " $c4align$c4</td>"
856 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000857}
858
Fred Drake6659c301998-03-03 22:02:19 +0000859sub do_cmd_maketitle {
860 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000861 my $the_title = '';
Fred Drake6659c301998-03-03 22:02:19 +0000862 if ($t_title) {
Fred Drakec9a44381998-03-17 06:29:13 +0000863 $the_title .= "<h1 align=center>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +0000864 } else { write_warnings("\nThis document has no title."); }
Fred Drakec9a44381998-03-17 06:29:13 +0000865 $the_title .= "\n<center>";
Fred Drake6659c301998-03-03 22:02:19 +0000866 if ($t_author) {
867 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +0000868 my $href = translate_commands($t_authorURL);
869 $href = make_named_href('author', $href, "<strong>${t_author}</strong>");
Fred Drakec9a44381998-03-17 06:29:13 +0000870 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +0000871 } else {
Fred Drakec9a44381998-03-17 06:29:13 +0000872 $the_title .= "\n<p><strong>$t_author</strong></p>";
Fred Drake6659c301998-03-03 22:02:19 +0000873 }
Fred Drake08932051998-04-17 02:15:42 +0000874 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +0000875 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +0000876 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +0000877 if ($DEVELOPER_ADDRESS) {
878 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000879 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +0000880 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000881 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +0000882 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +0000883 if ($PYTHON_VERSION) {
884 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
885 $the_title .= "</p>"
886 }
Fred Drakec9a44381998-03-17 06:29:13 +0000887 $the_title .= "\n</center>";
Fred Drake6659c301998-03-03 22:02:19 +0000888 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +0000889 $the_title .= "\n<p>$t_address</p>";
890 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +0000891 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +0000892 $the_title .= "\n<p>$t_email</p>";
893 }# else { $the_title .= "</p>" }
Fred Drake62e43691998-08-10 19:40:44 +0000894 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +0000895}
896
897
Fred Drake885215c1998-05-20 21:32:09 +0000898#
Fred Drakea0f4c941998-07-24 22:16:04 +0000899# Module synopsis support
900#
901
902require SynopsisTable;
903
Fred Drakef7685d71998-07-25 03:31:46 +0000904sub get_chapter_id(){
905 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +0000906 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
907 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +0000908 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +0000909}
910
Fred Drakef7685d71998-07-25 03:31:46 +0000911%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
912
913sub get_synopsis_table($){
914 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000915 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +0000916 my $key;
917 foreach $key (keys %ModuleSynopses) {
918 if ($key eq $chap) {
919 return $ModuleSynopses{$chap};
920 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000921 }
Fred Drakef7685d71998-07-25 03:31:46 +0000922 $st = SynopsisTable->new();
923 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +0000924 return $st;
925}
926
Fred Drake62e43691998-08-10 19:40:44 +0000927sub do_cmd_moduleauthor{
928 local($_) = @_;
929 next_argument();
930 next_argument();
931 return $_;
932}
933
934sub do_cmd_sectionauthor{
935 local($_) = @_;
936 next_argument();
937 next_argument();
938 return $_;
939}
940
Fred Drakea0f4c941998-07-24 22:16:04 +0000941sub do_cmd_declaremodule{
942 local($_) = @_;
943 my $key = next_optional_argument();
944 my $type = next_argument();
945 my $name = next_argument();
946 my $st = get_synopsis_table(get_chapter_id());
947 #
948 $key = $name unless $key;
949 $type = 'built-in' if $type eq 'builtin';
950 $st->declare($name, $key, $type);
951 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +0000952 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +0000953}
954
955sub do_cmd_modulesynopsis{
956 local($_) = @_;
957 my $st = get_synopsis_table(get_chapter_id());
958 $st->set_synopsis($THIS_MODULE, next_argument());
959 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000960 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000961}
962
963sub do_cmd_localmoduletable{
964 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000965 my $chap = get_chapter_id();
Fred Drake62e43691998-08-10 19:40:44 +0000966 return "<tex2htmllocalmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000967}
968
969sub process_all_localmoduletables{
970 while (/<tex2htmllocalmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +0000971 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +0000972 my $chap = $1;
973 my $st = get_synopsis_table($chap);
974 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +0000975 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +0000976 }
977}
978
979
980#
981# "See also:" -- references placed at the end of a \section
982#
983
984sub do_env_seealso{
Fred Drake62e43691998-08-10 19:40:44 +0000985 return "<p><b>See Also:</b></p>\n" . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +0000986}
987
988sub do_cmd_seemodule{
989 # Insert the right magic to jump to the module definition. This should
990 # work most of the time, at least for repeat builds....
991 local($_) = @_;
992 my $key = next_optional_argument();
993 my $module = next_argument();
994 my $text = next_argument();
995 $key = $module
996 unless $key;
Fred Drake62e43691998-08-10 19:40:44 +0000997 return "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
998 . "&nbsp;&nbsp;&nbsp;($text)</p>"
999 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001000}
1001
1002sub do_cmd_seetext{
Fred Drake62e43691998-08-10 19:40:44 +00001003 return '<p>' . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +00001004}
1005
1006
1007#
Fred Drake885215c1998-05-20 21:32:09 +00001008# Definition list support.
1009#
1010
1011sub do_env_definitions{
1012 local($_) = @_;
1013 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +00001014 return "<dl>$_</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001015}
1016
1017sub do_cmd_term{
1018 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001019 my $term = next_argument();
1020 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001021 swallow_newline();
1022 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001023 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001024}
1025
1026
Fred Drake6659c301998-03-03 22:02:19 +000010271; # This must be the last line