blob: de27a2d30e5fd40d0edfe37c3ee15f742ccec907 [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
Fred Drake7a40c072000-10-02 14:43:38 +000011use File::Basename;
12
Fred Drake6659c301998-03-03 22:02:19 +000013
Fred Drake08932051998-04-17 02:15:42 +000014sub next_argument{
Fred Drakeccc62721999-01-05 22:16:29 +000015 my $param;
16 $param = missing_braces()
17 unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
18 ||(s/$next_pair_rx/$param=$2;''/eo));
Fred Drake62e43691998-08-10 19:40:44 +000019 return $param;
Fred Drake08932051998-04-17 02:15:42 +000020}
21
22sub next_optional_argument{
23 my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?");
Fred Drake5ccf3301998-04-17 20:04:09 +000024 s/$rx/$param=$2;''/eo;
Fred Drake62e43691998-08-10 19:40:44 +000025 return $param;
Fred Drake08932051998-04-17 02:15:42 +000026}
27
Fred Drake7a40c072000-10-02 14:43:38 +000028sub make_icon_filename($){
29 my($myname, $mydir, $myext) = fileparse(@_[0], '\..*');
30 chop $mydir;
31 if ($mydir eq '.') {
32 $mydir = $ICONSERVER;
33 }
34 $myext = ".$IMAGE_TYPE"
35 unless $myext;
36 return "$mydir$dd$myname$myext";
37}
38
Fred Drake7a40c072000-10-02 14:43:38 +000039sub get_link_icon($){
40 my $url = @_[0];
41 if ($OFF_SITE_LINK_ICON && ($url =~ /^[-a-zA-Z0-9.]+:/)) {
42 # absolute URL; assume it points off-site
43 my $icon = make_icon_filename($OFF_SITE_LINK_ICON);
Fred Drakef1927a62001-06-20 21:29:30 +000044 return (" <img src=\"$icon\"\n"
45 . ' border="0" class="offsitelink"'
Fred Drake5f84c9b2000-10-03 06:05:25 +000046 . ($OFF_SITE_LINK_ICON_HEIGHT
Fred Drakef1927a62001-06-20 21:29:30 +000047 ? " height=\"$OFF_SITE_LINK_ICON_HEIGHT\""
Fred Drake5f84c9b2000-10-03 06:05:25 +000048 : '')
49 . ($OFF_SITE_LINK_ICON_WIDTH
Fred Drakef1927a62001-06-20 21:29:30 +000050 ? " width=\"$OFF_SITE_LINK_ICON_WIDTH\""
Fred Drake5f84c9b2000-10-03 06:05:25 +000051 : '')
Fred Drakef1927a62001-06-20 21:29:30 +000052 . " alt=\"[off-site link]\"\n"
Fred Drake7a40c072000-10-02 14:43:38 +000053 . " >");
54 }
55 return '';
56}
Fred Drakee16f6791998-05-15 04:28:37 +000057
58# This is a fairly simple hack; it supports \let when it is used to create
59# (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
Fred Drake5b73cdf1998-05-15 16:59:38 +000060# Many possible uses of \let aren't supported or aren't supported correctly.
Fred Drakee16f6791998-05-15 04:28:37 +000061#
62sub do_cmd_let{
63 local($_) = @_;
64 my $matched = 0;
Fred Drake7a4ad0f1998-05-15 13:45:54 +000065 s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
Fred Drakee16f6791998-05-15 04:28:37 +000066 if ($matched) {
67 my($new, $old) = ($1, $3);
68 eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
69 print "\ndefining handler for \\$new using \\$old\n";
70 }
Fred Drake7a4ad0f1998-05-15 13:45:54 +000071 else {
72 s/[\\]([a-zA-Z]+)\s*(=\s*)?([^\\])/$matched=1; ''/es;
73 if ($matched) {
74 my($new, $char) = ($1, $3);
75 eval "sub do_cmd_$new { \"\\$char\" . \@_[0]; }";
76 print "\ndefining handler for \\$new to insert '$char'\n";
77 }
78 else {
79 write_warnings("Could not interpret \\let construct...");
80 }
81 }
Fred Drake62e43691998-08-10 19:40:44 +000082 return $_;
Fred Drakee16f6791998-05-15 04:28:37 +000083}
84
85
Fred Drakec3fd45f2000-06-15 22:41:48 +000086# the older version of LaTeX2HTML we use doesn't support this, but we use it:
87
88sub do_cmd_textasciitilde{ '~' . @_[0]; }
Fred Drake056a71d2001-04-21 05:48:07 +000089sub do_cmd_textasciicircum{ '^' . @_[0]; }
Fred Drake6fe46602001-06-23 03:13:30 +000090sub do_cmd_textbar{ '|' . @_[0]; }
91sub do_cmd_infinity{ '&infin;' . @_[0]; }
92sub do_cmd_plusminus{ '&plusmn;' . @_[0]; }
Fred Drakec3fd45f2000-06-15 22:41:48 +000093
94
Fred Drake6659c301998-03-03 22:02:19 +000095# words typeset in a special way (not in HTML though)
96
97sub do_cmd_ABC{ 'ABC' . @_[0]; }
98sub do_cmd_UNIX{ 'Unix'. @_[0]; }
99sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
100sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
101sub do_cmd_C{ 'C' . @_[0]; }
102sub do_cmd_Cpp{ 'C++' . @_[0]; }
103sub do_cmd_EOF{ 'EOF' . @_[0]; }
Fred Drakee15956b2000-04-03 04:51:13 +0000104sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +0000105
106sub do_cmd_e{ '&#92;' . @_[0]; }
107
Fred Draked07868a1998-05-14 21:00:28 +0000108$DEVELOPER_ADDRESS = '';
Fred Drake3cdb89d2000-09-14 20:17:23 +0000109$SHORT_VERSION = '';
Fred Drakef1927a62001-06-20 21:29:30 +0000110$RELEASE_INFO = '';
Fred Draked04592a2000-10-25 16:15:13 +0000111$PACKAGE_VERSION = '';
Fred Drake6659c301998-03-03 22:02:19 +0000112
Fred Draked04592a2000-10-25 16:15:13 +0000113sub do_cmd_version{ $PACKAGE_VERSION . @_[0]; }
Fred Drake3cdb89d2000-09-14 20:17:23 +0000114sub do_cmd_shortversion{ $SHORT_VERSION . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +0000115sub do_cmd_release{
116 local($_) = @_;
Fred Draked04592a2000-10-25 16:15:13 +0000117 $PACKAGE_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000118 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000119}
120
Fred Drakef1927a62001-06-20 21:29:30 +0000121sub do_cmd_setreleaseinfo{
122 local($_) = @_;
123 $RELEASE_INFO = next_argument();
124 return $_;
125}
126
Fred Drake3cdb89d2000-09-14 20:17:23 +0000127sub do_cmd_setshortversion{
128 local($_) = @_;
129 $SHORT_VERSION = next_argument();
130 return $_;
131}
132
Fred Drake6659c301998-03-03 22:02:19 +0000133sub do_cmd_authoraddress{
134 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +0000135 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000136 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000137}
138
Fred Drakee16f6791998-05-15 04:28:37 +0000139#sub do_cmd_developer{ do_cmd_author(@_[0]); }
140#sub do_cmd_developers{ do_cmd_author(@_[0]); }
141#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +0000142
Fred Drake6659c301998-03-03 22:02:19 +0000143sub do_cmd_hackscore{
144 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000145 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000146 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000147}
148
Fred Drake08932051998-04-17 02:15:42 +0000149sub use_wrappers{
150 local($_,$before,$after) = @_;
151 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000152 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +0000153}
154
Fred Drake3cdb89d2000-09-14 20:17:23 +0000155$IN_DESC_HANDLER = 0;
Fred Drake6659c301998-03-03 22:02:19 +0000156sub do_cmd_optional{
Fred Drake3cdb89d2000-09-14 20:17:23 +0000157 if ($IN_DESC_HANDLER) {
158 return use_wrappers(@_[0], "</var><big>\[</big><var>",
159 "</var><big>\]</big><var>");
160 }
161 else {
162 return use_wrappers(@_[0], "<big>\[</big>", "<big>\]</big>");
163 }
Fred Drake6659c301998-03-03 22:02:19 +0000164}
165
Fred Drakec9a44381998-03-17 06:29:13 +0000166# Logical formatting (some based on texinfo), needs to be converted to
167# minimalist HTML. The "minimalist" is primarily to reduce the size of
168# output files for users that read them over the network rather than
169# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000170
Fred Drake2cafcbb1999-03-25 16:57:04 +0000171# \file and \samp are at the end of this file since they screw up fontlock.
172
Fred Drake2ff880e1999-02-05 18:31:29 +0000173sub do_cmd_pytype{ return @_[0]; }
Fred Drake3d5a04a2000-08-03 17:25:44 +0000174sub do_cmd_makevar{
175 return use_wrappers(@_[0], '<span class="makevar">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000176sub do_cmd_code{
Fred Drakee15956b2000-04-03 04:51:13 +0000177 return use_wrappers(@_[0], '<code>', '</code>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000178sub do_cmd_module{
Fred Drakee15956b2000-04-03 04:51:13 +0000179 return use_wrappers(@_[0], '<tt class="module">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000180sub do_cmd_keyword{
Fred Drakee15956b2000-04-03 04:51:13 +0000181 return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000182sub do_cmd_exception{
Fred Drakee15956b2000-04-03 04:51:13 +0000183 return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000184sub do_cmd_class{
Fred Drakee15956b2000-04-03 04:51:13 +0000185 return use_wrappers(@_[0], '<tt class="class">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000186sub do_cmd_function{
Fred Drakee15956b2000-04-03 04:51:13 +0000187 return use_wrappers(@_[0], '<tt class="function">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000188sub do_cmd_constant{
Fred Drakee15956b2000-04-03 04:51:13 +0000189 return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000190sub do_cmd_member{
Fred Drakee15956b2000-04-03 04:51:13 +0000191 return use_wrappers(@_[0], '<tt class="member">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000192sub do_cmd_method{
Fred Drakee15956b2000-04-03 04:51:13 +0000193 return use_wrappers(@_[0], '<tt class="method">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000194sub do_cmd_cfunction{
Fred Drakee15956b2000-04-03 04:51:13 +0000195 return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000196sub do_cmd_cdata{
Fred Drakee15956b2000-04-03 04:51:13 +0000197 return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000198sub do_cmd_ctype{
Fred Drakee15956b2000-04-03 04:51:13 +0000199 return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000200sub do_cmd_regexp{
Fred Drakee15956b2000-04-03 04:51:13 +0000201 return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000202sub do_cmd_character{
Fred Drakee15956b2000-04-03 04:51:13 +0000203 return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000204sub do_cmd_program{
Fred Drakee15956b2000-04-03 04:51:13 +0000205 return use_wrappers(@_[0], '<b class="program">', '</b>'); }
Fred Drakec9f5fe01999-11-09 16:59:42 +0000206sub do_cmd_programopt{
207 return use_wrappers(@_[0], '<b class="programopt">', '</b>'); }
Fred Drake0cd60212000-04-11 18:46:59 +0000208sub do_cmd_longprogramopt{
209 # note that the --- will be later converted to -- by LaTeX2HTML
210 return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000211sub do_cmd_email{
Fred Drakee15956b2000-04-03 04:51:13 +0000212 return use_wrappers(@_[0], '<span class="email">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000213sub do_cmd_mimetype{
Fred Drakee15956b2000-04-03 04:51:13 +0000214 return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000215sub do_cmd_var{
216 return use_wrappers(@_[0], "<var>", "</var>"); }
217sub do_cmd_dfn{
Fred Drakee15956b2000-04-03 04:51:13 +0000218 return use_wrappers(@_[0], '<i class="dfn">', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000219sub do_cmd_emph{
Fred Drake38178fd2000-09-22 17:05:04 +0000220 return use_wrappers(@_[0], '<i>', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000221sub do_cmd_file{
Fred Drake3d5a04a2000-08-03 17:25:44 +0000222 return use_wrappers(@_[0], '<span class="file">', '</span>'); }
Fred Drakef74e5b71999-04-28 14:58:49 +0000223sub do_cmd_filenq{
Fred Drakee15956b2000-04-03 04:51:13 +0000224 return do_cmd_file(@_[0]); }
Fred Drake90fdda51999-02-16 20:27:42 +0000225sub do_cmd_samp{
Fred Drakee15956b2000-04-03 04:51:13 +0000226 return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000227sub do_cmd_kbd{
228 return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
229sub do_cmd_strong{
230 return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drake2cafcbb1999-03-25 16:57:04 +0000231sub do_cmd_textbf{
232 return use_wrappers(@_[0], '<b>', '</b>'); }
233sub do_cmd_textit{
234 return use_wrappers(@_[0], '<i>', '</i>'); }
235
Fred Drake3d5a04a2000-08-03 17:25:44 +0000236sub do_cmd_moreargs{
237 return '...' . @_[0]; }
238sub do_cmd_unspecified{
239 return '...' . @_[0]; }
240
Fred Drakec9a44381998-03-17 06:29:13 +0000241
Fred Drake25817041999-01-13 17:06:34 +0000242sub do_cmd_refmodule{
243 # Insert the right magic to jump to the module definition.
244 local($_) = @_;
245 my $key = next_optional_argument();
246 my $module = next_argument();
247 $key = $module
248 unless $key;
Fred Drakef1927a62001-06-20 21:29:30 +0000249 return "<tt class=\"module\"><a href=\"module-$key.html\">$module</a></tt>"
Fred Drakee15956b2000-04-03 04:51:13 +0000250 . $_;
Fred Drake25817041999-01-13 17:06:34 +0000251}
252
Fred Drake1a7af391998-04-01 22:44:56 +0000253sub do_cmd_newsgroup{
254 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000255 my $newsgroup = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000256 my $icon = get_link_icon("news:$newsgroup");
Fred Drakef1927a62001-06-20 21:29:30 +0000257 my $stuff = ("<a class=\"newsgroup\" href=\"news:$newsgroup\">"
258 . "$newsgroup$icon</a>");
Fred Drake62e43691998-08-10 19:40:44 +0000259 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000260}
Fred Drakefc16e781998-03-12 21:03:26 +0000261
262sub do_cmd_envvar{
263 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000264 my $envvar = next_argument();
265 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000266 # The <tt> here is really to keep buildindex.py from making
267 # the variable name case-insensitive.
Fred Drakeafc7ce12001-01-22 17:33:24 +0000268 add_index_entry("environment variables!$envvar@<tt>$envvar</tt>",
Fred Drake166abba1998-04-08 23:10:54 +0000269 $ahref);
Fred Drakeafc7ce12001-01-22 17:33:24 +0000270 add_index_entry("$envvar (environment variable)", $ahref);
Fred Drakee15956b2000-04-03 04:51:13 +0000271 $aname =~ s/<a/<a class="envvar"/;
Fred Drakeafc7ce12001-01-22 17:33:24 +0000272 return "$aname$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000273}
274
Fred Drake6659c301998-03-03 22:02:19 +0000275sub do_cmd_url{
276 # use the URL as both text and hyperlink
277 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000278 my $url = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000279 my $icon = get_link_icon($url);
Fred Drake6659c301998-03-03 22:02:19 +0000280 $url =~ s/~/&#126;/g;
Fred Drake7a40c072000-10-02 14:43:38 +0000281 return "<a class=\"url\" href=\"$url\">$url$icon</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000282}
283
284sub do_cmd_manpage{
285 # two parameters: \manpage{name}{section}
286 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000287 my $page = next_argument();
288 my $section = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000289 return "<span class=\"manpage\"><i>$page</i>($section)</span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000290}
291
Fred Drakef1927a62001-06-20 21:29:30 +0000292$PEP_FORMAT = "http://python.sourceforge.net/peps/pep-%04d.html";
293#$RFC_FORMAT = "http://www.ietf.org/rfc/rfc%04d.txt";
294$RFC_FORMAT = "http://www.faqs.org/rfcs/rfc%d.html";
Fred Drakeafc7ce12001-01-22 17:33:24 +0000295
296sub get_rfc_url($$){
297 my($rfcnum, $format) = @_;
Fred Drakef1927a62001-06-20 21:29:30 +0000298 return sprintf($format, $rfcnum);
Fred Drake643d76d2000-09-09 06:07:37 +0000299}
300
301sub do_cmd_pep{
302 local($_) = @_;
303 my $rfcnumber = next_argument();
304 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drakeafc7ce12001-01-22 17:33:24 +0000305 my $href = get_rfc_url($rfcnumber, $PEP_FORMAT);
Fred Drake7a40c072000-10-02 14:43:38 +0000306 my $icon = get_link_icon($href);
Fred Drake643d76d2000-09-09 06:07:37 +0000307 # Save the reference
308 my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", '');
309 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drake7a40c072000-10-02 14:43:38 +0000310 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">PEP $rfcnumber"
311 . "$icon</a>" . $_);
Fred Drake643d76d2000-09-09 06:07:37 +0000312}
313
Fred Drake6659c301998-03-03 22:02:19 +0000314sub do_cmd_rfc{
315 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000316 my $rfcnumber = next_argument();
317 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drakeafc7ce12001-01-22 17:33:24 +0000318 my $href = get_rfc_url($rfcnumber, $RFC_FORMAT);
Fred Drake7a40c072000-10-02 14:43:38 +0000319 my $icon = get_link_icon($href);
Fred Drake6659c301998-03-03 22:02:19 +0000320 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000321 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000322 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drake7a40c072000-10-02 14:43:38 +0000323 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber"
324 . "$icon</a>" . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000325}
326
Fred Drakec9f5fe01999-11-09 16:59:42 +0000327sub do_cmd_citetitle{
328 local($_) = @_;
329 my $url = next_optional_argument();
330 my $title = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000331 my $icon = get_link_icon($url);
Fred Drakec9f5fe01999-11-09 16:59:42 +0000332 my $repl = '';
333 if ($url) {
Fred Drakef1927a62001-06-20 21:29:30 +0000334 $repl = ("<em class=\"citetitle\"><a\n"
335 . " href=\"$url\"\n"
336 . " title=\"$title\"\n"
Fred Drake7a40c072000-10-02 14:43:38 +0000337 . " >$title$icon</a></em>");
Fred Drakec9f5fe01999-11-09 16:59:42 +0000338 }
339 else {
Fred Drakef1927a62001-06-20 21:29:30 +0000340 $repl = "<em class=\"citetitle\"\n >$title</em>";
Fred Drakec9f5fe01999-11-09 16:59:42 +0000341 }
342 return $repl . $_;
343}
344
Fred Drake6659c301998-03-03 22:02:19 +0000345sub do_cmd_deprecated{
346 # two parameters: \deprecated{version}{whattodo}
347 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000348 my $release = next_argument();
349 my $reason = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +0000350 return ('<div class="versionnote">'
351 . "<b>Deprecated since release $release.</b>"
352 . "\n$reason</div><p>"
353 . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000354}
355
Fred Drakec2b29d02001-04-18 03:11:04 +0000356sub versionnote{
357 # one or two parameters: \versionnote[explanation]{version}
358 my $type = @_[0];
359 local $_ = @_[1];
360 my $explanation = next_optional_argument();
Fred Drake897d12b1998-07-27 20:33:17 +0000361 my $release = next_argument();
Fred Drakec2b29d02001-04-18 03:11:04 +0000362 my $text = "$type in version $release.";
363 if ($explanation) {
364 $text = "$type in version $release:\n$explanation.";
365 }
Fred Drakef1927a62001-06-20 21:29:30 +0000366 return "\n<span class=\"versionnote\">$text</span>\n" . $_;
Fred Drakec2b29d02001-04-18 03:11:04 +0000367}
368
369sub do_cmd_versionadded{
370 return versionnote('New', @_);
Fred Drake897d12b1998-07-27 20:33:17 +0000371}
372
373sub do_cmd_versionchanged{
Fred Drakec2b29d02001-04-18 03:11:04 +0000374 return versionnote('Changed', @_);
Fred Drake897d12b1998-07-27 20:33:17 +0000375}
376
Fred Drake557460c1999-03-02 16:05:35 +0000377#
Fred Drake2cafcbb1999-03-25 16:57:04 +0000378# These function handle platform dependency tracking.
Fred Drake557460c1999-03-02 16:05:35 +0000379#
380sub do_cmd_platform{
381 local($_) = @_;
382 my $platform = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000383 $ModulePlatforms{"<tt class=\"module\">$THIS_MODULE</tt>"} = $platform;
Fred Drake557460c1999-03-02 16:05:35 +0000384 $platform = "Macintosh"
Fred Drake085b8121999-04-21 14:00:29 +0000385 if $platform eq 'Mac';
Fred Drakef1927a62001-06-20 21:29:30 +0000386 return "\n<p class=\"availability\">Availability: <span"
387 . "\n class=\"platform\">$platform</span>.</p>\n" . $_;
Fred Drake557460c1999-03-02 16:05:35 +0000388}
389
Fred Drake557460c1999-03-02 16:05:35 +0000390$IGNORE_PLATFORM_ANNOTATION = '';
391sub do_cmd_ignorePlatformAnnotation{
392 local($_) = @_;
393 $IGNORE_PLATFORM_ANNOTATION = next_argument();
394 return $_;
395}
396
Fred Drake6659c301998-03-03 22:02:19 +0000397
398# index commands
399
400$INDEX_SUBITEM = "";
401
402sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000403 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000404}
405
406sub do_cmd_setindexsubitem{
407 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000408 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000409 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000410}
411
Fred Drakefc16e781998-03-12 21:03:26 +0000412sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000413 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000414 # do things in the right order, but we need to at least strip this stuff
415 # out, and leave anything that the second argument expanded out to.
416 #
417 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000418 my $oldsubitem = $INDEX_SUBITEM;
419 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000420 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000421 my $br_id = ++$globals{'max_id'};
422 my $marker = "$O$br_id$C";
Fred Drake7d45f6d1999-01-05 14:39:27 +0000423 return
424 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000425 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000426 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000427}
428
Fred Drake08932051998-04-17 02:15:42 +0000429# This is the prologue macro which is required to start writing the
Fred Drakeab032151999-05-13 18:36:54 +0000430# mod\jobname.idx file; we can just ignore it. (Defining this suppresses
431# a warning that \makemodindex is unknown.)
Fred Drake08932051998-04-17 02:15:42 +0000432#
Fred Drake62e43691998-08-10 19:40:44 +0000433sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000434
Fred Drake42b31a51998-03-27 05:16:10 +0000435# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000436#
Fred Drake08932051998-04-17 02:15:42 +0000437open(IDXFILE, '>index.dat') || die "\n$!\n";
438open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000439print INTLABELS "%internal_labels = ();\n";
440print INTLABELS "1; # hack in case there are no entries\n\n";
441
442# Using \0 for this is bad because we can't use common tools to work with the
443# resulting files. Things like grep can be useful with this stuff!
444#
445$IDXFILE_FIELD_SEP = "\1";
446
Fred Drakeccc62721999-01-05 22:16:29 +0000447sub write_idxfile{
448 my ($ahref, $str) = @_;
449 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000450}
451
Fred Drake42b31a51998-03-27 05:16:10 +0000452
453sub gen_link{
454 my($node,$target) = @_;
455 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drakef1927a62001-06-20 21:29:30 +0000456 return "<a href=\"$node#$target\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000457}
458
Fred Drake42b31a51998-03-27 05:16:10 +0000459sub add_index_entry{
460 # add an entry to the index structures; ignore the return value
461 my($str,$ahref) = @_;
462 $str = gen_index_id($str, '');
463 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000464 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000465}
466
Fred Drakeccc62721999-01-05 22:16:29 +0000467sub new_link_info{
468 my $name = "l2h-" . ++$globals{'max_id'};
Fred Drakef1927a62001-06-20 21:29:30 +0000469 my $aname = "<a name=\"$name\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000470 my $ahref = gen_link($CURRENT_FILE, $name);
471 return ($name, $aname, $ahref);
472}
473
Fred Drakeab032151999-05-13 18:36:54 +0000474$IndexMacroPattern = '';
475sub define_indexing_macro{
476 my $count = @_;
477 my $i = 0;
478 for (; $i < $count; ++$i) {
479 my $name = @_[$i];
480 my $cmd = "idx_cmd_$name";
481 die "\nNo function $cmd() defined!\n"
482 if (!defined &$cmd);
483 eval ("sub do_cmd_$name { return process_index_macros("
484 . "\@_[0], '$name'); }");
485 if (length($IndexMacroPattern) == 0) {
486 $IndexMacroPattern = "$name";
487 }
488 else {
489 $IndexMacroPattern .= "|$name";
490 }
491 }
492}
493
494$DEBUG_INDEXING = 0;
495sub process_index_macros{
Fred Drake42b31a51998-03-27 05:16:10 +0000496 local($_) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000497 my $cmdname = @_[1]; # This is what triggered us in the first place;
498 # we know it's real, so just process it.
Fred Drakeccc62721999-01-05 22:16:29 +0000499 my($name,$aname,$ahref) = new_link_info();
Fred Drakeab032151999-05-13 18:36:54 +0000500 my $cmd = "idx_cmd_$cmdname";
501 print "\nIndexing: \\$cmdname"
502 if $DEBUG_INDEXING;
503 &$cmd($ahref); # modifies $_ and adds index entries
504 while (/^[\s\n]*\\($IndexMacroPattern)</) {
505 $cmdname = "$1";
506 print " \\$cmdname"
507 if $DEBUG_INDEXING;
508 $cmd = "idx_cmd_$cmdname";
509 if (!defined &$cmd) {
510 last;
511 }
512 else {
513 s/^[\s\n]*\\$cmdname//;
514 &$cmd($ahref);
515 }
516 }
Fred Drakeafc7ce12001-01-22 17:33:24 +0000517 if (/^[ \t\r\n]/) {
518 $_ = substr($_, 1);
519 }
Fred Drake62e43691998-08-10 19:40:44 +0000520 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000521}
522
Fred Drakeab032151999-05-13 18:36:54 +0000523define_indexing_macro('index');
524sub idx_cmd_index{
Fred Drakeccc62721999-01-05 22:16:29 +0000525 my $str = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000526 add_index_entry("$str", @_[0]);
Fred Drake2e7edb81998-05-11 18:31:17 +0000527}
528
Fred Drakeab032151999-05-13 18:36:54 +0000529define_indexing_macro('kwindex');
530sub idx_cmd_kwindex{
531 my $str = next_argument();
532 add_index_entry("<tt>$str</tt>!keyword", @_[0]);
533 add_index_entry("keyword!<tt>$str</tt>", @_[0]);
534}
535
536define_indexing_macro('indexii');
537sub idx_cmd_indexii{
Fred Drakeccc62721999-01-05 22:16:29 +0000538 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000539 my $str2 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000540 add_index_entry("$str1!$str2", @_[0]);
541 add_index_entry("$str2!$str1", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000542}
543
Fred Drakeab032151999-05-13 18:36:54 +0000544define_indexing_macro('indexiii');
545sub idx_cmd_indexiii{
Fred Drakeccc62721999-01-05 22:16:29 +0000546 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000547 my $str2 = next_argument();
548 my $str3 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000549 add_index_entry("$str1!$str2 $str3", @_[0]);
550 add_index_entry("$str2!$str3, $str1", @_[0]);
551 add_index_entry("$str3!$str1 $str2", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000552}
553
Fred Drakeab032151999-05-13 18:36:54 +0000554define_indexing_macro('indexiv');
555sub idx_cmd_indexiv{
Fred Drakeccc62721999-01-05 22:16:29 +0000556 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000557 my $str2 = next_argument();
558 my $str3 = next_argument();
559 my $str4 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000560 add_index_entry("$str1!$str2 $str3 $str4", @_[0]);
561 add_index_entry("$str2!$str3 $str4, $str1", @_[0]);
562 add_index_entry("$str3!$str4, $str1 $str2", @_[0]);
563 add_index_entry("$str4!$$str1 $str2 $str3", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000564}
565
Fred Drakeab032151999-05-13 18:36:54 +0000566define_indexing_macro('ttindex');
567sub idx_cmd_ttindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000568 my $str = next_argument();
569 my $entry = $str . get_indexsubitem();
Fred Drakeab032151999-05-13 18:36:54 +0000570 add_index_entry($entry, @_[0]);
Fred Drakec9a44381998-03-17 06:29:13 +0000571}
Fred Drake6659c301998-03-03 22:02:19 +0000572
573sub my_typed_index_helper{
Fred Drakeab032151999-05-13 18:36:54 +0000574 my($word,$ahref) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000575 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000576 add_index_entry("$str $word", $ahref);
577 add_index_entry("$word!$str", $ahref);
Fred Drake6659c301998-03-03 22:02:19 +0000578}
579
Fred Drakeab032151999-05-13 18:36:54 +0000580define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
581sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
582sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
583sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
584sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
Fred Drake6659c301998-03-03 22:02:19 +0000585
Fred Drakeab032151999-05-13 18:36:54 +0000586define_indexing_macro('bifuncindex');
587sub idx_cmd_bifuncindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000588 my $str = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000589 add_index_entry("<tt class=\"function\">$str()</tt> (built-in function)",
Fred Drakee15956b2000-04-03 04:51:13 +0000590 @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000591}
592
593
Fred Drake6659c301998-03-03 22:02:19 +0000594sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000595 my($str,$define) = @_;
596 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000597 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000598 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
599 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000600 $str = gen_index_id($str, $define);
601 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000602 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000603
Fred Drakec9a44381998-03-17 06:29:13 +0000604 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000605 # add to the module index
Fred Drakee15956b2000-04-03 04:51:13 +0000606 $str =~ /(<tt.*<\/tt>)/;
607 my $nstr = $1;
Fred Drake42b31a51998-03-27 05:16:10 +0000608 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000609 }
Fred Drakeafc7ce12001-01-22 17:33:24 +0000610 return "$aname$anchor_invisible_mark2</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000611}
612
Fred Drake557460c1999-03-02 16:05:35 +0000613
Fred Drakec9a44381998-03-17 06:29:13 +0000614$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000615$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000616
Fred Drakea0f4c941998-07-24 22:16:04 +0000617sub define_module{
618 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000619 my $section_tag = join('', @curr_sec_id);
Fred Drake3e4c6141999-05-17 15:00:32 +0000620 if ($word ne "built-in" && $word ne "extension"
621 && $word ne "standard" && $word ne "") {
622 write_warnings("Bad module type '$word'"
623 . " for \\declaremodule (module $name)");
624 $word = "";
625 }
Fred Drake6659c301998-03-03 22:02:19 +0000626 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000627 $THIS_MODULE = "$name";
Fred Drake5942b432000-10-30 06:24:56 +0000628 $INDEX_SUBITEM = "(in module $name)";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000629 print "[$name]";
Fred Drakee15956b2000-04-03 04:51:13 +0000630 return make_mod_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000631 "<tt class=\"module\">$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000632}
633
634sub my_module_index_helper{
635 local($word, $_) = @_;
636 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000637 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000638}
639
Fred Drake62e43691998-08-10 19:40:44 +0000640sub do_cmd_modindex{ return my_module_index_helper('', @_); }
641sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
642sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
643sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000644
Fred Drakeab032151999-05-13 18:36:54 +0000645sub ref_module_index_helper{
Fred Drake37cc0c02000-04-26 18:05:24 +0000646 my($word, $ahref) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000647 my $str = next_argument();
648 $word = "$word " if $word;
Fred Drakef1927a62001-06-20 21:29:30 +0000649 $str = "<tt class=\"module\">$str</tt> (${word}module)";
Fred Drakeab032151999-05-13 18:36:54 +0000650 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
651 # just inline it all here
652 $str = gen_index_id($str, 'REF');
653 $index{$str} .= $ahref;
654 write_idxfile($ahref, $str);
655}
656
Fred Drake6659c301998-03-03 22:02:19 +0000657# these should be adjusted a bit....
Fred Drakeab032151999-05-13 18:36:54 +0000658define_indexing_macro('refmodindex', 'refbimodindex',
659 'refexmodindex', 'refstmodindex');
660sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
661sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
662sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
663sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000664
Fred Drake62e43691998-08-10 19:40:44 +0000665sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000666
667sub init_myformat{
Fred Drakeafc7ce12001-01-22 17:33:24 +0000668 $anchor_invisible_mark = '&nbsp;';
669 $anchor_invisible_mark2 = '';
Fred Drake6659c301998-03-03 22:02:19 +0000670 $anchor_mark = '';
671 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000672}
Fred Drake42b31a51998-03-27 05:16:10 +0000673init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000674
Fred Drakeab032151999-05-13 18:36:54 +0000675# Create an index entry, but include the string in the target anchor
Fred Drake6659c301998-03-03 22:02:19 +0000676# instead of the dummy filler.
677#
678sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000679 my($str) = @_;
680 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000681 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000682 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000683}
684
Fred Drakee15956b2000-04-03 04:51:13 +0000685$REFCOUNTS_LOADED = 0;
686
687sub load_refcounts{
688 $REFCOUNTS_LOADED = 1;
689
Fred Drakee15956b2000-04-03 04:51:13 +0000690 my $myname, $mydir, $myext;
691 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
692 chop $mydir; # remove trailing '/'
693 ($myname, $mydir, $myext) = fileparse($mydir, '\..*');
694 chop $mydir; # remove trailing '/'
695 $mydir = getcwd() . "$dd$mydir"
696 unless $mydir =~ s|^/|/|;
697 local $_;
698 my $filename = "$mydir${dd}api${dd}refcounts.dat";
699 open(REFCOUNT_FILE, "<$filename") || die "\n$!\n";
700 print "[loading API refcount data]";
701 while (<REFCOUNT_FILE>) {
Fred Drakec2578c52000-04-10 18:26:45 +0000702 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
Fred Drakee15956b2000-04-03 04:51:13 +0000703 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
704 #print "\n$func($param) --> $count";
705 $REFCOUNTS{"$func:$param"} = $count;
706 }
707 }
708}
709
710sub get_refcount{
711 my ($func, $param) = @_;
712 load_refcounts()
713 unless $REFCOUNTS_LOADED;
714 return $REFCOUNTS{"$func:$param"};
715}
716
Fred Drake6659c301998-03-03 22:02:19 +0000717sub do_env_cfuncdesc{
718 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000719 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000720 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000721 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000722 my $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000723 "<tt class=\"cfunction\">$function_name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000724 $idx =~ s/ \(.*\)//;
Fred Drake241551c2000-08-11 20:04:19 +0000725 $idx =~ s/\(\)//; # ???? - why both of these?
Fred Drakee15956b2000-04-03 04:51:13 +0000726 my $result_rc = get_refcount($function_name, '');
727 my $rcinfo = '';
728 if ($result_rc eq '+1') {
Fred Drake241551c2000-08-11 20:04:19 +0000729 $rcinfo = 'New reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000730 }
731 elsif ($result_rc eq '0') {
Fred Drake241551c2000-08-11 20:04:19 +0000732 $rcinfo = 'Borrowed reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000733 }
Fred Drakec2578c52000-04-10 18:26:45 +0000734 elsif ($result_rc eq 'null') {
Fred Drake241551c2000-08-11 20:04:19 +0000735 $rcinfo = 'Always <tt class="constant">NULL</tt>';
Fred Drakec2578c52000-04-10 18:26:45 +0000736 }
Fred Drakee15956b2000-04-03 04:51:13 +0000737 if ($rcinfo ne '') {
Fred Drake241551c2000-08-11 20:04:19 +0000738 $rcinfo = ( "\n<div class=\"refcount-info\">"
739 . "\n <span class=\"label\">Return value:</span>"
740 . "\n <span class=\"value\">$rcinfo.</span>"
741 . "\n</div>");
Fred Drakee15956b2000-04-03 04:51:13 +0000742 }
Fred Drakec612a142001-03-29 18:24:08 +0000743 return "<dl><dt>$return_type <b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000744 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000745 . $_
746 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000747}
748
Fred Drakee15956b2000-04-03 04:51:13 +0000749sub do_env_csimplemacrodesc{
750 local($_) = @_;
751 my $name = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000752 my $idx = make_str_index_entry("<tt class=\"macro\">$name</tt>");
Fred Drakee15956b2000-04-03 04:51:13 +0000753 return "<dl><dt><b>$idx</b>\n<dd>"
754 . $_
755 . '</dl>'
756}
757
Fred Drake6659c301998-03-03 22:02:19 +0000758sub do_env_ctypedesc{
759 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000760 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000761 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000762 $index_name = $type_name
763 unless $index_name;
764 my($name,$aname,$ahref) = new_link_info();
Fred Drakef1927a62001-06-20 21:29:30 +0000765 add_index_entry("<tt class=\"ctype\">$index_name</tt> (C type)", $ahref);
766 return "<dl><dt><b><tt class=\"ctype\">$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000767 . $_
768 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000769}
770
771sub do_env_cvardesc{
772 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000773 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000774 my $var_name = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000775 my $idx = make_str_index_entry("<tt class=\"cdata\">$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +0000776 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000777 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000778 return "<dl><dt>$var_type <b>$idx</b>\n"
779 . '<dd>'
780 . $_
781 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000782}
783
Fred Drake3cdb89d2000-09-14 20:17:23 +0000784sub convert_args($){
785 local($IN_DESC_HANDLER) = 1;
786 local($_) = @_;
787 return translate_commands($_);
788}
789
Fred Drake6659c301998-03-03 22:02:19 +0000790sub do_env_funcdesc{
791 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000792 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000793 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +0000794 my $idx = make_str_index_entry("<tt class=\"function\">$function_name()"
795 . '</tt>'
Fred Drake08932051998-04-17 02:15:42 +0000796 . get_indexsubitem());
797 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +0000798 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drakec612a142001-03-29 18:24:08 +0000799 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000800}
801
802sub do_env_funcdescni{
803 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000804 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000805 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +0000806 return "<dl><dt><b><tt class=\"function\">$function_name</tt></b>"
Fred Drakec612a142001-03-29 18:24:08 +0000807 . "(<var>$arg_list</var>)\n"
Fred Drake90fdda51999-02-16 20:27:42 +0000808 . '<dd>'
809 . $_
810 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000811}
812
813sub do_cmd_funcline{
814 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000815 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000816 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +0000817 my $prefix = "<tt class=\"function\">$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +0000818 my $idx = make_str_index_entry($prefix . get_indexsubitem());
819 $prefix =~ s/\(\)//;
820
Fred Drakec612a142001-03-29 18:24:08 +0000821 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000822}
823
Fred Drake6b3fb781999-07-12 16:50:09 +0000824sub do_cmd_funclineni{
825 local($_) = @_;
826 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000827 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +0000828 my $prefix = "<tt class=\"function\">$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +0000829
Fred Drakec612a142001-03-29 18:24:08 +0000830 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6b3fb781999-07-12 16:50:09 +0000831}
832
Fred Drake6659c301998-03-03 22:02:19 +0000833# Change this flag to index the opcode entries. I don't think it's very
834# useful to index them, since they're only presented to describe the dis
835# module.
836#
837$INDEX_OPCODES = 0;
838
839sub do_env_opcodedesc{
840 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000841 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000842 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000843 my $idx;
844 if ($INDEX_OPCODES) {
Fred Drakef1927a62001-06-20 21:29:30 +0000845 $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>"
846 . ' (byte code instruction)');
Fred Drake08932051998-04-17 02:15:42 +0000847 $idx =~ s/ \(byte code instruction\)//;
848 }
849 else {
Fred Drakef1927a62001-06-20 21:29:30 +0000850 $idx = "<tt class=\"opcode\">$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +0000851 }
852 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +0000853 if ($arg_list) {
854 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
855 }
Fred Drake62e43691998-08-10 19:40:44 +0000856 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000857}
858
859sub do_env_datadesc{
860 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000861 my $dataname = next_argument();
862 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000863 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000864 return "<dl><dt><b>$idx</b>\n<dd>"
865 . $_
866 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000867}
868
869sub do_env_datadescni{
870 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000871 my $idx = next_argument();
872 if (! $STRING_INDEX_TT) {
873 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +0000874 }
Fred Drake62e43691998-08-10 19:40:44 +0000875 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000876}
877
878sub do_cmd_dataline{
879 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000880 my $data_name = next_argument();
881 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +0000882 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000883 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000884}
885
Fred Drakeadb272c2000-04-10 17:47:14 +0000886sub do_cmd_datalineni{
887 local($_) = @_;
888 my $data_name = next_argument();
889 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
890}
891
Fred Drake42b31a51998-03-27 05:16:10 +0000892sub do_env_excdesc{
893 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000894 my $excname = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000895 my $idx = make_str_index_entry("<tt class=\"exception\">$excname</tt>");
Fred Drakeab357ec2001-03-02 18:57:05 +0000896 return "<dl><dt><b>exception $idx</b>\n<dd>" . $_ . '</dl>'
Fred Drake42b31a51998-03-27 05:16:10 +0000897}
898
Fred Drake62e43691998-08-10 19:40:44 +0000899sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000900
901
Fred Drake643d76d2000-09-09 06:07:37 +0000902sub handle_classlike_descriptor{
903 local($_, $what) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000904 $THIS_CLASS = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000905 my $arg_list = convert_args(next_argument());
Fred Drakeccc62721999-01-05 22:16:29 +0000906 $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000907 "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +0000908 $idx =~ s/ \(.*\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000909 return ("<dl><dt><b>$what $idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drakeab357ec2001-03-02 18:57:05 +0000910 . $_
911 . '</dl>');
Fred Drakec9a44381998-03-17 06:29:13 +0000912}
913
Fred Drake643d76d2000-09-09 06:07:37 +0000914sub do_env_classdesc{
915 return handle_classlike_descriptor(@_[0], "class");
916}
917
Fred Drake06a01e82001-05-11 01:00:30 +0000918sub do_env_classdescstar{
919 local($_) = @_;
920 $THIS_CLASS = next_argument();
921 $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000922 "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)");
Fred Drake06a01e82001-05-11 01:00:30 +0000923 $idx =~ s/ \(.*\)//;
924 return ("<dl><dt><b>class $idx</b>\n<dd>"
925 . $_
926 . '</dl>');
927}
928
Fred Drake643d76d2000-09-09 06:07:37 +0000929sub do_env_excclassdesc{
930 return handle_classlike_descriptor(@_[0], "exception");
931}
932
Fred Drake42b31a51998-03-27 05:16:10 +0000933
934sub do_env_methoddesc{
935 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000936 my $class_name = next_optional_argument();
937 $class_name = $THIS_CLASS
938 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +0000939 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000940 my $arg_list = convert_args(next_argument());
Fred Drake08932051998-04-17 02:15:42 +0000941 my $extra = '';
942 if ($class_name) {
943 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +0000944 }
Fred Drakef1927a62001-06-20 21:29:30 +0000945 my $idx = make_str_index_entry(
946 "<tt class=\"method\">$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +0000947 $idx =~ s/ \(.*\)//;
948 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000949 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000950}
951
952
Fred Drake7d45f6d1999-01-05 14:39:27 +0000953sub do_cmd_methodline{
954 local($_) = @_;
955 my $class_name = next_optional_argument();
956 $class_name = $THIS_CLASS
957 unless $class_name;
958 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000959 my $arg_list = convert_args(next_argument());
Fred Drake7d45f6d1999-01-05 14:39:27 +0000960 my $extra = '';
961 if ($class_name) {
962 $extra = " ($class_name method)";
963 }
Fred Drakef1927a62001-06-20 21:29:30 +0000964 my $idx = make_str_index_entry(
965 "<tt class=\"method\">$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +0000966 $idx =~ s/ \(.*\)//;
967 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +0000968 return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000969 . $_;
970}
971
972
Fred Draked64a40d1998-09-10 18:59:13 +0000973sub do_cmd_methodlineni{
974 local($_) = @_;
975 next_optional_argument();
976 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000977 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +0000978 return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Draked64a40d1998-09-10 18:59:13 +0000979 . $_;
980}
981
Fred Drake42b31a51998-03-27 05:16:10 +0000982sub do_env_methoddescni{
983 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000984 next_optional_argument();
985 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +0000986 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +0000987 return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000988 . $_
989 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +0000990}
991
992
993sub do_env_memberdesc{
994 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000995 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000996 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000997 $class = $THIS_CLASS
998 unless $class;
Fred Drake08932051998-04-17 02:15:42 +0000999 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +00001000 $extra = " ($class attribute)"
1001 if ($class ne '');
Fred Drakef1927a62001-06-20 21:29:30 +00001002 my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +00001003 $idx =~ s/ \(.*\)//;
1004 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001005 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001006}
1007
1008
Fred Drake5ccf3301998-04-17 20:04:09 +00001009sub do_cmd_memberline{
1010 local($_) = @_;
1011 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001012 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +00001013 $class = $THIS_CLASS
1014 unless $class;
1015 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +00001016 $extra = " ($class attribute)"
1017 if ($class ne '');
Fred Drakef1927a62001-06-20 21:29:30 +00001018 my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +00001019 $idx =~ s/ \(.*\)//;
1020 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001021 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001022}
1023
Fred Drake42b31a51998-03-27 05:16:10 +00001024sub do_env_memberdescni{
1025 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001026 next_optional_argument();
1027 my $member = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001028 return "<dl><dt><b><tt class=\"member\">$member</tt></b>\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +00001029 . $_
1030 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001031}
1032
1033
Fred Drake5ccf3301998-04-17 20:04:09 +00001034sub do_cmd_memberlineni{
1035 local($_) = @_;
1036 next_optional_argument();
1037 my $member = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001038 return "<dt><b><tt class=\"member\">$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001039}
1040
Fred Drakee15956b2000-04-03 04:51:13 +00001041@col_aligns = ('<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +00001042
Fred Drakef74e5b71999-04-28 14:58:49 +00001043sub fix_font{
1044 # do a little magic on a font name to get the right behavior in the first
1045 # column of the output table
1046 my $font = @_[0];
1047 if ($font eq 'textrm') {
1048 $font = '';
1049 }
1050 elsif ($font eq 'file' || $font eq 'filenq') {
Fred Drakee15956b2000-04-03 04:51:13 +00001051 $font = 'tt class="file"';
1052 }
1053 elsif ($font eq 'member') {
1054 $font = 'tt class="member"';
Fred Drakef74e5b71999-04-28 14:58:49 +00001055 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001056 elsif ($font eq 'class') {
1057 $font = 'tt class="class"';
1058 }
Fred Drake7388f732000-06-28 21:06:08 +00001059 elsif ($font eq 'constant') {
1060 $font = 'tt class="constant"';
1061 }
Fred Drakecb0fc9c2000-08-09 13:45:04 +00001062 elsif ($font eq 'kbd') {
1063 $font = 'kbd';
1064 }
Fred Draked04592a2000-10-25 16:15:13 +00001065 elsif ($font eq 'programopt') {
1066 $font = 'b';
1067 }
Fred Drakeafc7ce12001-01-22 17:33:24 +00001068 elsif ($font eq 'exception') {
1069 $font = 'tt class="exception"';
1070 }
Fred Drakef74e5b71999-04-28 14:58:49 +00001071 return $font;
1072}
1073
Fred Drakee15956b2000-04-03 04:51:13 +00001074sub figure_column_alignment{
1075 my $a = @_[0];
1076 my $mark = substr($a, 0, 1);
1077 my $r = '';
1078 if ($mark eq 'c')
1079 { $r = ' align="center"'; }
1080 elsif ($mark eq 'r')
1081 { $r = ' align="right"'; }
1082 elsif ($mark eq 'l')
1083 { $r = ' align="left"'; }
1084 elsif ($mark eq 'p')
1085 { $r = ' align="left"'; }
1086 return $r;
1087}
1088
Fred Drake6659c301998-03-03 22:02:19 +00001089sub setup_column_alignments{
1090 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001091 my($s1,$s2,$s3,$s4) = split(/[|]/,$_);
1092 my $a1 = figure_column_alignment($s1);
1093 my $a2 = figure_column_alignment($s2);
1094 my $a3 = figure_column_alignment($s3);
1095 my $a4 = figure_column_alignment($s4);
1096 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
1097 $col_aligns[1] = "<td$a2>";
1098 $col_aligns[2] = "<td$a3>";
1099 $col_aligns[3] = "<td$a4>";
Fred Drake79189b51999-04-28 13:54:30 +00001100 # return the aligned header start tags
Fred Drakee15956b2000-04-03 04:51:13 +00001101 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>");
1102}
1103
1104sub get_table_col1_fonts{
1105 my $font = $globals{'lineifont'};
1106 my ($sfont,$efont) = ('', '');
1107 if ($font) {
1108 $sfont = "<$font>";
1109 $efont = "</$font>";
1110 $efont =~ s/ .*>/>/;
1111 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001112 return ($sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +00001113}
1114
1115sub do_env_tableii{
1116 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001117 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001118 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001119 my $h1 = next_argument();
1120 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001121 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001122 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001123 my $a1 = $col_aligns[0];
1124 my $a2 = $col_aligns[1];
1125 s/\\lineii</\\lineii[$a1|$a2]</g;
1126 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001127 . "\n <thead>"
1128 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001129 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1130 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001131 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001132 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001133 . "\n <tbody valign=\"baseline\">"
Fred Drake351960d2000-10-26 20:14:58 +00001134 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001135 . "\n </tbody>"
1136 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001137}
1138
Fred Drakeda72b932000-09-21 15:58:02 +00001139sub do_env_longtableii{
1140 return do_env_tableii(@_);
1141}
1142
Fred Drake6659c301998-03-03 22:02:19 +00001143sub do_cmd_lineii{
1144 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001145 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001146 my $c1 = next_argument();
1147 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001148 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001149 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001150 $c2 = '&nbsp;' if ($c2 eq '');
1151 my($c1align,$c2align) = split('\|', $aligns);
1152 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001153 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001154 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001155 }
Fred Drakee15956b2000-04-03 04:51:13 +00001156 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1157 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001158 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001159}
1160
1161sub do_env_tableiii{
1162 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001163 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001164 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001165 my $h1 = next_argument();
1166 my $h2 = next_argument();
1167 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001168 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001169 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001170 my $a1 = $col_aligns[0];
1171 my $a2 = $col_aligns[1];
1172 my $a3 = $col_aligns[2];
1173 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1174 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001175 . "\n <thead>"
1176 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001177 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1178 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1179 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001180 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001181 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001182 . "\n <tbody valign=\"baseline\">"
Fred Drake62e43691998-08-10 19:40:44 +00001183 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001184 . "\n </tbody>"
1185 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001186}
1187
Fred Drakeda72b932000-09-21 15:58:02 +00001188sub do_env_longtableiii{
1189 return do_env_tableiii(@_);
1190}
1191
Fred Drake6659c301998-03-03 22:02:19 +00001192sub do_cmd_lineiii{
1193 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001194 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001195 my $c1 = next_argument();
1196 my $c2 = next_argument();
1197 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001198 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001199 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001200 $c3 = '&nbsp;' if ($c3 eq '');
1201 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1202 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001203 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001204 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001205 }
Fred Drakee15956b2000-04-03 04:51:13 +00001206 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001207 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001208 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001209 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001210}
1211
Fred Drakea0f4c941998-07-24 22:16:04 +00001212sub do_env_tableiv{
1213 local($_) = @_;
1214 my($th1,$th2,$th3,$th4) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001215 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001216 my $h1 = next_argument();
1217 my $h2 = next_argument();
1218 my $h3 = next_argument();
1219 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001220 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001221 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001222 my $a1 = $col_aligns[0];
1223 my $a2 = $col_aligns[1];
1224 my $a3 = $col_aligns[2];
1225 my $a4 = $col_aligns[3];
1226 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1227 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001228 . "\n <thead>"
1229 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001230 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1231 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1232 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1233 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001234 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001235 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001236 . "\n <tbody valign=\"baseline\">"
Fred Drake62e43691998-08-10 19:40:44 +00001237 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001238 . "\n </tbody>"
1239 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001240}
1241
Fred Drakeda72b932000-09-21 15:58:02 +00001242sub do_env_longtableiv{
1243 return do_env_tableiv(@_);
1244}
1245
Fred Drakea0f4c941998-07-24 22:16:04 +00001246sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001247 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001248 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001249 my $c1 = next_argument();
1250 my $c2 = next_argument();
1251 my $c3 = next_argument();
1252 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001253 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001254 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001255 $c4 = '&nbsp;' if ($c4 eq '');
1256 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1257 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001258 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001259 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001260 }
Fred Drakee15956b2000-04-03 04:51:13 +00001261 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001262 . " $c2align$c2</td>\n"
1263 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001264 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001265 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001266}
1267
Fred Drake3be20742000-08-31 06:22:54 +00001268
1269# These can be used to control the title page appearance;
1270# they need a little bit of documentation.
1271#
1272# If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the
1273# $ICONSERVER directory, or include path information (other than "./"). The
1274# default image type will be assumed if an extension is not provided.
1275#
1276# If specified, the "title page" will contain two colums: one containing the
1277# title/author/etc., and the other containing the graphic. Use the other
1278# four variables listed here to control specific details of the layout; all
1279# are optional.
1280#
1281# $TITLE_PAGE_GRAPHIC = "my-company-logo";
1282# $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%";
1283# $TITLE_PAGE_GRAPHIC_WIDTH = 150;
1284# $TITLE_PAGE_GRAPHIC_HEIGHT = 150;
1285# $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0;
1286
1287sub make_my_titlepage() {
1288 my $the_title = "";
Fred Drake6659c301998-03-03 22:02:19 +00001289 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001290 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake3be20742000-08-31 06:22:54 +00001291 }
1292 else {
1293 write_warnings("\nThis document has no title.");
1294 }
Fred Drake6659c301998-03-03 22:02:19 +00001295 if ($t_author) {
1296 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001297 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001298 $href = make_named_href('author', $href,
Fred Drakef1927a62001-06-20 21:29:30 +00001299 "<b><font size=\"+2\">$t_author"
1300 . '</font></b>');
Fred Drakec9a44381998-03-17 06:29:13 +00001301 $the_title .= "\n<p>$href</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001302 }
1303 else {
Fred Drakef1927a62001-06-20 21:29:30 +00001304 $the_title .= ("\n<p><b><font size=\"+2\">$t_author"
1305 . '</font></b></p>');
Fred Drake6659c301998-03-03 22:02:19 +00001306 }
Fred Drake3be20742000-08-31 06:22:54 +00001307 }
1308 else {
1309 write_warnings("\nThere is no author for this document.");
1310 }
Fred Drake6659c301998-03-03 22:02:19 +00001311 if ($t_institute) {
Fred Drake3be20742000-08-31 06:22:54 +00001312 $the_title .= "\n<p>$t_institute</p>";
1313 }
Fred Draked07868a1998-05-14 21:00:28 +00001314 if ($DEVELOPER_ADDRESS) {
Fred Drake3be20742000-08-31 06:22:54 +00001315 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";
1316 }
Fred Drake6659c301998-03-03 22:02:19 +00001317 if ($t_affil) {
Fred Drake3be20742000-08-31 06:22:54 +00001318 $the_title .= "\n<p><i>$t_affil</i></p>";
1319 }
Fred Drake6659c301998-03-03 22:02:19 +00001320 if ($t_date) {
Fred Drakede77bc52000-12-14 18:36:12 +00001321 $the_title .= "\n<p>";
Fred Draked04592a2000-10-25 16:15:13 +00001322 if ($PACKAGE_VERSION) {
Fred Drakef1927a62001-06-20 21:29:30 +00001323 $the_title .= ('<strong>Release '
1324 . "$PACKAGE_VERSION$RELEASE_INFO</strong><br>\n");
Fred Drake3be20742000-08-31 06:22:54 +00001325 }
Fred Drakede77bc52000-12-14 18:36:12 +00001326 $the_title .= "<strong>$t_date</strong></p>"
Fred Drake6659c301998-03-03 22:02:19 +00001327 }
1328 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001329 $the_title .= "\n<p>$t_address</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001330 }
1331 else {
1332 $the_title .= "\n<p>";
1333 }
Fred Drake6659c301998-03-03 22:02:19 +00001334 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001335 $the_title .= "\n<p>$t_email</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001336 }
1337 return $the_title;
1338}
1339
Fred Drake3be20742000-08-31 06:22:54 +00001340sub make_my_titlegraphic() {
Fred Drake7a40c072000-10-02 14:43:38 +00001341 my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC);
Fred Drake3be20742000-08-31 06:22:54 +00001342 my $graphic = "<td class=\"titlegraphic\"";
1343 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\""
1344 if ($TITLE_PAGE_GRAPHIC_COLWIDTH);
1345 $graphic .= "><img";
1346 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\""
1347 if ($TITLE_PAGE_GRAPHIC_WIDTH);
1348 $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\""
1349 if ($TITLE_PAGE_GRAPHIC_HEIGHT);
Fred Drake5f84c9b2000-10-03 06:05:25 +00001350 $graphic .= "\n src=\"$filename\"></td>\n";
Fred Drake3be20742000-08-31 06:22:54 +00001351 return $graphic;
1352}
1353
1354sub do_cmd_maketitle {
1355 local($_) = @_;
1356 my $the_title = "\n<div class=\"titlepage\">";
1357 if ($TITLE_PAGE_GRAPHIC) {
1358 if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) {
1359 $the_title .= ("\n<table border=\"0\" width=\"100%\">"
1360 . "<tr align=\"right\">\n<td>"
1361 . make_my_titlepage()
1362 . "</td>\n"
1363 . make_my_titlegraphic()
1364 . "</tr>\n</table>");
1365 }
1366 else {
1367 $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n"
1368 . make_my_titlegraphic()
1369 . "<td>"
1370 . make_my_titlepage()
1371 . "</td></tr>\n</table>");
1372 }
1373 }
1374 else {
1375 $the_title .= ("\n<center>"
1376 . make_my_titlepage()
1377 . "\n</center>");
1378 }
1379 $the_title .= "\n</div>";
1380 return $the_title . $_;
Fred Drake90fdda51999-02-16 20:27:42 +00001381 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001382 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001383}
1384
1385
Fred Drake885215c1998-05-20 21:32:09 +00001386#
Fred Drakea0f4c941998-07-24 22:16:04 +00001387# Module synopsis support
1388#
1389
1390require SynopsisTable;
1391
Fred Drakef7685d71998-07-25 03:31:46 +00001392sub get_chapter_id(){
1393 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001394 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1395 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001396 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001397}
1398
Fred Drake643d76d2000-09-09 06:07:37 +00001399# 'chapter' => 'SynopsisTable instance'
1400%ModuleSynopses = ();
Fred Drakef7685d71998-07-25 03:31:46 +00001401
1402sub get_synopsis_table($){
1403 my($chap) = @_;
Fred Drakef7685d71998-07-25 03:31:46 +00001404 my $key;
1405 foreach $key (keys %ModuleSynopses) {
1406 if ($key eq $chap) {
1407 return $ModuleSynopses{$chap};
1408 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001409 }
Fred Drake643d76d2000-09-09 06:07:37 +00001410 my $st = SynopsisTable->new();
Fred Drakef7685d71998-07-25 03:31:46 +00001411 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001412 return $st;
1413}
1414
Fred Drake62e43691998-08-10 19:40:44 +00001415sub do_cmd_moduleauthor{
1416 local($_) = @_;
1417 next_argument();
1418 next_argument();
1419 return $_;
1420}
1421
1422sub do_cmd_sectionauthor{
1423 local($_) = @_;
1424 next_argument();
1425 next_argument();
1426 return $_;
1427}
1428
Fred Drakea0f4c941998-07-24 22:16:04 +00001429sub do_cmd_declaremodule{
1430 local($_) = @_;
1431 my $key = next_optional_argument();
1432 my $type = next_argument();
1433 my $name = next_argument();
1434 my $st = get_synopsis_table(get_chapter_id());
1435 #
1436 $key = $name unless $key;
1437 $type = 'built-in' if $type eq 'builtin';
1438 $st->declare($name, $key, $type);
1439 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001440 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001441}
1442
1443sub do_cmd_modulesynopsis{
1444 local($_) = @_;
1445 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001446 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001447 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001448}
1449
1450sub do_cmd_localmoduletable{
1451 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001452 my $chap = get_chapter_id();
Fred Drake643d76d2000-09-09 06:07:37 +00001453 my $st = get_synopsis_table($chap);
1454 $st->set_file("$CURRENT_FILE");
Fred Drake557460c1999-03-02 16:05:35 +00001455 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001456}
1457
1458sub process_all_localmoduletables{
Fred Drake643d76d2000-09-09 06:07:37 +00001459 my $key;
1460 my $st, $file;
1461 foreach $key (keys %ModuleSynopses) {
1462 $st = $ModuleSynopses{$key};
1463 $file = $st->get_file();
1464 if ($file) {
1465 process_localmoduletables_in_file($file);
1466 }
1467 else {
Fred Drake6fe46602001-06-23 03:13:30 +00001468 print "\nsynopsis table $key has no file association\n";
Fred Drake643d76d2000-09-09 06:07:37 +00001469 }
1470 }
1471}
1472
1473sub process_localmoduletables_in_file{
1474 my $file = @_[0];
1475 open(MYFILE, "<$file");
1476 local($_);
1477 sysread(MYFILE, $_, 1024*1024);
1478 close(MYFILE);
1479 # need to get contents of file in $_
Fred Drake557460c1999-03-02 16:05:35 +00001480 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001481 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001482 my $chap = $1;
1483 my $st = get_synopsis_table($chap);
1484 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001485 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001486 }
Fred Drake643d76d2000-09-09 06:07:37 +00001487 open(MYFILE,">$file");
1488 print MYFILE $_;
1489 close(MYFILE);
Fred Drakea0f4c941998-07-24 22:16:04 +00001490}
Fred Drake557460c1999-03-02 16:05:35 +00001491sub process_python_state{
1492 process_all_localmoduletables();
Fred Drake557460c1999-03-02 16:05:35 +00001493}
Fred Drakea0f4c941998-07-24 22:16:04 +00001494
1495
1496#
1497# "See also:" -- references placed at the end of a \section
1498#
1499
1500sub do_env_seealso{
Fred Drakef1927a62001-06-20 21:29:30 +00001501 return ("<div class=\"seealso\">\n "
1502 . "<p class=\"heading\"><b>See Also:</b></p>\n"
1503 . @_[0]
1504 . '</div>');
Fred Drakea0f4c941998-07-24 22:16:04 +00001505}
1506
1507sub do_cmd_seemodule{
1508 # Insert the right magic to jump to the module definition. This should
1509 # work most of the time, at least for repeat builds....
1510 local($_) = @_;
1511 my $key = next_optional_argument();
1512 my $module = next_argument();
1513 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001514 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001515 $key = $module
1516 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001517 if ($text =~ /\.$/) {
1518 $period = '';
1519 }
Fred Drakef1927a62001-06-20 21:29:30 +00001520 return ('<dl compact class="seemodule">'
1521 . "\n <dt>Module <b><tt class=\"module\">"
1522 . "<a href=\"module-$key.html\">$module</a></tt>:</b>"
1523 . "\n <dd>$text$period\n </dl>"
1524 . $_);
Fred Drakea0f4c941998-07-24 22:16:04 +00001525}
1526
Fred Drakee0197bf2001-04-12 04:03:22 +00001527sub strip_html_markup($){
1528 my $str = @_[0];
1529 my $s = "$str";
1530 $s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g;
1531 $s =~ s/<\/[a-zA-Z0-9]+>//g;
1532 return $s;
1533}
1534
Fred Drake643d76d2000-09-09 06:07:37 +00001535sub handle_rfclike_reference{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001536 local($_, $what, $format) = @_;
Fred Drake37cc0c02000-04-26 18:05:24 +00001537 my $rfcnum = next_argument();
1538 my $title = next_argument();
1539 my $text = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +00001540 my $url = get_rfc_url($rfcnum, $format);
Fred Drake7a40c072000-10-02 14:43:38 +00001541 my $icon = get_link_icon($url);
Fred Drakee0197bf2001-04-12 04:03:22 +00001542 my $attrtitle = strip_html_markup($title);
Fred Drake37cc0c02000-04-26 18:05:24 +00001543 return '<dl compact class="seerfc">'
1544 . "\n <dt><a href=\"$url\""
Fred Drakee0197bf2001-04-12 04:03:22 +00001545 . "\n title=\"$attrtitle\""
Fred Drake5f84c9b2000-10-03 06:05:25 +00001546 . "\n >$what $rfcnum, <em>$title</em>$icon</a>"
Fred Drake37cc0c02000-04-26 18:05:24 +00001547 . "\n <dd>$text\n </dl>"
1548 . $_;
1549}
1550
Fred Drake643d76d2000-09-09 06:07:37 +00001551sub do_cmd_seepep{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001552 return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001553}
1554
1555sub do_cmd_seerfc{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001556 return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001557}
1558
Fred Drake48449982000-09-12 17:52:33 +00001559sub do_cmd_seetitle{
1560 local($_) = @_;
1561 my $url = next_optional_argument();
1562 my $title = next_argument();
1563 my $text = next_argument();
1564 if ($url) {
Fred Drake5f84c9b2000-10-03 06:05:25 +00001565 my $icon = get_link_icon($url);
Fred Drake48449982000-09-12 17:52:33 +00001566 return '<dl compact class="seetitle">'
1567 . "\n <dt><em class=\"citetitle\"><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001568 . "\n >$title$icon</a></em>"
Fred Drake48449982000-09-12 17:52:33 +00001569 . "\n <dd>$text\n </dl>"
1570 . $_;
1571 }
1572 return '<dl compact class="seetitle">'
1573 . "\n <dt><em class=\"citetitle\""
1574 . "\n >$title</em>"
1575 . "\n <dd>$text\n </dl>"
1576 . $_;
1577}
1578
Fred Drakeef4d1112000-05-09 16:17:51 +00001579sub do_cmd_seeurl{
1580 local($_) = @_;
1581 my $url = next_argument();
1582 my $text = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +00001583 my $icon = get_link_icon($url);
Fred Drakeef4d1112000-05-09 16:17:51 +00001584 return '<dl compact class="seeurl">'
1585 . "\n <dt><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001586 . "\n class=\"url\">$url$icon</a>"
Fred Drakeef4d1112000-05-09 16:17:51 +00001587 . "\n <dd>$text\n </dl>"
1588 . $_;
1589}
1590
Fred Drakea0f4c941998-07-24 22:16:04 +00001591sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001592 local($_) = @_;
1593 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001594 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001595}
1596
1597
1598#
Fred Drake885215c1998-05-20 21:32:09 +00001599# Definition list support.
1600#
1601
1602sub do_env_definitions{
Fred Drakef1927a62001-06-20 21:29:30 +00001603 return "<dl class=\"definitions\">" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001604}
1605
1606sub do_cmd_term{
1607 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001608 my $term = next_argument();
1609 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001610 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001611 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001612}
1613
1614
Fred Drake38178fd2000-09-22 17:05:04 +00001615# I don't recall exactly why this was needed, but it was very much needed.
1616# We'll see if anything breaks when I move the "code" line out -- some
1617# things broke with it in.
1618
1619#code # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001620process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001621declaremodule # [] # {} # {}
1622memberline # [] # {}
1623methodline # [] # {} # {}
1624modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001625platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001626samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001627setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001628withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001629_RAW_ARG_DEFERRED_CMDS_
1630
1631
Fred Drake86333602001-04-10 17:13:39 +00001632$alltt_start = '<dl><dd><pre class="verbatim">';
1633$alltt_end = '</pre></dl>';
1634
1635sub do_env_alltt {
1636 local ($_) = @_;
1637 local($closures,$reopens,@open_block_tags);
1638
1639 # get the tag-strings for all open tags
1640 local(@keep_open_tags) = @$open_tags_R;
1641 ($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R);
1642
1643 # get the tags for text-level tags only
1644 $open_tags_R = [ @keep_open_tags ];
1645 local($local_closures, $local_reopens);
1646 ($local_closures, $local_reopens,@open_block_tags)
1647 = &preserve_open_block_tags
1648 if (@$open_tags_R);
1649
1650 $open_tags_R = [ @open_block_tags ];
1651
1652 do {
1653 local($open_tags_R) = [ @open_block_tags ];
1654 local(@save_open_tags) = ();
1655
1656 local($cnt) = ++$global{'max_id'};
1657 $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C
1658 , $_ , $O, $global{'max_id'}, "$C$O$cnt$C");
1659
1660 $_ = &translate_environments($_);
1661 $_ = &translate_commands($_) if (/\\/);
1662
1663 # preserve space-runs, using &nbsp;
1664 while (s/(\S) ( +)/$1$2;SPMnbsp;/g){};
1665 s/(<BR>) /$1;SPMnbsp;/g;
1666
1667 $_ = join('', $closures, $alltt_start, $local_reopens
1668 , $_
1669 , &balance_tags() #, $local_closures
1670 , $alltt_end, $reopens);
1671 undef $open_tags_R; undef @save_open_tags;
1672 };
1673 $open_tags_R = [ @keep_open_tags ];
1674 $_;
1675}
1676
Fred Drake57e52ef2001-06-15 21:31:57 +00001677sub do_cmd_verbatiminput{
1678 local($_) = @_;
1679 my $fname = next_argument();
1680 my $file;
1681 my $found = 0;
1682 my $texpath;
1683 # Search TEXINPUTS for the input file, the way we're supposed to:
1684 foreach $texpath (split /$envkey/, $TEXINPUTS) {
1685 $file = "$texpath$dd$fname";
1686 last if ($found = (-f $file));
1687 }
1688 my $text;
1689 if ($found) {
1690 open(MYFILE, "<$file") || die "\n$!\n";
1691 read(MYFILE, $text, 1024*1024);
1692 close(MYFILE);
1693 #
1694 # These rewrites convert the raw text to something that will
1695 # be properly visible as HTML and also will pass through the
1696 # vagaries of conversion through LaTeX2HTML. The order in
1697 # which the specific rewrites are performed is significant.
1698 #
1699 $text =~ s/\&/\&amp;/g;
1700 # These need to happen before the normal < and > re-writes,
1701 # since we need to avoid LaTeX2HTML's attempt to perform
1702 # ligature processing without regard to context (since it
1703 # doesn't have font information).
1704 $text =~ s/--/-&\#45;/g;
1705 $text =~ s/<</\&lt;\&\#60;/g;
1706 $text =~ s/>>/\&gt;\&\#62;/g;
1707 # Just normal re-writes...
1708 $text =~ s/</\&lt;/g;
1709 $text =~ s/>/\&gt;/g;
1710 # These last isn't needed for the HTML, but is needed to get
1711 # past LaTeX2HTML processing TeX macros. We use &#92; instead
1712 # of &sol; since many browsers don't support that.
1713 $text =~ s/\\/\&\#92;/g;
1714 }
1715 else {
1716 $text = '<b>Could not locate requested file <i>$fname</i>!</b>\n';
1717 }
1718 return ($alltt_start
1719 . $text
1720 . $alltt_end
1721 . $_);
1722}
Fred Drake86333602001-04-10 17:13:39 +00001723
Fred Drake6659c301998-03-03 22:02:19 +000017241; # This must be the last line