blob: 48cf0dd080a2fed9134a1f4c2a0fcf6a30dd744b [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_sans_serif{
Fred Drakeccc62721999-01-05 22:16:29 +0000105 return use_wrappers(@_[0], '<font face="sans-serif">', '</font>');
Fred Drake62e43691998-08-10 19:40:44 +0000106}
107sub use_italics{
108 return use_wrappers(@_[0], '<i>', '</i>');
109}
Fred Drake08932051998-04-17 02:15:42 +0000110
Fred Drake6659c301998-03-03 22:02:19 +0000111sub do_cmd_optional{
Fred Drake62e43691998-08-10 19:40:44 +0000112 return use_wrappers(@_[0], "</var><big>\[</big><var>",
113 "</var><big>\]</big><var>");
Fred Drake6659c301998-03-03 22:02:19 +0000114}
115
Fred Drakec9a44381998-03-17 06:29:13 +0000116# Logical formatting (some based on texinfo), needs to be converted to
117# minimalist HTML. The "minimalist" is primarily to reduce the size of
118# output files for users that read them over the network rather than
119# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000120
Fred Drake2ff880e1999-02-05 18:31:29 +0000121sub do_cmd_pytype{ return @_[0]; }
122sub do_cmd_makevar{ return @_[0]; }
Fred Drake1a4c5391999-02-09 15:31:52 +0000123sub do_cmd_code{ return use_wrappers(@_[0], '<tt>', '</tt>'); }
Fred Drake62e43691998-08-10 19:40:44 +0000124sub do_cmd_module{ return do_cmd_code(@_); }
125sub do_cmd_keyword{ return do_cmd_code(@_); }
126sub do_cmd_exception{ return do_cmd_code(@_); }
127sub do_cmd_class{ return do_cmd_code(@_); }
128sub do_cmd_function{ return do_cmd_code(@_); }
129sub do_cmd_constant{ return do_cmd_code(@_); }
130sub do_cmd_member{ return do_cmd_code(@_); }
131sub do_cmd_method{ return do_cmd_code(@_); }
132sub do_cmd_cfunction{ return do_cmd_code(@_); }
133sub do_cmd_cdata{ return do_cmd_code(@_); }
134sub do_cmd_ctype{ return do_cmd_code(@_); }
135sub do_cmd_regexp{ return do_cmd_code(@_); }
136sub do_cmd_character{ return do_cmd_samp(@_); }
137sub do_cmd_program{ return do_cmd_strong(@_); }
138sub do_cmd_email{ return use_sans_serif(@_); }
139sub do_cmd_mimetype{ return use_sans_serif(@_); }
Fred Drake1a4c5391999-02-09 15:31:52 +0000140sub do_cmd_var{ return use_wrappers(@_[0], "<i>", "</i>"); }
Fred Drake62e43691998-08-10 19:40:44 +0000141sub do_cmd_dfn{ return use_italics(@_); } # make an index entry?
142sub do_cmd_emph{ return use_italics(@_); }
143sub do_cmd_file{ return use_wrappers(@_[0], '"<tt>', '</tt>"'); }
Fred Drake1a4c5391999-02-09 15:31:52 +0000144sub do_cmd_samp{ return use_wrappers(@_[0], '"<tt>', '</tt>"'); }
Fred Drake62e43691998-08-10 19:40:44 +0000145sub do_cmd_kbd{ return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
146sub do_cmd_strong{ return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drakec9a44381998-03-17 06:29:13 +0000147
Fred Drake25817041999-01-13 17:06:34 +0000148sub do_cmd_refmodule{
149 # Insert the right magic to jump to the module definition.
150 local($_) = @_;
151 my $key = next_optional_argument();
152 my $module = next_argument();
153 $key = $module
154 unless $key;
155 return "<tt><a href=\"module-$key.html\">$module</a></tt>" . $_;
156}
157
Fred Drake1a7af391998-04-01 22:44:56 +0000158sub do_cmd_newsgroup{
159 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000160 my $newsgroup = next_argument();
Fred Drake1a7af391998-04-01 22:44:56 +0000161 my $stuff = "<a href=\"news:$newsgroup\"><font face=sans-serif>"
162 . "$newsgroup</font></a>";
Fred Drake62e43691998-08-10 19:40:44 +0000163 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000164}
Fred Drakefc16e781998-03-12 21:03:26 +0000165
166sub do_cmd_envvar{
167 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000168 my $envvar = next_argument();
169 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000170 # The <tt> here is really to keep buildindex.py from making
171 # the variable name case-insensitive.
172 add_index_entry("environment variables!$envvar@<tt>\$$envvar</tt>",
173 $ahref);
Fred Drake42b31a51998-03-27 05:16:10 +0000174 add_index_entry("$envvar@\$$envvar", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000175 return "$aname\$$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000176}
177
Fred Drake08932051998-04-17 02:15:42 +0000178
Fred Drake6659c301998-03-03 22:02:19 +0000179sub do_cmd_url{
180 # use the URL as both text and hyperlink
181 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000182 my $url = next_argument();
Fred Drake6659c301998-03-03 22:02:19 +0000183 $url =~ s/~/&#126;/g;
Fred Drake62e43691998-08-10 19:40:44 +0000184 return "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000185}
186
187sub do_cmd_manpage{
188 # two parameters: \manpage{name}{section}
189 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000190 my $page = next_argument();
191 my $section = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000192 return "<i>$page</i>($section)" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000193}
194
195sub do_cmd_rfc{
196 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000197 my $rfcnumber = next_argument();
198 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drake2eff3c51998-12-22 18:02:25 +0000199 my $href =
200 "http://info.internet.isi.edu/in-notes/rfc/files/rfc$rfcnumber.txt";
Fred Drake6659c301998-03-03 22:02:19 +0000201 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000202 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000203 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
204 return "<a name=\"$id\"\nhref=\"$href\">RFC $rfcnumber</a>" .$_;
Fred Drake6659c301998-03-03 22:02:19 +0000205}
206
Fred Drake6659c301998-03-03 22:02:19 +0000207sub do_cmd_deprecated{
208 # two parameters: \deprecated{version}{whattodo}
209 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000210 my $release = next_argument();
211 my $reason = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000212 return "<b>Deprecated since release $release.</b>\n$reason<p>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000213}
214
Fred Drake897d12b1998-07-27 20:33:17 +0000215sub do_cmd_versionadded{
216 # one parameter: \versionadded{version}
217 local($_) = @_;
218 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000219 return "\nNew in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000220}
221
222sub do_cmd_versionchanged{
223 # one parameter: \versionchanged{version}
224 local($_) = @_;
225 my $release = next_argument();
Fred Drake2116d981999-02-02 18:02:48 +0000226 return "\nChanged in version $release.\n" . $_;
Fred Drake897d12b1998-07-27 20:33:17 +0000227}
228
Fred Drake6659c301998-03-03 22:02:19 +0000229# file and samp are at the end of this file since they screw up fontlock.
230
231# index commands
232
233$INDEX_SUBITEM = "";
234
235sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000236 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000237}
238
239sub do_cmd_setindexsubitem{
240 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000241 my $subitem = next_argument();
242 $INDEX_SUBITEM = $subitem;
Fred Drake62e43691998-08-10 19:40:44 +0000243 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000244}
245
Fred Drakefc16e781998-03-12 21:03:26 +0000246sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000247 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000248 # do things in the right order, but we need to at least strip this stuff
249 # out, and leave anything that the second argument expanded out to.
250 #
251 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000252 my $oldsubitem = $INDEX_SUBITEM;
253 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000254 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000255 my $br_id = ++$globals{'max_id'};
256 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000257 return
258 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000259 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000260 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000261}
262
Fred Drake08932051998-04-17 02:15:42 +0000263# This is the prologue macro which is required to start writing the
264# mod\jobname.idx file; we can just ignore it.
265#
Fred Drake62e43691998-08-10 19:40:44 +0000266sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000267
Fred Drake42b31a51998-03-27 05:16:10 +0000268# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000269#
Fred Drake08932051998-04-17 02:15:42 +0000270open(IDXFILE, '>index.dat') || die "\n$!\n";
271open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000272print INTLABELS "%internal_labels = ();\n";
273print INTLABELS "1; # hack in case there are no entries\n\n";
274
275# Using \0 for this is bad because we can't use common tools to work with the
276# resulting files. Things like grep can be useful with this stuff!
277#
278$IDXFILE_FIELD_SEP = "\1";
279
Fred Drakeccc62721999-01-05 22:16:29 +0000280sub write_idxfile{
281 my ($ahref, $str) = @_;
282 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000283}
284
Fred Drake42b31a51998-03-27 05:16:10 +0000285
286sub gen_link{
287 my($node,$target) = @_;
288 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drake62e43691998-08-10 19:40:44 +0000289 return "<a href=\"$node#$target\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000290}
291
292sub make_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000293 my($str) = @_;
294 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000295 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000296 return "$aname$anchor_invisible_mark</a>";
Fred Drake42b31a51998-03-27 05:16:10 +0000297}
298
299sub add_index_entry{
300 # add an entry to the index structures; ignore the return value
301 my($str,$ahref) = @_;
302 $str = gen_index_id($str, '');
303 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000304 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000305}
306
Fred Drakeccc62721999-01-05 22:16:29 +0000307sub new_link_info{
308 my $name = "l2h-" . ++$globals{'max_id'};
309 my $aname = '<a name="' . $name . '">';
Fred Drake42b31a51998-03-27 05:16:10 +0000310 my $ahref = gen_link($CURRENT_FILE, $name);
311 return ($name, $aname, $ahref);
312}
313
314sub do_cmd_index{
315 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000316 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000317 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000318 #
Fred Drakeccc62721999-01-05 22:16:29 +0000319 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000320 add_index_entry("$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000321 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000322}
323
Fred Drake2e7edb81998-05-11 18:31:17 +0000324sub do_cmd_kwindex{
325 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000326 my $str = next_argument();
Fred Drake2e7edb81998-05-11 18:31:17 +0000327 #
Fred Drakeccc62721999-01-05 22:16:29 +0000328 my($name,$aname,$ahref) = new_link_info();
Fred Drake2e7edb81998-05-11 18:31:17 +0000329 add_index_entry("<tt>$str</tt>!keyword", $ahref);
330 add_index_entry("keyword!<tt>$str</tt>", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000331 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake2e7edb81998-05-11 18:31:17 +0000332}
333
Fred Drake6659c301998-03-03 22:02:19 +0000334sub do_cmd_indexii{
335 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000336 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000337 my $str2 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000338 #
Fred Drakeccc62721999-01-05 22:16:29 +0000339 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000340 add_index_entry("$str1!$str2", $ahref);
341 add_index_entry("$str2!$str1", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000342 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000343}
344
345sub do_cmd_indexiii{
346 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000347 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000348 my $str2 = next_argument();
349 my $str3 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000350 #
Fred Drakeccc62721999-01-05 22:16:29 +0000351 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000352 add_index_entry("$str1!$str2 $str3", $ahref);
353 add_index_entry("$str2!$str3, $str1", $ahref);
354 add_index_entry("$str3!$str1 $str2", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000355 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000356}
357
358sub do_cmd_indexiv{
359 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000360 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000361 my $str2 = next_argument();
362 my $str3 = next_argument();
363 my $str4 = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000364 #
Fred Drakeccc62721999-01-05 22:16:29 +0000365 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000366 add_index_entry("$str1!$str2 $str3 $str4", $ahref);
367 add_index_entry("$str2!$str3 $str4, $str1", $ahref);
368 add_index_entry("$str3!$str4, $str1 $str2", $ahref);
369 add_index_entry("$str4!$$str1 $str2 $str3", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000370 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000371}
372
Fred Drakec9a44381998-03-17 06:29:13 +0000373sub do_cmd_ttindex{
374 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000375 my $str = next_argument();
376 my $entry = $str . get_indexsubitem();
Fred Drake08932051998-04-17 02:15:42 +0000377 swallow_newline();
Fred Drakeccc62721999-01-05 22:16:29 +0000378 return make_index_entry($entry) . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000379}
Fred Drake6659c301998-03-03 22:02:19 +0000380
381sub my_typed_index_helper{
Fred Drakec9a44381998-03-17 06:29:13 +0000382 local($word,$_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000383 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000384 swallow_newline();
Fred Drake42b31a51998-03-27 05:16:10 +0000385 #
Fred Drakeccc62721999-01-05 22:16:29 +0000386 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000387 add_index_entry("$str $word", $ahref);
388 add_index_entry("$word!$str", $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000389 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000390}
391
Fred Drake62e43691998-08-10 19:40:44 +0000392sub do_cmd_stindex{ return my_typed_index_helper('statement', @_); }
393sub do_cmd_opindex{ return my_typed_index_helper('operator', @_); }
394sub do_cmd_exindex{ return my_typed_index_helper('exception', @_); }
395sub do_cmd_obindex{ return my_typed_index_helper('object', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000396
397sub my_parword_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 Drakeccc62721999-01-05 22:16:29 +0000401 return make_index_entry("$str ($word)") . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000402}
403
404
Fred Drake6659c301998-03-03 22:02:19 +0000405sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000406 my($str,$define) = @_;
407 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000408 # equivalent of add_index_entry() using $define instead of ''
409 $str = gen_index_id($str, $define);
410 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000411 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000412
Fred Drakec9a44381998-03-17 06:29:13 +0000413 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000414 # add to the module index
Fred Drakec9a44381998-03-17 06:29:13 +0000415 my($nstr,$garbage) = split / /, $str, 2;
Fred Drake42b31a51998-03-27 05:16:10 +0000416 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000417 }
Fred Drake62e43691998-08-10 19:40:44 +0000418 return "$aname$anchor_invisible_mark</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000419}
420
Fred Drakec9a44381998-03-17 06:29:13 +0000421$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000422$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000423
Fred Drakea0f4c941998-07-24 22:16:04 +0000424sub define_module{
425 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000426 my $section_tag = join('', @curr_sec_id);
Fred Drake6659c301998-03-03 22:02:19 +0000427 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000428 $THIS_MODULE = "$name";
Fred Drakeccc62721999-01-05 22:16:29 +0000429 return make_mod_index_entry("<tt>$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000430}
431
432sub my_module_index_helper{
433 local($word, $_) = @_;
434 my $name = next_argument();
435 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000436 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000437}
438
439sub ref_module_index_helper{
440 local($word, $_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000441 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000442 swallow_newline();
Fred Drake6659c301998-03-03 22:02:19 +0000443 $word = "$word " if $word;
Fred Drakeccc62721999-01-05 22:16:29 +0000444 return make_mod_index_entry("<tt>$str</tt> (${word}module)", 'REF') . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000445}
446
Fred Drakec9a44381998-03-17 06:29:13 +0000447sub do_cmd_bifuncindex{
448 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000449 my $str = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000450 my $fname = "<tt>$str()</tt>";
Fred Drakeccc62721999-01-05 22:16:29 +0000451 swallow_newline();
452 return make_index_entry("$fname (built-in function)") . $_;
Fred Drakec9a44381998-03-17 06:29:13 +0000453}
454
Fred Drake62e43691998-08-10 19:40:44 +0000455sub do_cmd_modindex{ return my_module_index_helper('', @_); }
456sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
457sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
458sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000459
460# these should be adjusted a bit....
Fred Drake62e43691998-08-10 19:40:44 +0000461sub do_cmd_refmodindex{ return ref_module_index_helper('', @_); }
462sub do_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
463sub do_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
464sub do_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000465
Fred Drake62e43691998-08-10 19:40:44 +0000466sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000467
468sub init_myformat{
Fred Drake08932051998-04-17 02:15:42 +0000469# $anchor_invisible_mark = '';
Fred Drake6659c301998-03-03 22:02:19 +0000470 $anchor_mark = '';
471 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000472}
Fred Drake42b31a51998-03-27 05:16:10 +0000473init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000474
475# similar to make_index_entry(), but includes the string in the result
476# instead of the dummy filler.
477#
478sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000479 my($str) = @_;
480 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000481 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000482 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000483}
484
Fred Drake6659c301998-03-03 22:02:19 +0000485sub do_env_cfuncdesc{
486 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000487 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000488 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000489 my $arg_list = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000490 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
491 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000492 $idx =~ s/ \(.*\)//;
493 $idx =~ s/\(\)//; # ????
Fred Drake62e43691998-08-10 19:40:44 +0000494 return "<dl><dt>$return_type <b>$idx</b>"
495 . "(<var>$arg_list</var>)\n<dd>"
496 . $_
497 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000498}
499
500sub do_env_ctypedesc{
501 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000502 my $type_name = next_argument();
503 my $idx = make_str_index_entry("<tt>$type_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000504 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000505 return "<dl><dt><b>$idx</b>\n<dd>"
506 . $_
507 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000508}
509
510sub do_env_cvardesc{
511 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000512 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000513 my $var_name = next_argument();
514 my $idx = make_str_index_entry("<tt>$var_name</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000515 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000516 return "<dl><dt>$var_type <b>$idx</b>\n"
517 . '<dd>'
518 . $_
519 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000520}
521
522sub do_env_funcdesc{
523 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000524 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000525 my $arg_list = next_argument();
526 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000527 . get_indexsubitem());
528 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000529 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drake62e43691998-08-10 19:40:44 +0000530 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000531}
532
533sub do_env_funcdescni{
534 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000535 my $function_name = next_argument();
536 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000537 return "<dl><dt><b><tt>$function_name</tt></b> (<var>$arg_list</var>)\n"
538 . "<dd>"
539 . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000540}
541
542sub do_cmd_funcline{
543 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000544 my $function_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000545 my $arg_list = next_argument();
546 my $idx = make_str_index_entry("<tt>$function_name()</tt>"
Fred Drake08932051998-04-17 02:15:42 +0000547 . get_indexsubitem());
Fred Drakec9a44381998-03-17 06:29:13 +0000548 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000549 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000550}
551
552# Change this flag to index the opcode entries. I don't think it's very
553# useful to index them, since they're only presented to describe the dis
554# module.
555#
556$INDEX_OPCODES = 0;
557
558sub do_env_opcodedesc{
559 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000560 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000561 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000562 my $idx;
563 if ($INDEX_OPCODES) {
Fred Drakeccc62721999-01-05 22:16:29 +0000564 $idx = make_str_index_entry(
Fred Drake6659c301998-03-03 22:02:19 +0000565 "<tt>$opcode_name</tt> (byte code instruction)");
Fred Drake08932051998-04-17 02:15:42 +0000566 $idx =~ s/ \(byte code instruction\)//;
567 }
568 else {
569 $idx = "<tt>$opcode_name</tt>";
570 }
571 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000572 if ($arg_list) {
573 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
574 }
Fred Drake62e43691998-08-10 19:40:44 +0000575 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000576}
577
578sub do_env_datadesc{
579 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000580 my $dataname = next_argument();
581 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000582 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000583 return "<dl><dt><b>$idx</b>\n<dd>"
584 . $_
585 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000586}
587
588sub do_env_datadescni{
589 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000590 my $idx = next_argument();
591 if (! $STRING_INDEX_TT) {
592 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000593 }
Fred Drake62e43691998-08-10 19:40:44 +0000594 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000595}
596
597sub do_cmd_dataline{
598 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000599 my $data_name = next_argument();
600 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000601 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000602 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000603}
604
Fred Drake42b31a51998-03-27 05:16:10 +0000605sub do_env_excdesc{
606 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000607 my $excname = next_argument();
608 my $idx = make_str_index_entry("<tt>$excname</tt>");
Fred Drake62e43691998-08-10 19:40:44 +0000609 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000610}
611
Fred Drake62e43691998-08-10 19:40:44 +0000612sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000613
614
Fred Drakec9a44381998-03-17 06:29:13 +0000615sub do_env_classdesc{
616 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000617 $THIS_CLASS = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000618 my $arg_list = next_argument();
619 $idx = make_str_index_entry(
Fred Drake08932051998-04-17 02:15:42 +0000620 "<tt>$THIS_CLASS</tt> (class in $THIS_MODULE)" );
621 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000622 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drakec9a44381998-03-17 06:29:13 +0000623}
624
Fred Drake42b31a51998-03-27 05:16:10 +0000625
626sub do_env_methoddesc{
627 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000628 my $class_name = next_optional_argument();
629 $class_name = $THIS_CLASS
630 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000631 my $method = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000632 my $arg_list = next_argument();
633 my $extra = '';
634 if ($class_name) {
635 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000636 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000637 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000638 $idx =~ s/ \(.*\)//;
639 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000640 return "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000641}
642
643
Fred Drake7d45f6d1999-01-05 14:39:27 +0000644sub do_cmd_methodline{
645 local($_) = @_;
646 my $class_name = next_optional_argument();
647 $class_name = $THIS_CLASS
648 unless $class_name;
649 my $method = next_argument();
650 my $arg_list = next_argument();
651 my $extra = '';
652 if ($class_name) {
653 $extra = " ($class_name method)";
654 }
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000655 my $idx = make_str_index_entry("<tt>$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000656 $idx =~ s/ \(.*\)//;
657 $idx =~ s/\(\)//;
658 return "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>"
659 . $_;
660}
661
662
Fred Draked64a40d1998-09-10 18:59:13 +0000663sub do_cmd_methodlineni{
664 local($_) = @_;
665 next_optional_argument();
666 my $method = next_argument();
667 my $arg_list = next_argument();
668 return "<dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
669 . $_;
670}
671
Fred Drake42b31a51998-03-27 05:16:10 +0000672sub do_env_methoddescni{
673 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000674 next_optional_argument();
675 my $method = next_argument();
676 my $arg_list = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000677 return "<dl><dt><b>$method</b> (<var>$arg_list</var>)\n<dd>"
678 . $_
679 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000680}
681
682
683sub do_env_memberdesc{
684 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000685 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000686 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000687 $class = $THIS_CLASS
688 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000689 my $extra = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000690 $extra = " ($class_name attribute)"
Fred Drakea608feb1998-04-12 03:58:13 +0000691 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000692 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +0000693 $idx =~ s/ \(.*\)//;
694 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000695 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000696}
697
698
Fred Drake5ccf3301998-04-17 20:04:09 +0000699sub do_cmd_memberline{
700 local($_) = @_;
701 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000702 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +0000703 $class = $THIS_CLASS
704 unless $class;
705 my $extra = '';
706 $extra = " ($class_name attribute)"
707 if (!($class eq ''));
Fred Drakeccc62721999-01-05 22:16:29 +0000708 my $idx = make_str_index_entry("<tt>$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +0000709 $idx =~ s/ \(.*\)//;
710 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000711 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000712}
713
Fred Drake42b31a51998-03-27 05:16:10 +0000714sub do_env_memberdescni{
715 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000716 next_optional_argument();
717 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000718 return "<dl><dt><b>$member</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000719}
720
721
Fred Drake5ccf3301998-04-17 20:04:09 +0000722sub do_cmd_memberlineni{
723 local($_) = @_;
724 next_optional_argument();
725 my $member = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000726 return "<dt><b>$member</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +0000727}
728
Fred Drakea0f4c941998-07-24 22:16:04 +0000729@col_aligns = ("<td>", "<td>", "<td>", "<td>");
Fred Drake6659c301998-03-03 22:02:19 +0000730
731sub setup_column_alignments{
732 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000733 my($a1,$a2,$a3,$a4) = split(/[|]/,$_);
734 my($th1,$th2,$th3,$th4) = ('<th>', '<th>', '<th>', '<th>');
Fred Drake08932051998-04-17 02:15:42 +0000735 $col_aligns[0] = (($a1 eq 'c') ? '<td align=center>' : '<td>');
736 $col_aligns[1] = (($a2 eq 'c') ? '<td align=center>' : '<td>');
737 $col_aligns[2] = (($a3 eq 'c') ? '<td align=center>' : '<td>');
Fred Drakea0f4c941998-07-24 22:16:04 +0000738 $col_aligns[3] = (($a4 eq 'c') ? '<td align=center>' : '<td>');
Fred Drake6659c301998-03-03 22:02:19 +0000739 # return the aligned header start tags; only used for \begin{tableiii?}
Fred Drake08932051998-04-17 02:15:42 +0000740 $th1 = (($a1 eq 'l') ? '<th align=left>'
741 : ($a1 eq 'r' ? '<th align=right>' : '<th>'));
742 $th2 = (($a2 eq 'l') ? '<th align=left>'
743 : ($a2 eq 'r' ? '<th align=right>' : '<th>'));
744 $th3 = (($a3 eq 'l') ? '<th align=left>'
745 : ($a3 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drakea0f4c941998-07-24 22:16:04 +0000746 $th4 = (($a4 eq 'l') ? '<th align=left>'
747 : ($a4 eq 'r' ? '<th align=right>' : '<th>'));
Fred Drake62e43691998-08-10 19:40:44 +0000748 return ($th1, $th2, $th3, $th4);
Fred Drake6659c301998-03-03 22:02:19 +0000749}
750
751sub do_env_tableii{
752 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000753 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000754 my $font = next_argument();
755 my $h1 = next_argument();
756 my $h2 = next_argument();
757 $font = ''
758 if ($font eq 'textrm');
759 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000760 return '<table border align=center>'
761 . "\n <tr>$th1<b>$h1</b></th>"
762 . "\n $th2<b>$h2</b></th>"
763 . $_
764 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000765}
766
767sub do_cmd_lineii{
768 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000769 my $c1 = next_argument();
770 my $c2 = next_argument();
771 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000772 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000773 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000774 $efont = "</$font>";
775 }
Fred Drakec9a44381998-03-17 06:29:13 +0000776 my($c1align,$c2align) = @col_aligns[0,1];
Fred Drake62e43691998-08-10 19:40:44 +0000777 return "<tr>$c1align$sfont$c1$efont</td>\n"
778 . " $c2align$c2</td>"
779 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000780}
781
782sub do_env_tableiii{
783 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000784 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000785 my $font = next_argument();
786 my $h1 = next_argument();
787 my $h2 = next_argument();
788 my $h3 = next_argument();
789 $font = ''
790 if ($font eq 'textrm');
791 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000792 return '<table border align=center>'
793 . "\n <tr>$th1<b>$h1</b></th>"
794 . "\n $th2<b>$h2</b></th>"
795 . "\n $th3<b>$h3</b></th>"
796 . $_
797 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000798}
799
800sub do_cmd_lineiii{
801 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000802 my $c1 = next_argument();
803 my $c2 = next_argument();
804 my $c3 = next_argument();
805 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
Fred Drake58b2bfd1998-04-02 20:14:04 +0000806 if ($font) {
Fred Drake5cca42e1998-04-09 17:59:11 +0000807 $sfont = "<$font>";
Fred Drake58b2bfd1998-04-02 20:14:04 +0000808 $efont = "</$font>";
809 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000810 my($c1align,$c2align,$c3align) = @col_aligns[0,1,2];
Fred Drake62e43691998-08-10 19:40:44 +0000811 return "<tr>$c1align$sfont$c1$efont</td>\n"
812 . " $c2align$c2</td>\n"
813 . " $c3align$c3</td>"
814 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000815}
816
Fred Drakea0f4c941998-07-24 22:16:04 +0000817sub do_env_tableiv{
818 local($_) = @_;
819 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
820 my $font = next_argument();
821 my $h1 = next_argument();
822 my $h2 = next_argument();
823 my $h3 = next_argument();
824 my $h4 = next_argument();
825 $font = ''
826 if ($font eq 'textrm');
827 $globals{'lineifont'} = $font;
Fred Drake62e43691998-08-10 19:40:44 +0000828 return '<table border align=center>'
829 . "\n <tr>$th1<b>$h1</b></th>"
830 . "\n $th2<b>$h2</b></th>"
831 . "\n $th3<b>$h3</b></th>"
832 . "\n $th4<b>$h4</b></th>"
833 . $_
834 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +0000835}
836
Fred Drakea0f4c941998-07-24 22:16:04 +0000837sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +0000838 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000839 my $c1 = next_argument();
840 my $c2 = next_argument();
841 my $c3 = next_argument();
842 my $c4 = next_argument();
843 my($font,$sfont,$efont) = ($globals{'lineifont'}, '', '');
844 if ($font) {
845 $sfont = "<$font>";
846 $efont = "</$font>";
847 }
848 my($c1align,$c2align,$c3align,$c4align) = @col_aligns;
Fred Drake62e43691998-08-10 19:40:44 +0000849 return "<tr>$c1align$sfont$c1$efont</td>\n"
850 . " $c2align$c2</td>\n"
851 . " $c3align$c3</td>\n"
852 . " $c4align$c4</td>"
853 . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000854}
855
Fred Drake6659c301998-03-03 22:02:19 +0000856sub do_cmd_maketitle {
857 local($_) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000858 my $the_title = '';
Fred Drake6659c301998-03-03 22:02:19 +0000859 if ($t_title) {
Fred Drakec9a44381998-03-17 06:29:13 +0000860 $the_title .= "<h1 align=center>$t_title</h1>";
Fred Drake08932051998-04-17 02:15:42 +0000861 } else { write_warnings("\nThis document has no title."); }
Fred Drakec9a44381998-03-17 06:29:13 +0000862 $the_title .= "\n<center>";
Fred Drake6659c301998-03-03 22:02:19 +0000863 if ($t_author) {
864 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +0000865 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +0000866 $href = make_named_href('author', $href,
867 "<b><font size='+2'>$t_author</font></b>");
Fred Drakec9a44381998-03-17 06:29:13 +0000868 $the_title .= "\n<p>$href</p>";
Fred Drake6659c301998-03-03 22:02:19 +0000869 } else {
Fred Drake2d1f81e1999-02-09 16:03:31 +0000870 $the_title .= ("\n<p><b><font size='+2'>$t_author</font></b></p>");
Fred Drake6659c301998-03-03 22:02:19 +0000871 }
Fred Drake08932051998-04-17 02:15:42 +0000872 } else { write_warnings("\nThere is no author for this document."); }
Fred Drake6659c301998-03-03 22:02:19 +0000873 if ($t_institute) {
Fred Drakec9a44381998-03-17 06:29:13 +0000874 $the_title .= "\n<p>$t_institute</p>";}
Fred Draked07868a1998-05-14 21:00:28 +0000875 if ($DEVELOPER_ADDRESS) {
876 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000877 if ($t_affil) {
Fred Drakec9a44381998-03-17 06:29:13 +0000878 $the_title .= "\n<p><i>$t_affil</i></p>";}
Fred Drake6659c301998-03-03 22:02:19 +0000879 if ($t_date) {
Fred Drakec9a44381998-03-17 06:29:13 +0000880 $the_title .= "\n<p><strong>$t_date</strong>";
Fred Drake6659c301998-03-03 22:02:19 +0000881 if ($PYTHON_VERSION) {
882 $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";}
883 $the_title .= "</p>"
884 }
Fred Drakec9a44381998-03-17 06:29:13 +0000885 $the_title .= "\n</center>";
Fred Drake6659c301998-03-03 22:02:19 +0000886 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +0000887 $the_title .= "\n<p>$t_address</p>";
888 } else { $the_title .= "\n<p>"}
Fred Drake6659c301998-03-03 22:02:19 +0000889 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +0000890 $the_title .= "\n<p>$t_email</p>";
891 }# else { $the_title .= "</p>" }
Fred Drake62e43691998-08-10 19:40:44 +0000892 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +0000893}
894
895
Fred Drake885215c1998-05-20 21:32:09 +0000896#
Fred Drakea0f4c941998-07-24 22:16:04 +0000897# Module synopsis support
898#
899
900require SynopsisTable;
901
Fred Drakef7685d71998-07-25 03:31:46 +0000902sub get_chapter_id(){
903 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +0000904 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
905 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +0000906 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +0000907}
908
Fred Drakef7685d71998-07-25 03:31:46 +0000909%ModuleSynopses = ('chapter' => 'SynopsisTable instance');
910
911sub get_synopsis_table($){
912 my($chap) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000913 my $st = $ModuleSynopses{$chap};
Fred Drakef7685d71998-07-25 03:31:46 +0000914 my $key;
915 foreach $key (keys %ModuleSynopses) {
916 if ($key eq $chap) {
917 return $ModuleSynopses{$chap};
918 }
Fred Drakea0f4c941998-07-24 22:16:04 +0000919 }
Fred Drakef7685d71998-07-25 03:31:46 +0000920 $st = SynopsisTable->new();
921 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +0000922 return $st;
923}
924
Fred Drake62e43691998-08-10 19:40:44 +0000925sub do_cmd_moduleauthor{
926 local($_) = @_;
927 next_argument();
928 next_argument();
929 return $_;
930}
931
932sub do_cmd_sectionauthor{
933 local($_) = @_;
934 next_argument();
935 next_argument();
936 return $_;
937}
938
Fred Drakea0f4c941998-07-24 22:16:04 +0000939sub do_cmd_declaremodule{
940 local($_) = @_;
941 my $key = next_optional_argument();
942 my $type = next_argument();
943 my $name = next_argument();
944 my $st = get_synopsis_table(get_chapter_id());
945 #
946 $key = $name unless $key;
947 $type = 'built-in' if $type eq 'builtin';
948 $st->declare($name, $key, $type);
949 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +0000950 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +0000951}
952
953sub do_cmd_modulesynopsis{
954 local($_) = @_;
955 my $st = get_synopsis_table(get_chapter_id());
956 $st->set_synopsis($THIS_MODULE, next_argument());
957 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +0000958 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000959}
960
961sub do_cmd_localmoduletable{
962 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000963 my $chap = get_chapter_id();
Fred Drake62e43691998-08-10 19:40:44 +0000964 return "<tex2htmllocalmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000965}
966
967sub process_all_localmoduletables{
968 while (/<tex2htmllocalmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +0000969 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +0000970 my $chap = $1;
971 my $st = get_synopsis_table($chap);
972 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +0000973 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +0000974 }
975}
976
977
978#
979# "See also:" -- references placed at the end of a \section
980#
981
982sub do_env_seealso{
Fred Drake62e43691998-08-10 19:40:44 +0000983 return "<p><b>See Also:</b></p>\n" . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +0000984}
985
986sub do_cmd_seemodule{
987 # Insert the right magic to jump to the module definition. This should
988 # work most of the time, at least for repeat builds....
989 local($_) = @_;
990 my $key = next_optional_argument();
991 my $module = next_argument();
992 my $text = next_argument();
993 $key = $module
994 unless $key;
Fred Drake62e43691998-08-10 19:40:44 +0000995 return "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>"
996 . "&nbsp;&nbsp;&nbsp;($text)</p>"
997 . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +0000998}
999
1000sub do_cmd_seetext{
Fred Drake62e43691998-08-10 19:40:44 +00001001 return '<p>' . @_[0];
Fred Drakea0f4c941998-07-24 22:16:04 +00001002}
1003
1004
1005#
Fred Drake885215c1998-05-20 21:32:09 +00001006# Definition list support.
1007#
1008
1009sub do_env_definitions{
1010 local($_) = @_;
1011 swallow_newline();
Fred Drake62e43691998-08-10 19:40:44 +00001012 return "<dl>$_</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001013}
1014
1015sub do_cmd_term{
1016 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001017 my $term = next_argument();
1018 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001019 swallow_newline();
1020 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001021 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001022}
1023
1024
Fred Drake2ff880e1999-02-05 18:31:29 +00001025process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
1026code # {}
1027samp # {}
1028_RAW_ARG_DEFERRED_CMDS_
1029
1030
Fred Drake6659c301998-03-03 22:02:19 +000010311; # This must be the last line