blob: 020f31e5866aeda12e60124928b85f7459cf4136 [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 Drake2ff880e1999-02-05 18:31:29 +0000104sub use_env_wrappers{
105 local($_,$before,$after,$tag) = @_;
106 push(@open_tags,$tag);
107 my $s = join('', $before,
108 translate_commands(next_argument()), $after, $_);
109 return $s;
Fred Drake62e43691998-08-10 19:40:44 +0000110}
Fred Drake2ff880e1999-02-05 18:31:29 +0000111
Fred Drake62e43691998-08-10 19:40:44 +0000112sub use_sans_serif{
Fred Drakeccc62721999-01-05 22:16:29 +0000113 return use_wrappers(@_[0], '<font face="sans-serif">', '</font>');
Fred Drake62e43691998-08-10 19:40:44 +0000114}
115sub use_italics{
116 return use_wrappers(@_[0], '<i>', '</i>');
117}
Fred Drake08932051998-04-17 02:15:42 +0000118
Fred Drake6659c301998-03-03 22:02:19 +0000119sub do_cmd_optional{
Fred Drake62e43691998-08-10 19:40:44 +0000120 return use_wrappers(@_[0], "</var><big>\[</big><var>",
121 "</var><big>\]</big><var>");
Fred Drake6659c301998-03-03 22:02:19 +0000122}
123
Fred Drakec9a44381998-03-17 06:29:13 +0000124# Logical formatting (some based on texinfo), needs to be converted to
125# minimalist HTML. The "minimalist" is primarily to reduce the size of
126# output files for users that read them over the network rather than
127# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000128
Fred Drake2ff880e1999-02-05 18:31:29 +0000129sub do_cmd_pytype{ return @_[0]; }
130sub do_cmd_makevar{ return @_[0]; }
131sub do_cmd_code{ return use_env_wrappers(@_[0], '<tt>', '</tt>', 'tt'); }
Fred Drake62e43691998-08-10 19:40:44 +0000132sub do_cmd_module{ return do_cmd_code(@_); }
133sub do_cmd_keyword{ return do_cmd_code(@_); }
134sub do_cmd_exception{ return do_cmd_code(@_); }
135sub do_cmd_class{ return do_cmd_code(@_); }
136sub do_cmd_function{ return do_cmd_code(@_); }
137sub do_cmd_constant{ return do_cmd_code(@_); }
138sub do_cmd_member{ return do_cmd_code(@_); }
139sub do_cmd_method{ return do_cmd_code(@_); }
140sub do_cmd_cfunction{ return do_cmd_code(@_); }
141sub do_cmd_cdata{ return do_cmd_code(@_); }
142sub do_cmd_ctype{ return do_cmd_code(@_); }
143sub do_cmd_regexp{ return do_cmd_code(@_); }
144sub do_cmd_character{ return do_cmd_samp(@_); }
145sub do_cmd_program{ return do_cmd_strong(@_); }
146sub do_cmd_email{ return use_sans_serif(@_); }
147sub do_cmd_mimetype{ return use_sans_serif(@_); }
Fred Drake2ff880e1999-02-05 18:31:29 +0000148sub do_cmd_var{
149 local($_, *open_args) = @_;
150 my $prevtag = $open_args[(scalar @open_args) - 1];
151 if ($prevtag eq "code" || $prevtag eq "tt") {
152 # in code of some sort....
153 my $text = next_argument();
154 return "</$prevtag><i>$text</i><$prevtag>$_";
155 }
156 return use_italics(@_); }
Fred Drake62e43691998-08-10 19:40:44 +0000157sub do_cmd_dfn{ return use_italics(@_); } # make an index entry?
158sub do_cmd_emph{ return use_italics(@_); }
159sub do_cmd_file{ return use_wrappers(@_[0], '"<tt>', '</tt>"'); }
Fred Drake2ff880e1999-02-05 18:31:29 +0000160sub do_cmd_samp{ return use_env_wrappers(@_[0], '"<tt>', '</tt>"', 'tt'); }
Fred Drake62e43691998-08-10 19:40:44 +0000161sub do_cmd_kbd{ return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
162sub do_cmd_strong{ return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drakec9a44381998-03-17 06:29:13 +0000163
Fred Drake25817041999-01-13 17:06:34 +0000164sub do_cmd_refmodule{
165 # Insert the right magic to jump to the module definition.
166 local($_) = @_;
167 my $key = next_optional_argument();
168 my $module = next_argument();
169 $key = $module
170 unless $key;
171 return "<tt><a href=\"module-$key.html\">$module</a></tt>" . $_;
172}
173
Fred Drake1a7af391998-04-01 22:44:56 +0000174sub do_cmd_newsgroup{
175 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000176 my $newsgroup = next_argument();
Fred Drake1a7af391998-04-01 22:44:56 +0000177 my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>"
178 . "$newsgroup</font></a>";
Fred Drake62e43691998-08-10 19:40:44 +0000179 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000180}
Fred Drakefc16e781998-03-12 21:03:26 +0000181
182sub do_cmd_envvar{
183 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000184 my $envvar = next_argument();
185 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000186 # The <tt> here is really to keep buildindex.py from making
187 # the variable name case-insensitive.
188 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
189 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000190 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000191 return "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000192}
193
Fred Drake08932051998-04-17 02:15:42 +0000194
Fred Drake6659c301998-03-03 22:02:19 +0000195sub do_cmd_url{
196 # use the URL as both text and hyperlink
197 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000198 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000199 $url =~ s/~/&#126;/g;
Fred Drake62e43691998-08-10 19:40:44 +0000200 return "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000201}
202
203sub do_cmd_manpage{
204 # two parameters: \manpage{name}{section}
205 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000206 my $page = next_argument();
207 my $section = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000208 return "<i>$page</i>($section)" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000209}
210
211sub do_cmd_rfc{
212 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000213 my $rfcnumber = next_argument();
214 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake2eff3c51998-12-22 18:02:25 +0000215 my $href =
216 "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt";
Fred Drake6659c301998-03-03 22:02:19 +0000217 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000218 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000219 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
220 return "<a name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>" .$_;
Fred Drake6659c301998-03-03 22:02:19 +0000221}
222
Fred Drake6659c301998-03-03 22:02:19 +0000223sub do_cmd_deprecated{
224 # two parameters: \deprecated{version}{whattodo}
225 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000226 my $release = next_argument();
227 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000228 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000229}
230
Fred Drake897d12b1998-07-27 20:33:17 +0000231sub do_cmd_versionadded{
232 # one parameter: \versionadded{version}
233 local($_) = @_;
234 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000235 return "\nNew in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000236}
237
238sub do_cmd_versionchanged{
239 # one parameter: \versionchanged{version}
240 local($_) = @_;
241 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000242 return "\nChanged in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000243}
244
Fred Drake6659c301998-03-03 22:02:19 +0000245# file and samp are at the end of this file since they screw up fontlock.
246
247# index commands
248
249$INDEX_SUBITEM = "";
250
251sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000252 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000253}
254
255sub do_cmd_setindexsubitem{
256 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000257 my $subitem = next_argument();
258 $INDEX_SUBITEM = $subitem;
Fred Drake62e43691998-08-10 19:40:44 +0000259 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000260}
261
Fred Drakefc16e781998-03-12 21:03:26 +0000262sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000263 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000264 # do things in the right order, but we need to at least strip this stuff
265 # out, and leave anything that the second argument expanded out to.
266 #
267 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000268 my $oldsubitem = $INDEX_SUBITEM;
269 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000270 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000271 my $br_id = ++$globals{'max_id'};
272 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000273 return
274 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000275 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000276 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000277}
278
Fred Drake08932051998-04-17 02:15:42 +0000279# This is the prologue macro which is required to start writing the
280# mod\jobname.idx file; we can just ignore it.
281#
Fred Drake62e43691998-08-10 19:40:44 +0000282sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000283
Fred Drake42b31a51998-03-27 05:16:10 +0000284# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000285#
Fred Drake08932051998-04-17 02:15:42 +0000286open(IDXFILE, '>index.dat') || die "\n$!\n";
287open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000288print INTLABELS "%internal_labels = ();\n";
289print INTLABELS "1; # hack in case there are no entries\n\n";
290
291# Using \0 for this is bad because we can't use common tools to work with the
292# resulting files. Things like grep can be useful with this stuff!
293#
294$IDXFILE_FIELD_SEP = "\1";
295
Fred Drakeccc62721999-01-05 22:16:29 +0000296sub write_idxfile{
297 my ($ahref, $str) = @_;
298 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000299}
300
Fred Drake42b31a51998-03-27 05:16:10 +0000301
302sub gen_link{
303 my($node,$target) = @_;
304 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drake62e43691998-08-10 19:40:44 +0000305 return "<a href=\"$node#$target\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000306}
307
308sub make_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000309 my($str) = @_;
310 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000311 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000312 return "$aname$anchor_invisible_mark</a>";
Fred Drake42b31a51998-03-27 05:16:10 +0000313}
314
315sub add_index_entry{
316 # add an entry to the index structures; ignore the return value
317 my($str,$ahref) = @_;
318 $str = gen_index_id($str, '');
319 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000320 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000321}
322
Fred Drakeccc62721999-01-05 22:16:29 +0000323sub new_link_info{
324 my $name = "l2h-" . ++$globals{'max_id'};
325 my $aname = '<a name="' . $name . '">';
Fred Drake42b31a51998-03-27 05:16:10 +0000326 my $ahref = gen_link($CURRENT_FILE, $name);
327 return ($name, $aname, $ahref);
328}
329
330sub do_cmd_index{
331 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000332 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000333 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000334 #
Fred Drakeccc62721999-01-05 22:16:29 +0000335 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000336 add_index_entry("$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000337 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000338}
339
Fred Drake2e7edb81998-05-11 18:31:17 +0000340sub do_cmd_kwindex{
341 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000342 my $str = next_argument();
Fred Drake2e7edb81998-05-11 18:31:17 +0000343 #
Fred Drakeccc62721999-01-05 22:16:29 +0000344 my($name,$aname,$ahref) = new_link_info();
Fred Drake2e7edb81998-05-11 18:31:17 +0000345 add_index_entry("<tt>$str</tt>!keyword", $ahref);
346 add_index_entry("keyword!<tt>$str</tt>", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000347 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake2e7edb81998-05-11 18:31:17 +0000348}
349
Fred Drake6659c301998-03-03 22:02:19 +0000350sub do_cmd_indexii{
351 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000352 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000353 my $str2 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000354 #
Fred Drakeccc62721999-01-05 22:16:29 +0000355 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000356 add_index_entry("$str1!$str2", $ahref);
357 add_index_entry("$str2!$str1", $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_indexiii{
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();
Fred Drake42b31a51998-03-27 05:16:10 +0000366 #
Fred Drakeccc62721999-01-05 22:16:29 +0000367 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000368 add_index_entry("$str1!$str2 $str3", $ahref);
369 add_index_entry("$str2!$str3, $str1", $ahref);
370 add_index_entry("$str3!$str1 $str2", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000371 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000372}
373
374sub do_cmd_indexiv{
375 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000376 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000377 my $str2 = next_argument();
378 my $str3 = next_argument();
379 my $str4 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000380 #
Fred Drakeccc62721999-01-05 22:16:29 +0000381 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000382 add_index_entry("$str1!$str2 $str3 $str4", $ahref);
383 add_index_entry("$str2!$str3 $str4, $str1", $ahref);
384 add_index_entry("$str3!$str4, $str1 $str2", $ahref);
385 add_index_entry("$str4!$$str1 $str2 $str3", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000386 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000387}
388
Fred Drakec9a44381998-03-17 06:29:13 +0000389sub do_cmd_ttindex{
390 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000391 my $str = next_argument();
392 my $entry = $str . get_indexsubitem();
Fred Drake08932051998-04-17 02:15:42 +0000393 swallow_newline();
Fred Drakeccc62721999-01-05 22:16:29 +0000394 return make_index_entry($entry) . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000395}
Fred Drake6659c301998-03-03 22:02:19 +0000396
397sub my_typed_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000398 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000399 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000400 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000401 #
Fred Drakeccc62721999-01-05 22:16:29 +0000402 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000403 add_index_entry("$str $word", $ahref);
404 add_index_entry("$word!$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000405 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000406}
407
Fred Drake62e43691998-08-10 19:40:44 +0000408sub do_cmd_stindex{ return my_typed_index_helper('statement', @_); }
409sub do_cmd_opindex{ return my_typed_index_helper('operator', @_); }
410sub do_cmd_exindex{ return my_typed_index_helper('exception', @_); }
411sub do_cmd_obindex{ return my_typed_index_helper('object', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000412
413sub my_parword_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000414 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000415 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000416 swallow_newline();
Fred Drakeccc62721999-01-05 22:16:29 +0000417 return make_index_entry("$str ($word)") . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000418}
419
420
Fred Drake6659c301998-03-03 22:02:19 +0000421sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000422 my($str,$define) = @_;
423 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000424 # equivalent of add_index_entry() using $define instead of ''
425 $str = gen_index_id($str, $define);
426 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000427 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000428
Fred Drakec9a44381998-03-17 06:29:13 +0000429 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000430 # add to the module index
Fred Drakec9a44381998-03-17 06:29:13 +0000431 my($nstr,$garbage) = split / /, $str, 2;
Fred Drake42b31a51998-03-27 05:16:10 +0000432 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000433 }
Fred Drake62e43691998-08-10 19:40:44 +0000434 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000435}
436
Fred Drakec9a44381998-03-17 06:29:13 +0000437$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000438$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000439
Fred Drakea0f4c941998-07-24 22:16:04 +0000440sub define_module{
441 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000442 my $section_tag = join('', @curr_sec_id);
Fred Drake6659c301998-03-03 22:02:19 +0000443 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000444 $THIS_MODULE = "$name";
Fred Drakeccc62721999-01-05 22:16:29 +0000445 return make_mod_index_entry("<tt>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000446}
447
448sub my_module_index_helper{
449 local($word, $_) = @_;
450 my $name = next_argument();
451 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000452 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000453}
454
455sub ref_module_index_helper{
456 local($word, $_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000457 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000458 swallow_newline();
Fred Drake6659c301998-03-03 22:02:19 +0000459 $word = "$word " if $word;
Fred Drakeccc62721999-01-05 22:16:29 +0000460 return make_mod_index_entry("<tt>$str</tt> (${word}module)", 'REF') . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000461}
462
Fred Drakec9a44381998-03-17 06:29:13 +0000463sub do_cmd_bifuncindex{
464 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000465 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000466 my $fname = "<tt>$str()</tt>";
Fred Drakeccc62721999-01-05 22:16:29 +0000467 swallow_newline();
468 return make_index_entry("$fname (built-in function)") . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000469}
470
Fred Drake62e43691998-08-10 19:40:44 +0000471sub do_cmd_modindex{ return my_module_index_helper('', @_); }
472sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
473sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
474sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000475
476# these should be adjusted a bit....
Fred Drake62e43691998-08-10 19:40:44 +0000477sub do_cmd_refmodindex{ return ref_module_index_helper('', @_); }
478sub do_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
479sub do_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
480sub do_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000481
Fred Drake62e43691998-08-10 19:40:44 +0000482sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000483
484sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000485# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000486 $anchor_mark = '';
487 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000488}
Fred Drake42b31a51998-03-27 05:16:10 +0000489init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000490
491# similar to make_index_entry(), but includes the string in the result
492# instead of the dummy filler.
493#
494sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000495 my($str) = @_;
496 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000497 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000498 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000499}
500
Fred Drake6659c301998-03-03 22:02:19 +0000501sub do_env_cfuncdesc{
502 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000503 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000504 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000505 my $arg_list = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000506 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
507 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000508 $idx =~ s/ \(.*\)//;
509 $idx =~ s/\(\)//; # ????
Fred Drake62e43691998-08-10 19:40:44 +0000510 return "<dl><dt>$return_type <b>$idx</b>"
511 . "(<var>$arg_list</var>)\n<dd>"
512 . $_
513 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000514}
515
516sub do_env_ctypedesc{
517 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000518 my $type_name = next_argument();
519 my $idx = make_str_index_entry("<tt>$type_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000520 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000521 return "<dl><dt><b>$idx</b>\n<dd>"
522 . $_
523 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000524}
525
526sub do_env_cvardesc{
527 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000528 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000529 my $var_name = next_argument();
530 my $idx = make_str_index_entry("<tt>$var_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000531 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000532 return "<dl><dt>$var_type <b>$idx</b>\n"
533 . '<dd>'
534 . $_
535 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000536}
537
538sub do_env_funcdesc{
539 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000540 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000541 my $arg_list = next_argument();
542 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000543 . get_indexsubitem());
544 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000545 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000546 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000547}
548
549sub do_env_funcdescni{
550 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000551 my $function_name = next_argument();
552 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000553 return "<dl><dt><b><tt>$function_name</tt></b> (<var>$arg_list</var>)\n"
554 . "<dd>"
555 . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000556}
557
558sub do_cmd_funcline{
559 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000560 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000561 my $arg_list = next_argument();
562 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000563 . get_indexsubitem());
Fred Drakec9a44381998-03-17 06:29:13 +0000564 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000565 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000566}
567
568# Change this flag to index the opcode entries. I don't think it's very
569# useful to index them, since they're only presented to describe the dis
570# module.
571#
572$INDEX_OPCODES = 0;
573
574sub do_env_opcodedesc{
575 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000576 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000577 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000578 my $idx;
579 if ($INDEX_OPCODES) {
Fred Drakeccc62721999-01-05 22:16:29 +0000580 $idx = make_str_index_entry(
Fred Drake6659c301998-03-03 22:02:19 +0000581 "<tt>$opcode_name</tt> (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000582 $idx =~ s/ \(byte code instruction\)//;
583 }
584 else {
585 $idx = "<tt>$opcode_name</tt>";
586 }
587 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000588 if ($arg_list) {
589 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
590 }
Fred Drake62e43691998-08-10 19:40:44 +0000591 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000592}
593
594sub do_env_datadesc{
595 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000596 my $dataname = next_argument();
597 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000598 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000599 return "<dl><dt><b>$idx</b>\n<dd>"
600 . $_
601 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000602}
603
604sub do_env_datadescni{
605 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000606 my $idx = next_argument();
607 if (! $STRING_INDEX_TT) {
608 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000609 }
Fred Drake62e43691998-08-10 19:40:44 +0000610 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000611}
612
613sub do_cmd_dataline{
614 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000615 my $data_name = next_argument();
616 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000617 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000618 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000619}
620
Fred Drake42b31a51998-03-27 05:16:10 +0000621sub do_env_excdesc{
622 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000623 my $excname = next_argument();
624 my $idx = make_str_index_entry("<tt>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000625 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000626}
627
Fred Drake62e43691998-08-10 19:40:44 +0000628sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000629
630
Fred Drakec9a44381998-03-17 06:29:13 +0000631sub do_env_classdesc{
632 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000633 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000634 my $arg_list = next_argument();
635 $idx = make_str_index_entry(
Fred Drake08932051998-04-17 02:15:42 +0000636 "<tt>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
637 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000638 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000639}
640
Fred Drake42b31a51998-03-27 05:16:10 +0000641
642sub do_env_methoddesc{
643 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000644 my $class_name = next_optional_argument();
645 $class_name = $THIS_CLASS
646 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000647 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000648 my $arg_list = next_argument();
649 my $extra = '';
650 if ($class_name) {
651 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000652 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000653 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000654 $idx =~ s/ \(.*\)//;
655 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000656 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000657}
658
659
Fred Drake7d45f6d1999-01-05 14:39:27 +0000660sub do_cmd_methodline{
661 local($_) = @_;
662 my $class_name = next_optional_argument();
663 $class_name = $THIS_CLASS
664 unless $class_name;
665 my $method = next_argument();
666 my $arg_list = next_argument();
667 my $extra = '';
668 if ($class_name) {
669 $extra = " ($class_name method)";
670 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000671 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000672 $idx =~ s/ \(.*\)//;
673 $idx =~ s/\(\)//;
674 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
675 . $_;
676}
677
678
Fred Draked64a40d1998-09-10 18:59:13 +0000679sub do_cmd_methodlineni{
680 local($_) = @_;
681 next_optional_argument();
682 my $method = next_argument();
683 my $arg_list = next_argument();
684 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
685 . $_;
686}
687
Fred Drake42b31a51998-03-27 05:16:10 +0000688sub do_env_methoddescni{
689 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000690 next_optional_argument();
691 my $method = next_argument();
692 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000693 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
694 . $_
695 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000696}
697
698
699sub do_env_memberdesc{
700 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000701 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000702 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000703 $class = $THIS_CLASS
704 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000705 my $extra = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000706 $extra = " ($class_name attribute)"
Fred Drakea608feb1998-04-12 03:58:13 +0000707 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000708 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000709 $idx =~ s/ \(.*\)//;
710 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000711 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000712}
713
714
Fred Drake5ccf3301998-04-17 20:04:09 +0000715sub do_cmd_memberline{
716 local($_) = @_;
717 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000718 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000719 $class = $THIS_CLASS
720 unless $class;
721 my $extra = '';
722 $extra = " ($class_name attribute)"
723 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000724 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000725 $idx =~ s/ \(.*\)//;
726 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000727 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000728}
729
Fred Drake42b31a51998-03-27 05:16:10 +0000730sub do_env_memberdescni{
731 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000732 next_optional_argument();
733 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000734 return "<dl><dt><b>$member</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000735}
736
737
Fred Drake5ccf3301998-04-17 20:04:09 +0000738sub do_cmd_memberlineni{
739 local($_) = @_;
740 next_optional_argument();
741 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000742 return "<dt><b>$member</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000743}
744
Fred Drakea0f4c941998-07-24 22:16:04 +0000745@col_aligns = ("<td>", "<td>", "<td>", "<td>");
Fred Drake6659c301998-03-03 22:02:19 +0000746
747sub setup_column_alignments{
748 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000749 my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
750 my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>');
Fred Drake08932051998-04-17 02:15:42 +0000751 $col_aligns[0] = (($a1 eq 'c') ? '<td align=center>' : '<td>');
752 $col_aligns[1] = (($a2 eq 'c') ? '<td align=center>' : '<td>');
753 $col_aligns[2] = (($a3 eq 'c') ? '<td align=center>' : '<td>');
Fred Drakea0f4c941998-07-24 22:16:04 +0000754 $col_aligns[3] = (($a4 eq 'c') ? '<td align=center>' : '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000755 # return the aligned header start tags; only used for \begin{tableiii?}
Fred Drake08932051998-04-17 02:15:42 +0000756 $th1 = (($a1 eq 'l') ? '<th align=left>'
757 : ($a1 eq 'r' ? '<th align=right>' : '<th>'));
758 $th2 = (($a2 eq 'l') ? '<th align=left>'
759 : ($a2 eq 'r' ? '<th align=right>' : '<th>'));
760 $th3 = (($a3 eq 'l') ? '<th align=left>'
761 : ($a3 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drakea0f4c941998-07-24 22:16:04 +0000762 $th4 = (($a4 eq 'l') ? '<th align=left>'
763 : ($a4 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drake62e43691998-08-10 19:40:44 +0000764 return ($th1, $th2, $th3, $th4);
Fred Drake6659c301998-03-03 22:02:19 +0000765}
766
767sub do_env_tableii{
768 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000769 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000770 my $font = next_argument();
771 my $h1 = next_argument();
772 my $h2 = next_argument();
773 $font = ''
774 if ($font eq 'textrm');
775 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000776 return '<table border align=center>'
777 . "\n <tr>$th1<b>$h1</b></th>"
778 . "\n $th2<b>$h2</b></th>"
779 . $_
780 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000781}
782
783sub do_cmd_lineii{
784 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000785 my $c1 = next_argument();
786 my $c2 = next_argument();
787 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000788 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000789 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000790 $efont = "</$font>";
791 }
Fred Drakec9a44381998-03-17 06:29:13 +0000792 my($c1align,$c2align) = @col_aligns[0,1];
Fred Drake62e43691998-08-10 19:40:44 +0000793 return "<tr>$c1align$sfont$c1$efont</td>\n"
794 . " $c2align$c2</td>"
795 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000796}
797
798sub do_env_tableiii{
799 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000800 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000801 my $font = next_argument();
802 my $h1 = next_argument();
803 my $h2 = next_argument();
804 my $h3 = next_argument();
805 $font = ''
806 if ($font eq 'textrm');
807 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000808 return '<table border align=center>'
809 . "\n <tr>$th1<b>$h1</b></th>"
810 . "\n $th2<b>$h2</b></th>"
811 . "\n $th3<b>$h3</b></th>"
812 . $_
813 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000814}
815
816sub do_cmd_lineiii{
817 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000818 my $c1 = next_argument();
819 my $c2 = next_argument();
820 my $c3 = next_argument();
821 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000822 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000823 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000824 $efont = "</$font>";
825 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000826 my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
Fred Drake62e43691998-08-10 19:40:44 +0000827 return "<tr>$c1align$sfont$c1$efont</td>\n"
828 . " $c2align$c2</td>\n"
829 . " $c3align$c3</td>"
830 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000831}
832
Fred Drakea0f4c941998-07-24 22:16:04 +0000833sub do_env_tableiv{
834 local($_) = @_;
835 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
836 my $font = next_argument();
837 my $h1 = next_argument();
838 my $h2 = next_argument();
839 my $h3 = next_argument();
840 my $h4 = next_argument();
841 $font = ''
842 if ($font eq 'textrm');
843 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000844 return '<table border align=center>'
845 . "\n <tr>$th1<b>$h1</b></th>"
846 . "\n $th2<b>$h2</b></th>"
847 . "\n $th3<b>$h3</b></th>"
848 . "\n $th4<b>$h4</b></th>"
849 . $_
850 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000851}
852
Fred Drakea0f4c941998-07-24 22:16:04 +0000853sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +0000854 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000855 my $c1 = next_argument();
856 my $c2 = next_argument();
857 my $c3 = next_argument();
858 my $c4 = next_argument();
859 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
860 if ($font) {
861 $sfont = "<$font>";
862 $efont = "</$font>";
863 }
864 my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
Fred Drake62e43691998-08-10 19:40:44 +0000865 return "<tr>$c1align$sfont$c1$efont</td>\n"
866 . " $c2align$c2</td>\n"
867 . " $c3align$c3</td>\n"
868 . " $c4align$c4</td>"
869 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000870}
871
Fred Drake6659c301998-03-03 22:02:19 +0000872sub do_cmd_maketitle {
873 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000874 my $the_title = '';
Fred Drake6659c301998-03-03 22:02:19 +0000875 if ($t_title) {
Fred Drakec9a44381998-03-17 06:29:13 +0000876 $the_title .= "<h1 align=center>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +0000877 } else { write_warnings("\nThis document has no title."); }
Fred Drakec9a44381998-03-17 06:29:13 +0000878 $the_title .= "\n<center>";
Fred Drake6659c301998-03-03 22:02:19 +0000879 if ($t_author) {
880 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +0000881 my $href = translate_commands($t_authorURL);
882 $href = make_named_href('author', $href, "<strong>${t_author}</strong>");
Fred Drakec9a44381998-03-17 06:29:13 +0000883 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +0000884 } else {
Fred Drakec9a44381998-03-17 06:29:13 +0000885 $the_title .= "\n<p><strong>$t_author</strong></p>";
Fred Drake6659c301998-03-03 22:02:19 +0000886 }
Fred Drake08932051998-04-17 02:15:42 +0000887 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +0000888 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +0000889 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +0000890 if ($DEVELOPER_ADDRESS) {
891 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000892 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +0000893 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000894 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +0000895 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +0000896 if ($PYTHON_VERSION) {
897 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
898 $the_title .= "</p>"
899 }
Fred Drakec9a44381998-03-17 06:29:13 +0000900 $the_title .= "\n</center>";
Fred Drake6659c301998-03-03 22:02:19 +0000901 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +0000902 $the_title .= "\n<p>$t_address</p>";
903 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +0000904 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +0000905 $the_title .= "\n<p>$t_email</p>";
906 }# else { $the_title .= "</p>" }
Fred Drake62e43691998-08-10 19:40:44 +0000907 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +0000908}
909
910
Fred Drake885215c1998-05-20 21:32:09 +0000911#
Fred Drakea0f4c941998-07-24 22:16:04 +0000912# Module synopsis support
913#
914
915require SynopsisTable;
916
Fred Drakef7685d71998-07-25 03:31:46 +0000917sub get_chapter_id(){
918 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +0000919 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
920 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +0000921 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +0000922}
923
Fred Drakef7685d71998-07-25 03:31:46 +0000924%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
925
926sub get_synopsis_table($){
927 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000928 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +0000929 my $key;
930 foreach $key (keys %ModuleSynopses) {
931 if ($key eq $chap) {
932 return $ModuleSynopses{$chap};
933 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000934 }
Fred Drakef7685d71998-07-25 03:31:46 +0000935 $st = SynopsisTable->new();
936 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +0000937 return $st;
938}
939
Fred Drake62e43691998-08-10 19:40:44 +0000940sub do_cmd_moduleauthor{
941 local($_) = @_;
942 next_argument();
943 next_argument();
944 return $_;
945}
946
947sub do_cmd_sectionauthor{
948 local($_) = @_;
949 next_argument();
950 next_argument();
951 return $_;
952}
953
Fred Drakea0f4c941998-07-24 22:16:04 +0000954sub do_cmd_declaremodule{
955 local($_) = @_;
956 my $key = next_optional_argument();
957 my $type = next_argument();
958 my $name = next_argument();
959 my $st = get_synopsis_table(get_chapter_id());
960 #
961 $key = $name unless $key;
962 $type = 'built-in' if $type eq 'builtin';
963 $st->declare($name, $key, $type);
964 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +0000965 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +0000966}
967
968sub do_cmd_modulesynopsis{
969 local($_) = @_;
970 my $st = get_synopsis_table(get_chapter_id());
971 $st->set_synopsis($THIS_MODULE, next_argument());
972 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000973 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000974}
975
976sub do_cmd_localmoduletable{
977 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000978 my $chap = get_chapter_id();
Fred Drake62e43691998-08-10 19:40:44 +0000979 return "<tex2htmllocalmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000980}
981
982sub process_all_localmoduletables{
983 while (/<tex2htmllocalmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +0000984 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +0000985 my $chap = $1;
986 my $st = get_synopsis_table($chap);
987 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +0000988 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +0000989 }
990}
991
992
993#
994# "See also:" -- references placed at the end of a \section
995#
996
997sub do_env_seealso{
Fred Drake62e43691998-08-10 19:40:44 +0000998 return "<p><b>See Also:</b></p>\n" . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +0000999}
1000
1001sub do_cmd_seemodule{
1002 # Insert the right magic to jump to the module definition. This should
1003 # work most of the time, at least for repeat builds....
1004 local($_) = @_;
1005 my $key = next_optional_argument();
1006 my $module = next_argument();
1007 my $text = next_argument();
1008 $key = $module
1009 unless $key;
Fred Drake62e43691998-08-10 19:40:44 +00001010 return "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
1011 . "&nbsp;&nbsp;&nbsp;($text)</p>"
1012 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001013}
1014
1015sub do_cmd_seetext{
Fred Drake62e43691998-08-10 19:40:44 +00001016 return '<p>' . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +00001017}
1018
1019
1020#
Fred Drake885215c1998-05-20 21:32:09 +00001021# Definition list support.
1022#
1023
1024sub do_env_definitions{
1025 local($_) = @_;
1026 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +00001027 return "<dl>$_</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001028}
1029
1030sub do_cmd_term{
1031 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001032 my $term = next_argument();
1033 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001034 swallow_newline();
1035 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001036 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001037}
1038
1039
Fred Drake2ff880e1999-02-05 18:31:29 +00001040process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1041code # {}
1042samp # {}
1043_RAW_ARG_DEFERRED_CMDS_
1044
1045
Fred Drake6659c301998-03-03 22:02:19 +000010461; # This must be the last line