blob: 515b1e823482b776dc5a1bc8227c33b5df5ea95f [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
Fred Drakef171ad92002-03-13 02:44:50 +000088sub do_cmd_textasciitilde{ '&#126;' . @_[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]; }
Fred Drake58fb2372002-03-05 04:04:06 +000091sub do_cmd_textgreater{ '&gt;' . @_[0]; }
92sub do_cmd_textless{ '&lt;' . @_[0]; }
Fred Drake6fe46602001-06-23 03:13:30 +000093sub do_cmd_infinity{ '&infin;' . @_[0]; }
94sub do_cmd_plusminus{ '&plusmn;' . @_[0]; }
Fred Drake77602f22001-07-06 22:43:02 +000095sub do_cmd_menuselection{ @_[0]; }
96sub do_cmd_sub{ ' > ' . @_[0]; }
Fred Drakec3fd45f2000-06-15 22:41:48 +000097
98
Fred Drake6659c301998-03-03 22:02:19 +000099# words typeset in a special way (not in HTML though)
100
101sub do_cmd_ABC{ 'ABC' . @_[0]; }
102sub do_cmd_UNIX{ 'Unix'. @_[0]; }
103sub do_cmd_ASCII{ 'ASCII' . @_[0]; }
104sub do_cmd_POSIX{ 'POSIX' . @_[0]; }
105sub do_cmd_C{ 'C' . @_[0]; }
106sub do_cmd_Cpp{ 'C++' . @_[0]; }
107sub do_cmd_EOF{ 'EOF' . @_[0]; }
Fred Drakee15956b2000-04-03 04:51:13 +0000108sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +0000109
110sub do_cmd_e{ '&#92;' . @_[0]; }
111
Fred Draked07868a1998-05-14 21:00:28 +0000112$DEVELOPER_ADDRESS = '';
Fred Drake3cdb89d2000-09-14 20:17:23 +0000113$SHORT_VERSION = '';
Fred Drakef1927a62001-06-20 21:29:30 +0000114$RELEASE_INFO = '';
Fred Draked04592a2000-10-25 16:15:13 +0000115$PACKAGE_VERSION = '';
Fred Drake6659c301998-03-03 22:02:19 +0000116
Fred Draked04592a2000-10-25 16:15:13 +0000117sub do_cmd_version{ $PACKAGE_VERSION . @_[0]; }
Fred Drake3cdb89d2000-09-14 20:17:23 +0000118sub do_cmd_shortversion{ $SHORT_VERSION . @_[0]; }
Fred Drake6659c301998-03-03 22:02:19 +0000119sub do_cmd_release{
120 local($_) = @_;
Fred Draked04592a2000-10-25 16:15:13 +0000121 $PACKAGE_VERSION = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000122 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000123}
124
Fred Drakef1927a62001-06-20 21:29:30 +0000125sub do_cmd_setreleaseinfo{
126 local($_) = @_;
127 $RELEASE_INFO = next_argument();
128 return $_;
129}
130
Fred Drake3cdb89d2000-09-14 20:17:23 +0000131sub do_cmd_setshortversion{
132 local($_) = @_;
133 $SHORT_VERSION = next_argument();
134 return $_;
135}
136
Fred Drake6659c301998-03-03 22:02:19 +0000137sub do_cmd_authoraddress{
138 local($_) = @_;
Fred Draked07868a1998-05-14 21:00:28 +0000139 $DEVELOPER_ADDRESS = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000140 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000141}
142
Fred Drakee16f6791998-05-15 04:28:37 +0000143#sub do_cmd_developer{ do_cmd_author(@_[0]); }
144#sub do_cmd_developers{ do_cmd_author(@_[0]); }
145#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
Fred Draked07868a1998-05-14 21:00:28 +0000146
Fred Drake6659c301998-03-03 22:02:19 +0000147sub do_cmd_hackscore{
148 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000149 next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000150 return '_' . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000151}
152
Fred Drake08932051998-04-17 02:15:42 +0000153sub use_wrappers{
154 local($_,$before,$after) = @_;
155 my $stuff = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000156 return $before . $stuff . $after . $_;
Fred Drake08932051998-04-17 02:15:42 +0000157}
158
Fred Drake3cdb89d2000-09-14 20:17:23 +0000159$IN_DESC_HANDLER = 0;
Fred Drake6659c301998-03-03 22:02:19 +0000160sub do_cmd_optional{
Fred Drake3cdb89d2000-09-14 20:17:23 +0000161 if ($IN_DESC_HANDLER) {
162 return use_wrappers(@_[0], "</var><big>\[</big><var>",
163 "</var><big>\]</big><var>");
164 }
165 else {
166 return use_wrappers(@_[0], "<big>\[</big>", "<big>\]</big>");
167 }
Fred Drake6659c301998-03-03 22:02:19 +0000168}
169
Fred Drakec9a44381998-03-17 06:29:13 +0000170# Logical formatting (some based on texinfo), needs to be converted to
171# minimalist HTML. The "minimalist" is primarily to reduce the size of
172# output files for users that read them over the network rather than
173# from local repositories.
Fred Drake6659c301998-03-03 22:02:19 +0000174
Fred Drake2cafcbb1999-03-25 16:57:04 +0000175# \file and \samp are at the end of this file since they screw up fontlock.
176
Fred Drake2ff880e1999-02-05 18:31:29 +0000177sub do_cmd_pytype{ return @_[0]; }
Fred Drake3d5a04a2000-08-03 17:25:44 +0000178sub do_cmd_makevar{
179 return use_wrappers(@_[0], '<span class="makevar">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000180sub do_cmd_code{
Fred Drakee15956b2000-04-03 04:51:13 +0000181 return use_wrappers(@_[0], '<code>', '</code>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000182sub do_cmd_module{
Fred Drakee15956b2000-04-03 04:51:13 +0000183 return use_wrappers(@_[0], '<tt class="module">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000184sub do_cmd_keyword{
Fred Drakee15956b2000-04-03 04:51:13 +0000185 return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000186sub do_cmd_exception{
Fred Drakee15956b2000-04-03 04:51:13 +0000187 return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000188sub do_cmd_class{
Fred Drakee15956b2000-04-03 04:51:13 +0000189 return use_wrappers(@_[0], '<tt class="class">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000190sub do_cmd_function{
Fred Drakee15956b2000-04-03 04:51:13 +0000191 return use_wrappers(@_[0], '<tt class="function">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000192sub do_cmd_constant{
Fred Drakee15956b2000-04-03 04:51:13 +0000193 return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000194sub do_cmd_member{
Fred Drakee15956b2000-04-03 04:51:13 +0000195 return use_wrappers(@_[0], '<tt class="member">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000196sub do_cmd_method{
Fred Drakee15956b2000-04-03 04:51:13 +0000197 return use_wrappers(@_[0], '<tt class="method">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000198sub do_cmd_cfunction{
Fred Drakee15956b2000-04-03 04:51:13 +0000199 return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000200sub do_cmd_cdata{
Fred Drakee15956b2000-04-03 04:51:13 +0000201 return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000202sub do_cmd_ctype{
Fred Drakee15956b2000-04-03 04:51:13 +0000203 return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000204sub do_cmd_regexp{
Fred Drakee15956b2000-04-03 04:51:13 +0000205 return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000206sub do_cmd_character{
Fred Drakee15956b2000-04-03 04:51:13 +0000207 return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000208sub do_cmd_program{
Fred Drakee15956b2000-04-03 04:51:13 +0000209 return use_wrappers(@_[0], '<b class="program">', '</b>'); }
Fred Drakec9f5fe01999-11-09 16:59:42 +0000210sub do_cmd_programopt{
211 return use_wrappers(@_[0], '<b class="programopt">', '</b>'); }
Fred Drake0cd60212000-04-11 18:46:59 +0000212sub do_cmd_longprogramopt{
213 # note that the --- will be later converted to -- by LaTeX2HTML
214 return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000215sub do_cmd_email{
Fred Drakee15956b2000-04-03 04:51:13 +0000216 return use_wrappers(@_[0], '<span class="email">', '</span>'); }
Fred Drake7eac0cb2001-08-03 18:36:17 +0000217sub do_cmd_mailheader{
Fred Drake479384e2001-09-26 18:46:36 +0000218 return use_wrappers(@_[0], '<span class="mailheader">', ':</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000219sub do_cmd_mimetype{
Fred Drakee15956b2000-04-03 04:51:13 +0000220 return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000221sub do_cmd_var{
222 return use_wrappers(@_[0], "<var>", "</var>"); }
223sub do_cmd_dfn{
Fred Drakee15956b2000-04-03 04:51:13 +0000224 return use_wrappers(@_[0], '<i class="dfn">', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000225sub do_cmd_emph{
Fred Drake38178fd2000-09-22 17:05:04 +0000226 return use_wrappers(@_[0], '<i>', '</i>'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000227sub do_cmd_file{
Fred Drake3d5a04a2000-08-03 17:25:44 +0000228 return use_wrappers(@_[0], '<span class="file">', '</span>'); }
Fred Drakef74e5b71999-04-28 14:58:49 +0000229sub do_cmd_filenq{
Fred Drakee15956b2000-04-03 04:51:13 +0000230 return do_cmd_file(@_[0]); }
Fred Drake90fdda51999-02-16 20:27:42 +0000231sub do_cmd_samp{
Fred Drakee15956b2000-04-03 04:51:13 +0000232 return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); }
Fred Drake90fdda51999-02-16 20:27:42 +0000233sub do_cmd_kbd{
234 return use_wrappers(@_[0], '<kbd>', '</kbd>'); }
235sub do_cmd_strong{
236 return use_wrappers(@_[0], '<b>', '</b>'); }
Fred Drake2cafcbb1999-03-25 16:57:04 +0000237sub do_cmd_textbf{
238 return use_wrappers(@_[0], '<b>', '</b>'); }
239sub do_cmd_textit{
240 return use_wrappers(@_[0], '<i>', '</i>'); }
Fred Drake6ca33772001-12-14 22:50:06 +0000241# This can be changed/overridden for translations:
242%NoticeNames = ('note' => 'Note:',
243 'warning' => 'Warning:',
244 );
245
Fred Drake92350b32001-10-09 18:01:23 +0000246sub do_cmd_note{
Fred Drake6ca33772001-12-14 22:50:06 +0000247 my $label = $NoticeNames{'note'};
Fred Drake92350b32001-10-09 18:01:23 +0000248 return use_wrappers(
249 @_[0],
Fred Drake6ca33772001-12-14 22:50:06 +0000250 "<span class=\"note\"><b class=\"label\">$label</b>\n",
Fred Drake92350b32001-10-09 18:01:23 +0000251 '</span>'); }
252sub do_cmd_warning{
Fred Drake6ca33772001-12-14 22:50:06 +0000253 my $label = $NoticeNames{'warning'};
Fred Drake92350b32001-10-09 18:01:23 +0000254 return use_wrappers(
255 @_[0],
Fred Drake6ca33772001-12-14 22:50:06 +0000256 "<span class=\"warning\"><b class=\"label\">$label</b>\n",
Fred Drake92350b32001-10-09 18:01:23 +0000257 '</span>'); }
Fred Drake2cafcbb1999-03-25 16:57:04 +0000258
Fred Drake6ca33772001-12-14 22:50:06 +0000259sub do_env_notice{
260 local($_) = @_;
261 my $notice = next_optional_argument();
262 if (!$notice) {
263 $notice = 'note';
264 }
265 my $label = $NoticeNames{$notice};
266 return ("<div class=\"$notice\"><b class=\"label\">$label</b>\n"
267 . $_
268 . '</div>');
269}
270
Fred Drake3d5a04a2000-08-03 17:25:44 +0000271sub do_cmd_moreargs{
272 return '...' . @_[0]; }
273sub do_cmd_unspecified{
274 return '...' . @_[0]; }
275
Fred Drakec9a44381998-03-17 06:29:13 +0000276
Fred Drake25817041999-01-13 17:06:34 +0000277sub do_cmd_refmodule{
278 # Insert the right magic to jump to the module definition.
279 local($_) = @_;
280 my $key = next_optional_argument();
281 my $module = next_argument();
282 $key = $module
283 unless $key;
Fred Drakef1927a62001-06-20 21:29:30 +0000284 return "<tt class=\"module\"><a href=\"module-$key.html\">$module</a></tt>"
Fred Drakee15956b2000-04-03 04:51:13 +0000285 . $_;
Fred Drake25817041999-01-13 17:06:34 +0000286}
287
Fred Drake1a7af391998-04-01 22:44:56 +0000288sub do_cmd_newsgroup{
289 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000290 my $newsgroup = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000291 my $icon = get_link_icon("news:$newsgroup");
Fred Drakef1927a62001-06-20 21:29:30 +0000292 my $stuff = ("<a class=\"newsgroup\" href=\"news:$newsgroup\">"
293 . "$newsgroup$icon</a>");
Fred Drake62e43691998-08-10 19:40:44 +0000294 return $stuff . $_;
Fred Drake1a7af391998-04-01 22:44:56 +0000295}
Fred Drakefc16e781998-03-12 21:03:26 +0000296
297sub do_cmd_envvar{
298 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000299 my $envvar = next_argument();
300 my($name,$aname,$ahref) = new_link_info();
Fred Drake166abba1998-04-08 23:10:54 +0000301 # The <tt> here is really to keep buildindex.py from making
302 # the variable name case-insensitive.
Fred Drakeafc7ce12001-01-22 17:33:24 +0000303 add_index_entry("environment variables!$envvar@<tt>$envvar</tt>",
Fred Drake166abba1998-04-08 23:10:54 +0000304 $ahref);
Fred Drakeafc7ce12001-01-22 17:33:24 +0000305 add_index_entry("$envvar (environment variable)", $ahref);
Fred Drakee15956b2000-04-03 04:51:13 +0000306 $aname =~ s/<a/<a class="envvar"/;
Fred Drakeafc7ce12001-01-22 17:33:24 +0000307 return "$aname$envvar</a>" . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000308}
309
Fred Drake6659c301998-03-03 22:02:19 +0000310sub do_cmd_url{
311 # use the URL as both text and hyperlink
312 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000313 my $url = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000314 my $icon = get_link_icon($url);
Fred Drake6659c301998-03-03 22:02:19 +0000315 $url =~ s/~/&#126;/g;
Fred Drake7a40c072000-10-02 14:43:38 +0000316 return "<a class=\"url\" href=\"$url\">$url$icon</a>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000317}
318
319sub do_cmd_manpage{
320 # two parameters: \manpage{name}{section}
321 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000322 my $page = next_argument();
323 my $section = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000324 return "<span class=\"manpage\"><i>$page</i>($section)</span>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000325}
326
Fred Drakedbfe7682002-04-03 02:47:14 +0000327$PEP_FORMAT = "http://www.python.org/peps/pep-%04d.html";
Fred Drakef1927a62001-06-20 21:29:30 +0000328#$RFC_FORMAT = "http://www.ietf.org/rfc/rfc%04d.txt";
329$RFC_FORMAT = "http://www.faqs.org/rfcs/rfc%d.html";
Fred Drakeafc7ce12001-01-22 17:33:24 +0000330
331sub get_rfc_url($$){
332 my($rfcnum, $format) = @_;
Fred Drakef1927a62001-06-20 21:29:30 +0000333 return sprintf($format, $rfcnum);
Fred Drake643d76d2000-09-09 06:07:37 +0000334}
335
336sub do_cmd_pep{
337 local($_) = @_;
338 my $rfcnumber = next_argument();
339 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drakeafc7ce12001-01-22 17:33:24 +0000340 my $href = get_rfc_url($rfcnumber, $PEP_FORMAT);
Fred Drake7a40c072000-10-02 14:43:38 +0000341 my $icon = get_link_icon($href);
Fred Drake643d76d2000-09-09 06:07:37 +0000342 # Save the reference
343 my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", '');
344 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drake7a40c072000-10-02 14:43:38 +0000345 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">PEP $rfcnumber"
346 . "$icon</a>" . $_);
Fred Drake643d76d2000-09-09 06:07:37 +0000347}
348
Fred Drake6659c301998-03-03 22:02:19 +0000349sub do_cmd_rfc{
350 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000351 my $rfcnumber = next_argument();
352 my $id = "rfcref-" . ++$global{'max_id'};
Fred Drakeafc7ce12001-01-22 17:33:24 +0000353 my $href = get_rfc_url($rfcnumber, $RFC_FORMAT);
Fred Drake7a40c072000-10-02 14:43:38 +0000354 my $icon = get_link_icon($href);
Fred Drake6659c301998-03-03 22:02:19 +0000355 # Save the reference
Fred Drake08932051998-04-17 02:15:42 +0000356 my $nstr = gen_index_id("RFC!RFC $rfcnumber", '');
Fred Drakeccc62721999-01-05 22:16:29 +0000357 $index{$nstr} .= make_half_href("$CURRENT_FILE#$id");
Fred Drake7a40c072000-10-02 14:43:38 +0000358 return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber"
359 . "$icon</a>" . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000360}
361
Fred Drake77602f22001-07-06 22:43:02 +0000362sub do_cmd_ulink{
363 local($_) = @_;
364 my $text = next_argument();
365 my $url = next_argument();
366 return "<a class=\"ulink\" href=\"$url\"\n >$text</a>" . $_;
367}
368
Fred Drakec9f5fe01999-11-09 16:59:42 +0000369sub do_cmd_citetitle{
370 local($_) = @_;
371 my $url = next_optional_argument();
372 my $title = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +0000373 my $icon = get_link_icon($url);
Fred Drakec9f5fe01999-11-09 16:59:42 +0000374 my $repl = '';
375 if ($url) {
Fred Drakef1927a62001-06-20 21:29:30 +0000376 $repl = ("<em class=\"citetitle\"><a\n"
377 . " href=\"$url\"\n"
378 . " title=\"$title\"\n"
Fred Drake7a40c072000-10-02 14:43:38 +0000379 . " >$title$icon</a></em>");
Fred Drakec9f5fe01999-11-09 16:59:42 +0000380 }
381 else {
Fred Drakef1927a62001-06-20 21:29:30 +0000382 $repl = "<em class=\"citetitle\"\n >$title</em>";
Fred Drakec9f5fe01999-11-09 16:59:42 +0000383 }
384 return $repl . $_;
385}
386
Fred Drake6659c301998-03-03 22:02:19 +0000387sub do_cmd_deprecated{
388 # two parameters: \deprecated{version}{whattodo}
389 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000390 my $release = next_argument();
391 my $reason = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +0000392 return ('<div class="versionnote">'
393 . "<b>Deprecated since release $release.</b>"
394 . "\n$reason</div><p>"
395 . $_);
Fred Drake6659c301998-03-03 22:02:19 +0000396}
397
Fred Drakec2b29d02001-04-18 03:11:04 +0000398sub versionnote{
399 # one or two parameters: \versionnote[explanation]{version}
400 my $type = @_[0];
401 local $_ = @_[1];
402 my $explanation = next_optional_argument();
Fred Drake897d12b1998-07-27 20:33:17 +0000403 my $release = next_argument();
Fred Drakec2b29d02001-04-18 03:11:04 +0000404 my $text = "$type in version $release.";
405 if ($explanation) {
406 $text = "$type in version $release:\n$explanation.";
407 }
Fred Drakef1927a62001-06-20 21:29:30 +0000408 return "\n<span class=\"versionnote\">$text</span>\n" . $_;
Fred Drakec2b29d02001-04-18 03:11:04 +0000409}
410
411sub do_cmd_versionadded{
412 return versionnote('New', @_);
Fred Drake897d12b1998-07-27 20:33:17 +0000413}
414
415sub do_cmd_versionchanged{
Fred Drakec2b29d02001-04-18 03:11:04 +0000416 return versionnote('Changed', @_);
Fred Drake897d12b1998-07-27 20:33:17 +0000417}
418
Fred Drake557460c1999-03-02 16:05:35 +0000419#
Fred Drake2cafcbb1999-03-25 16:57:04 +0000420# These function handle platform dependency tracking.
Fred Drake557460c1999-03-02 16:05:35 +0000421#
422sub do_cmd_platform{
423 local($_) = @_;
424 my $platform = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000425 $ModulePlatforms{"<tt class=\"module\">$THIS_MODULE</tt>"} = $platform;
Fred Drake557460c1999-03-02 16:05:35 +0000426 $platform = "Macintosh"
Fred Drake085b8121999-04-21 14:00:29 +0000427 if $platform eq 'Mac';
Fred Drakef1927a62001-06-20 21:29:30 +0000428 return "\n<p class=\"availability\">Availability: <span"
429 . "\n class=\"platform\">$platform</span>.</p>\n" . $_;
Fred Drake557460c1999-03-02 16:05:35 +0000430}
431
Fred Drake557460c1999-03-02 16:05:35 +0000432$IGNORE_PLATFORM_ANNOTATION = '';
433sub do_cmd_ignorePlatformAnnotation{
434 local($_) = @_;
435 $IGNORE_PLATFORM_ANNOTATION = next_argument();
436 return $_;
437}
438
Fred Drake6659c301998-03-03 22:02:19 +0000439
440# index commands
441
442$INDEX_SUBITEM = "";
443
444sub get_indexsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000445 return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : '';
Fred Drake6659c301998-03-03 22:02:19 +0000446}
447
448sub do_cmd_setindexsubitem{
449 local($_) = @_;
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000450 $INDEX_SUBITEM = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000451 return $_;
Fred Drake6659c301998-03-03 22:02:19 +0000452}
453
Fred Drakefc16e781998-03-12 21:03:26 +0000454sub do_cmd_withsubitem{
Fred Drake7d45f6d1999-01-05 14:39:27 +0000455 # We can't really do the right thing, because LaTeX2HTML doesn't
Fred Drakefc16e781998-03-12 21:03:26 +0000456 # do things in the right order, but we need to at least strip this stuff
457 # out, and leave anything that the second argument expanded out to.
458 #
459 local($_) = @_;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000460 my $oldsubitem = $INDEX_SUBITEM;
461 $INDEX_SUBITEM = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000462 my $stuff = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000463 my $br_id = ++$globals{'max_id'};
464 my $marker = "$O$br_id$C";
Fred Drakebe6dd302001-12-11 20:49:23 +0000465 $stuff =~ s/^\s+//;
Fred Drake7d45f6d1999-01-05 14:39:27 +0000466 return
467 $stuff
Fred Drakeccc62721999-01-05 22:16:29 +0000468 . "\\setindexsubitem$marker$oldsubitem$marker"
Fred Drake7d45f6d1999-01-05 14:39:27 +0000469 . $_;
Fred Drakefc16e781998-03-12 21:03:26 +0000470}
471
Fred Drake08932051998-04-17 02:15:42 +0000472# This is the prologue macro which is required to start writing the
Fred Drakeab032151999-05-13 18:36:54 +0000473# mod\jobname.idx file; we can just ignore it. (Defining this suppresses
474# a warning that \makemodindex is unknown.)
Fred Drake08932051998-04-17 02:15:42 +0000475#
Fred Drake62e43691998-08-10 19:40:44 +0000476sub do_cmd_makemodindex{ return @_[0]; }
Fred Drakefc16e781998-03-12 21:03:26 +0000477
Fred Drake42b31a51998-03-27 05:16:10 +0000478# We're in the document subdirectory when this happens!
Fred Drake166abba1998-04-08 23:10:54 +0000479#
Fred Drake08932051998-04-17 02:15:42 +0000480open(IDXFILE, '>index.dat') || die "\n$!\n";
481open(INTLABELS, '>intlabels.pl') || die "\n$!\n";
Fred Drake166abba1998-04-08 23:10:54 +0000482print INTLABELS "%internal_labels = ();\n";
483print INTLABELS "1; # hack in case there are no entries\n\n";
484
485# Using \0 for this is bad because we can't use common tools to work with the
486# resulting files. Things like grep can be useful with this stuff!
487#
488$IDXFILE_FIELD_SEP = "\1";
489
Fred Drakeccc62721999-01-05 22:16:29 +0000490sub write_idxfile{
491 my ($ahref, $str) = @_;
492 print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n";
Fred Drake42b31a51998-03-27 05:16:10 +0000493}
494
Fred Drake42b31a51998-03-27 05:16:10 +0000495
496sub gen_link{
497 my($node,$target) = @_;
498 print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n";
Fred Drakef1927a62001-06-20 21:29:30 +0000499 return "<a href=\"$node#$target\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000500}
501
Fred Drake42b31a51998-03-27 05:16:10 +0000502sub add_index_entry{
503 # add an entry to the index structures; ignore the return value
504 my($str,$ahref) = @_;
505 $str = gen_index_id($str, '');
506 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000507 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000508}
509
Fred Drakeccc62721999-01-05 22:16:29 +0000510sub new_link_info{
511 my $name = "l2h-" . ++$globals{'max_id'};
Fred Drakef1927a62001-06-20 21:29:30 +0000512 my $aname = "<a name=\"$name\">";
Fred Drake42b31a51998-03-27 05:16:10 +0000513 my $ahref = gen_link($CURRENT_FILE, $name);
514 return ($name, $aname, $ahref);
515}
516
Fred Drakeab032151999-05-13 18:36:54 +0000517$IndexMacroPattern = '';
518sub define_indexing_macro{
519 my $count = @_;
520 my $i = 0;
521 for (; $i < $count; ++$i) {
522 my $name = @_[$i];
523 my $cmd = "idx_cmd_$name";
524 die "\nNo function $cmd() defined!\n"
525 if (!defined &$cmd);
526 eval ("sub do_cmd_$name { return process_index_macros("
527 . "\@_[0], '$name'); }");
528 if (length($IndexMacroPattern) == 0) {
529 $IndexMacroPattern = "$name";
530 }
531 else {
532 $IndexMacroPattern .= "|$name";
533 }
534 }
535}
536
537$DEBUG_INDEXING = 0;
538sub process_index_macros{
Fred Drake42b31a51998-03-27 05:16:10 +0000539 local($_) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000540 my $cmdname = @_[1]; # This is what triggered us in the first place;
541 # we know it's real, so just process it.
Fred Drakeccc62721999-01-05 22:16:29 +0000542 my($name,$aname,$ahref) = new_link_info();
Fred Drakeab032151999-05-13 18:36:54 +0000543 my $cmd = "idx_cmd_$cmdname";
544 print "\nIndexing: \\$cmdname"
545 if $DEBUG_INDEXING;
546 &$cmd($ahref); # modifies $_ and adds index entries
547 while (/^[\s\n]*\\($IndexMacroPattern)</) {
548 $cmdname = "$1";
549 print " \\$cmdname"
550 if $DEBUG_INDEXING;
551 $cmd = "idx_cmd_$cmdname";
552 if (!defined &$cmd) {
553 last;
554 }
555 else {
556 s/^[\s\n]*\\$cmdname//;
557 &$cmd($ahref);
558 }
559 }
Fred Drakeafc7ce12001-01-22 17:33:24 +0000560 if (/^[ \t\r\n]/) {
561 $_ = substr($_, 1);
562 }
Fred Drake62e43691998-08-10 19:40:44 +0000563 return "$aname$anchor_invisible_mark</a>" . $_;
Fred Drake42b31a51998-03-27 05:16:10 +0000564}
565
Fred Drakeab032151999-05-13 18:36:54 +0000566define_indexing_macro('index');
567sub idx_cmd_index{
Fred Drakeccc62721999-01-05 22:16:29 +0000568 my $str = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000569 add_index_entry("$str", @_[0]);
Fred Drake2e7edb81998-05-11 18:31:17 +0000570}
571
Fred Drakeab032151999-05-13 18:36:54 +0000572define_indexing_macro('kwindex');
573sub idx_cmd_kwindex{
574 my $str = next_argument();
575 add_index_entry("<tt>$str</tt>!keyword", @_[0]);
576 add_index_entry("keyword!<tt>$str</tt>", @_[0]);
577}
578
579define_indexing_macro('indexii');
580sub idx_cmd_indexii{
Fred Drakeccc62721999-01-05 22:16:29 +0000581 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000582 my $str2 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000583 add_index_entry("$str1!$str2", @_[0]);
584 add_index_entry("$str2!$str1", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000585}
586
Fred Drakeab032151999-05-13 18:36:54 +0000587define_indexing_macro('indexiii');
588sub idx_cmd_indexiii{
Fred Drakeccc62721999-01-05 22:16:29 +0000589 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000590 my $str2 = next_argument();
591 my $str3 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000592 add_index_entry("$str1!$str2 $str3", @_[0]);
593 add_index_entry("$str2!$str3, $str1", @_[0]);
594 add_index_entry("$str3!$str1 $str2", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000595}
596
Fred Drakeab032151999-05-13 18:36:54 +0000597define_indexing_macro('indexiv');
598sub idx_cmd_indexiv{
Fred Drakeccc62721999-01-05 22:16:29 +0000599 my $str1 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000600 my $str2 = next_argument();
601 my $str3 = next_argument();
602 my $str4 = next_argument();
Fred Drakeab032151999-05-13 18:36:54 +0000603 add_index_entry("$str1!$str2 $str3 $str4", @_[0]);
604 add_index_entry("$str2!$str3 $str4, $str1", @_[0]);
605 add_index_entry("$str3!$str4, $str1 $str2", @_[0]);
606 add_index_entry("$str4!$$str1 $str2 $str3", @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000607}
608
Fred Drakeab032151999-05-13 18:36:54 +0000609define_indexing_macro('ttindex');
610sub idx_cmd_ttindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000611 my $str = next_argument();
612 my $entry = $str . get_indexsubitem();
Fred Drakeab032151999-05-13 18:36:54 +0000613 add_index_entry($entry, @_[0]);
Fred Drakec9a44381998-03-17 06:29:13 +0000614}
Fred Drake6659c301998-03-03 22:02:19 +0000615
616sub my_typed_index_helper{
Fred Drakeab032151999-05-13 18:36:54 +0000617 my($word,$ahref) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +0000618 my $str = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +0000619 add_index_entry("$str $word", $ahref);
620 add_index_entry("$word!$str", $ahref);
Fred Drake6659c301998-03-03 22:02:19 +0000621}
622
Fred Drakeab032151999-05-13 18:36:54 +0000623define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex');
624sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); }
625sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); }
626sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); }
627sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); }
Fred Drake6659c301998-03-03 22:02:19 +0000628
Fred Drakeab032151999-05-13 18:36:54 +0000629define_indexing_macro('bifuncindex');
630sub idx_cmd_bifuncindex{
Fred Drakeccc62721999-01-05 22:16:29 +0000631 my $str = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000632 add_index_entry("<tt class=\"function\">$str()</tt> (built-in function)",
Fred Drakee15956b2000-04-03 04:51:13 +0000633 @_[0]);
Fred Drake6659c301998-03-03 22:02:19 +0000634}
635
636
Fred Drake6659c301998-03-03 22:02:19 +0000637sub make_mod_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000638 my($str,$define) = @_;
639 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000640 # equivalent of add_index_entry() using $define instead of ''
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000641 $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/
642 if ($define eq 'DEF');
Fred Drake42b31a51998-03-27 05:16:10 +0000643 $str = gen_index_id($str, $define);
644 $index{$str} .= $ahref;
Fred Drakeccc62721999-01-05 22:16:29 +0000645 write_idxfile($ahref, $str);
Fred Drake42b31a51998-03-27 05:16:10 +0000646
Fred Drakec9a44381998-03-17 06:29:13 +0000647 if ($define eq 'DEF') {
Fred Drake42b31a51998-03-27 05:16:10 +0000648 # add to the module index
Fred Drakee15956b2000-04-03 04:51:13 +0000649 $str =~ /(<tt.*<\/tt>)/;
650 my $nstr = $1;
Fred Drake42b31a51998-03-27 05:16:10 +0000651 $Modules{$nstr} .= $ahref;
Fred Drake6659c301998-03-03 22:02:19 +0000652 }
Fred Drakeafc7ce12001-01-22 17:33:24 +0000653 return "$aname$anchor_invisible_mark2</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000654}
655
Fred Drake557460c1999-03-02 16:05:35 +0000656
Fred Drakec9a44381998-03-17 06:29:13 +0000657$THIS_MODULE = '';
Fred Drake42b31a51998-03-27 05:16:10 +0000658$THIS_CLASS = '';
Fred Drakec9a44381998-03-17 06:29:13 +0000659
Fred Drakea0f4c941998-07-24 22:16:04 +0000660sub define_module{
661 my($word,$name) = @_;
Fred Drakec9a44381998-03-17 06:29:13 +0000662 my $section_tag = join('', @curr_sec_id);
Fred Drake3e4c6141999-05-17 15:00:32 +0000663 if ($word ne "built-in" && $word ne "extension"
664 && $word ne "standard" && $word ne "") {
665 write_warnings("Bad module type '$word'"
666 . " for \\declaremodule (module $name)");
667 $word = "";
668 }
Fred Drake6659c301998-03-03 22:02:19 +0000669 $word = "$word " if $word;
Fred Drakea0f4c941998-07-24 22:16:04 +0000670 $THIS_MODULE = "$name";
Fred Drake5942b432000-10-30 06:24:56 +0000671 $INDEX_SUBITEM = "(in module $name)";
Fred Drake2e1ee3e1999-02-10 21:17:04 +0000672 print "[$name]";
Fred Drakee15956b2000-04-03 04:51:13 +0000673 return make_mod_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000674 "<tt class=\"module\">$name</tt> (${word}module)", 'DEF');
Fred Drakea0f4c941998-07-24 22:16:04 +0000675}
676
677sub my_module_index_helper{
678 local($word, $_) = @_;
679 my $name = next_argument();
Fred Drake62e43691998-08-10 19:40:44 +0000680 return define_module($word, $name) . $_;
Fred Drake6659c301998-03-03 22:02:19 +0000681}
682
Fred Drake62e43691998-08-10 19:40:44 +0000683sub do_cmd_modindex{ return my_module_index_helper('', @_); }
684sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); }
685sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); }
686sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000687
Fred Drakeab032151999-05-13 18:36:54 +0000688sub ref_module_index_helper{
Fred Drake37cc0c02000-04-26 18:05:24 +0000689 my($word, $ahref) = @_;
Fred Drakeab032151999-05-13 18:36:54 +0000690 my $str = next_argument();
691 $word = "$word " if $word;
Fred Drakef1927a62001-06-20 21:29:30 +0000692 $str = "<tt class=\"module\">$str</tt> (${word}module)";
Fred Drakeab032151999-05-13 18:36:54 +0000693 # can't use add_index_entry() since the 2nd arg to gen_index_id() is used;
694 # just inline it all here
695 $str = gen_index_id($str, 'REF');
696 $index{$str} .= $ahref;
697 write_idxfile($ahref, $str);
698}
699
Fred Drake6659c301998-03-03 22:02:19 +0000700# these should be adjusted a bit....
Fred Drakeab032151999-05-13 18:36:54 +0000701define_indexing_macro('refmodindex', 'refbimodindex',
702 'refexmodindex', 'refstmodindex');
703sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); }
704sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); }
705sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); }
706sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); }
Fred Drake6659c301998-03-03 22:02:19 +0000707
Fred Drake62e43691998-08-10 19:40:44 +0000708sub do_cmd_nodename{ return do_cmd_label(@_); }
Fred Drake6659c301998-03-03 22:02:19 +0000709
710sub init_myformat{
Fred Drakeafc7ce12001-01-22 17:33:24 +0000711 $anchor_invisible_mark = '&nbsp;';
712 $anchor_invisible_mark2 = '';
Fred Drake6659c301998-03-03 22:02:19 +0000713 $anchor_mark = '';
714 $icons{'anchor_mark'} = '';
Fred Drake6659c301998-03-03 22:02:19 +0000715}
Fred Drake42b31a51998-03-27 05:16:10 +0000716init_myformat();
Fred Drake6659c301998-03-03 22:02:19 +0000717
Fred Drakeab032151999-05-13 18:36:54 +0000718# Create an index entry, but include the string in the target anchor
Fred Drake6659c301998-03-03 22:02:19 +0000719# instead of the dummy filler.
720#
721sub make_str_index_entry{
Fred Drakeccc62721999-01-05 22:16:29 +0000722 my($str) = @_;
723 my($name,$aname,$ahref) = new_link_info();
Fred Drake42b31a51998-03-27 05:16:10 +0000724 add_index_entry($str, $ahref);
Fred Drake62e43691998-08-10 19:40:44 +0000725 return "$aname$str</a>";
Fred Drake6659c301998-03-03 22:02:19 +0000726}
727
Fred Drake77602f22001-07-06 22:43:02 +0000728
729%TokenToTargetMapping = ();
730%DefinedGrammars = ();
731%BackpatchGrammarFiles = ();
732
733sub do_cmd_token{
734 local($_) = @_;
735 my $token = next_argument();
736 my $target = $TokenToTargetMapping{"$CURRENT_GRAMMAR:$token"};
737 if ($token eq $CURRENT_TOKEN || $CURRENT_GRAMMAR eq '*') {
738 # recursive definition or display-only productionlist
739 return "$token";
740 }
741 if ($target eq '') {
742 $target = "<pyGrammarToken><$CURRENT_GRAMMAR><$token>";
743 if (! $BackpatchGrammarFiles{"$CURRENT_FILE"}) {
744 print "Adding '$CURRENT_FILE' to back-patch list.\n";
745 }
746 $BackpatchGrammarFiles{"$CURRENT_FILE"} = 1;
747 }
748 return "<a href=\"$target\">$token</a>" . $_;
749}
750
Fred Drake16bb4192001-08-20 21:36:38 +0000751sub do_cmd_grammartoken{
752 return do_cmd_token(@_);
753}
754
Fred Drake77602f22001-07-06 22:43:02 +0000755sub do_env_productionlist{
756 local($_) = @_;
757 my $lang = next_optional_argument();
758 my $filename = "grammar-$lang.txt";
759 if ($lang eq '') {
760 $filename = 'grammar.txt';
761 }
762 local($CURRENT_GRAMMAR) = $lang;
763 $DefinedGrammars{$lang} .= $_;
764 return ("<dl><dd class=\"grammar\">\n"
765 . "<div class=\"productions\">\n"
Fred Drakee27f8682001-12-14 16:54:53 +0000766 . "<table cellpadding=\"2\">\n"
Fred Drake77602f22001-07-06 22:43:02 +0000767 . translate_commands(translate_environments($_))
768 . "</table>\n"
769 . "</div>\n"
770 . (($lang eq '*')
771 ? ''
772 : ("<a class=\"grammar-footer\"\n"
773 . " href=\"$filename\" type=\"text/plain\"\n"
774 . " >Download entire grammar as text.</a>\n"))
775 . "</dd></dl>");
776}
777
778sub do_cmd_production{
779 local($_) = @_;
780 my $token = next_argument();
781 my $defn = next_argument();
782 my $lang = $CURRENT_GRAMMAR;
783 local($CURRENT_TOKEN) = $token;
784 if ($lang eq '*') {
Fred Drakee27f8682001-12-14 16:54:53 +0000785 return ("<tr valign=\"baseline\">\n"
Fred Drake77602f22001-07-06 22:43:02 +0000786 . " <td><code>$token</code></td>\n"
787 . " <td>&nbsp;::=&nbsp;</td>\n"
788 . " <td><code>"
789 . translate_commands($defn)
790 . "</code></td></tr>"
791 . $_);
792 }
793 my $target;
794 if ($lang eq '') {
795 $target = "$CURRENT_FILE\#tok-$token";
796 }
797 else {
798 $target = "$CURRENT_FILE\#tok-$lang-$token";
799 }
800 $TokenToTargetMapping{"$CURRENT_GRAMMAR:$token"} = $target;
Fred Drakee27f8682001-12-14 16:54:53 +0000801 return ("<tr valign=\"baseline\">\n"
Fred Drake77602f22001-07-06 22:43:02 +0000802 . " <td><code><a name=\"tok-$token\">$token</a></code></td>\n"
803 . " <td>&nbsp;::=&nbsp;</td>\n"
804 . " <td><code>"
805 . translate_commands($defn)
806 . "</code></td></tr>"
807 . $_);
808}
809
Fred Drake53815882002-03-15 23:21:37 +0000810sub do_cmd_productioncont{
811 local($_) = @_;
812 my $defn = next_argument();
813 return ("<tr valign=\"baseline\">\n"
814 . " <td>&nbsp;</td>\n"
815 . " <td>&nbsp;</td>\n"
816 . " <td><code>"
817 . translate_commands($defn)
818 . "</code></td></tr>"
819 . $_);
820}
821
Fred Drake77602f22001-07-06 22:43:02 +0000822sub process_grammar_files{
823 my $lang;
824 my $filename;
825 local($_);
826 print "process_grammar_files()\n";
827 foreach $lang (keys %DefinedGrammars) {
828 $filename = "grammar-$lang.txt";
829 if ($lang eq '*') {
830 next;
831 }
832 if ($lang eq '') {
833 $filename = 'grammar.txt';
834 }
835 open(GRAMMAR, ">$filename") || die "\n$!\n";
836 print GRAMMAR strip_grammar_markup($DefinedGrammars{$lang});
837 close(GRAMMAR);
838 print "Wrote grammar file $filename\n";
839 }
840 my $PATTERN = '<pyGrammarToken><([^>]*)><([^>]*)>';
841 foreach $filename (keys %BackpatchGrammarFiles) {
842 print "\nBack-patching grammar links in $filename\n";
843 my $buffer;
844 open(GRAMMAR, "<$filename") || die "\n$!\n";
845 # read all of the file into the buffer
846 sysread(GRAMMAR, $buffer, 1024*1024);
847 close(GRAMMAR);
848 while ($buffer =~ /$PATTERN/) {
849 my($lang, $token) = ($1, $2);
850 my $target = $TokenToTargetMapping{"$lang:$token"};
851 my $source = "<pyGrammarToken><$lang><$token>";
852 $buffer =~ s/$source/$target/g;
853 }
854 open(GRAMMAR, ">$filename") || die "\n$!\n";
855 print GRAMMAR $buffer;
856 close(GRAMMAR);
857 }
858}
859
860sub strip_grammar_markup{
861 local($_) = @_;
Fred Drake53815882002-03-15 23:21:37 +0000862 s/\\productioncont/ /g;
Fred Drake77602f22001-07-06 22:43:02 +0000863 s/\\production(<<\d+>>)(.+)\1/\n\2 ::= /g;
864 s/\\token(<<\d+>>)(.+)\1/\2/g;
865 s/\\e([^a-zA-Z])/\\\1/g;
866 s/<<\d+>>//g;
867 s/;SPMgt;/>/g;
868 s/;SPMlt;/</g;
869 s/;SPMquot;/\"/g;
870 return $_;
871}
872
873
Fred Drakee15956b2000-04-03 04:51:13 +0000874$REFCOUNTS_LOADED = 0;
875
876sub load_refcounts{
877 $REFCOUNTS_LOADED = 1;
878
Fred Drakee15956b2000-04-03 04:51:13 +0000879 my $myname, $mydir, $myext;
880 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
881 chop $mydir; # remove trailing '/'
882 ($myname, $mydir, $myext) = fileparse($mydir, '\..*');
883 chop $mydir; # remove trailing '/'
884 $mydir = getcwd() . "$dd$mydir"
885 unless $mydir =~ s|^/|/|;
886 local $_;
887 my $filename = "$mydir${dd}api${dd}refcounts.dat";
888 open(REFCOUNT_FILE, "<$filename") || die "\n$!\n";
889 print "[loading API refcount data]";
890 while (<REFCOUNT_FILE>) {
Fred Drakec2578c52000-04-10 18:26:45 +0000891 if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) {
Fred Drakee15956b2000-04-03 04:51:13 +0000892 my($func, $param, $count, $comment) = ($1, $2, $3, $4);
893 #print "\n$func($param) --> $count";
894 $REFCOUNTS{"$func:$param"} = $count;
895 }
896 }
897}
898
899sub get_refcount{
900 my ($func, $param) = @_;
901 load_refcounts()
902 unless $REFCOUNTS_LOADED;
903 return $REFCOUNTS{"$func:$param"};
904}
905
Fred Drakeaf07b2c2001-10-26 03:09:27 +0000906
907$TLSTART = '<span class="typelabel">';
908$TLEND = '</span>';
909
Fred Drake6659c301998-03-03 22:02:19 +0000910sub do_env_cfuncdesc{
911 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000912 my $return_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000913 my $function_name = next_argument();
Fred Drake08932051998-04-17 02:15:42 +0000914 my $arg_list = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000915 my $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +0000916 "<tt class=\"cfunction\">$function_name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000917 $idx =~ s/ \(.*\)//;
Fred Drake241551c2000-08-11 20:04:19 +0000918 $idx =~ s/\(\)//; # ???? - why both of these?
Fred Drakee15956b2000-04-03 04:51:13 +0000919 my $result_rc = get_refcount($function_name, '');
920 my $rcinfo = '';
921 if ($result_rc eq '+1') {
Fred Drake241551c2000-08-11 20:04:19 +0000922 $rcinfo = 'New reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000923 }
924 elsif ($result_rc eq '0') {
Fred Drake241551c2000-08-11 20:04:19 +0000925 $rcinfo = 'Borrowed reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000926 }
Fred Drakec2578c52000-04-10 18:26:45 +0000927 elsif ($result_rc eq 'null') {
Fred Drake241551c2000-08-11 20:04:19 +0000928 $rcinfo = 'Always <tt class="constant">NULL</tt>';
Fred Drakec2578c52000-04-10 18:26:45 +0000929 }
Fred Drakee15956b2000-04-03 04:51:13 +0000930 if ($rcinfo ne '') {
Fred Drake241551c2000-08-11 20:04:19 +0000931 $rcinfo = ( "\n<div class=\"refcount-info\">"
932 . "\n <span class=\"label\">Return value:</span>"
933 . "\n <span class=\"value\">$rcinfo.</span>"
934 . "\n</div>");
Fred Drakee15956b2000-04-03 04:51:13 +0000935 }
Fred Drakec612a142001-03-29 18:24:08 +0000936 return "<dl><dt>$return_type <b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000937 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000938 . $_
939 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000940}
941
Fred Drakeeeb5ec42002-04-15 17:46:00 +0000942sub do_cmd_cmemberline{
943 local($_) = @_;
944 my $container = next_argument();
945 my $type = next_argument();
946 my $name = next_argument();
947 my $idx = make_str_index_entry("<tt class=\"cmember\">$name</tt>"
Fred Drake01572762002-04-15 19:35:29 +0000948 . " ($container member)");
Fred Drakeeeb5ec42002-04-15 17:46:00 +0000949 $idx =~ s/ \(.*\)//;
950 return "<dt>$type <b>$idx</b>\n<dd>"
951 . $_;
952}
953sub do_env_cmemberdesc{
954 local($_) = @_;
955 my $container = next_argument();
956 my $type = next_argument();
957 my $name = next_argument();
958 my $idx = make_str_index_entry("<tt class=\"cmember\">$name</tt>"
Fred Drake01572762002-04-15 19:35:29 +0000959 . " ($container member)");
Fred Drakeeeb5ec42002-04-15 17:46:00 +0000960 $idx =~ s/ \(.*\)//;
961 return "<dl><dt>$type <b>$idx</b>\n<dd>"
962 . $_
963 . '</dl>';
964}
965
Fred Drakee15956b2000-04-03 04:51:13 +0000966sub do_env_csimplemacrodesc{
967 local($_) = @_;
968 my $name = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000969 my $idx = make_str_index_entry("<tt class=\"macro\">$name</tt>");
Fred Drakee15956b2000-04-03 04:51:13 +0000970 return "<dl><dt><b>$idx</b>\n<dd>"
971 . $_
972 . '</dl>'
973}
974
Fred Drake6659c301998-03-03 22:02:19 +0000975sub do_env_ctypedesc{
976 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000977 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000978 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000979 $index_name = $type_name
980 unless $index_name;
981 my($name,$aname,$ahref) = new_link_info();
Fred Drakef1927a62001-06-20 21:29:30 +0000982 add_index_entry("<tt class=\"ctype\">$index_name</tt> (C type)", $ahref);
983 return "<dl><dt><b><tt class=\"ctype\">$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000984 . $_
985 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000986}
987
988sub do_env_cvardesc{
989 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +0000990 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000991 my $var_name = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000992 my $idx = make_str_index_entry("<tt class=\"cdata\">$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +0000993 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000994 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +0000995 return "<dl><dt>$var_type <b>$idx</b>\n"
996 . '<dd>'
997 . $_
998 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000999}
1000
Fred Drake3cdb89d2000-09-14 20:17:23 +00001001sub convert_args($){
1002 local($IN_DESC_HANDLER) = 1;
1003 local($_) = @_;
1004 return translate_commands($_);
1005}
1006
Fred Drake6659c301998-03-03 22:02:19 +00001007sub do_env_funcdesc{
1008 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001009 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001010 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +00001011 my $idx = make_str_index_entry("<tt class=\"function\">$function_name()"
1012 . '</tt>'
Fred Drake08932051998-04-17 02:15:42 +00001013 . get_indexsubitem());
1014 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +00001015 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drakec612a142001-03-29 18:24:08 +00001016 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001017}
1018
1019sub do_env_funcdescni{
1020 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001021 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001022 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +00001023 return "<dl><dt><b><tt class=\"function\">$function_name</tt></b>"
Fred Drakec612a142001-03-29 18:24:08 +00001024 . "(<var>$arg_list</var>)\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001025 . '<dd>'
1026 . $_
1027 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001028}
1029
1030sub do_cmd_funcline{
1031 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001032 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001033 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +00001034 my $prefix = "<tt class=\"function\">$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +00001035 my $idx = make_str_index_entry($prefix . get_indexsubitem());
1036 $prefix =~ s/\(\)//;
1037
Fred Drakec612a142001-03-29 18:24:08 +00001038 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001039}
1040
Fred Drake6b3fb781999-07-12 16:50:09 +00001041sub do_cmd_funclineni{
1042 local($_) = @_;
1043 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001044 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +00001045 my $prefix = "<tt class=\"function\">$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +00001046
Fred Drakec612a142001-03-29 18:24:08 +00001047 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6b3fb781999-07-12 16:50:09 +00001048}
1049
Fred Drake6659c301998-03-03 22:02:19 +00001050# Change this flag to index the opcode entries. I don't think it's very
1051# useful to index them, since they're only presented to describe the dis
1052# module.
1053#
1054$INDEX_OPCODES = 0;
1055
1056sub do_env_opcodedesc{
1057 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001058 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001059 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +00001060 my $idx;
1061 if ($INDEX_OPCODES) {
Fred Drakef1927a62001-06-20 21:29:30 +00001062 $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>"
1063 . ' (byte code instruction)');
Fred Drake08932051998-04-17 02:15:42 +00001064 $idx =~ s/ \(byte code instruction\)//;
1065 }
1066 else {
Fred Drakef1927a62001-06-20 21:29:30 +00001067 $idx = "<tt class=\"opcode\">$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +00001068 }
1069 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +00001070 if ($arg_list) {
1071 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
1072 }
Fred Drake62e43691998-08-10 19:40:44 +00001073 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001074}
1075
1076sub do_env_datadesc{
1077 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001078 my $dataname = next_argument();
1079 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +00001080 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001081 return "<dl><dt><b>$idx</b>\n<dd>"
1082 . $_
1083 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001084}
1085
1086sub do_env_datadescni{
1087 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001088 my $idx = next_argument();
1089 if (! $STRING_INDEX_TT) {
1090 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +00001091 }
Fred Drake62e43691998-08-10 19:40:44 +00001092 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001093}
1094
1095sub do_cmd_dataline{
1096 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001097 my $data_name = next_argument();
1098 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +00001099 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001100 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001101}
1102
Fred Drakeadb272c2000-04-10 17:47:14 +00001103sub do_cmd_datalineni{
1104 local($_) = @_;
1105 my $data_name = next_argument();
1106 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
1107}
1108
Fred Drake42b31a51998-03-27 05:16:10 +00001109sub do_env_excdesc{
1110 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001111 my $excname = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001112 my $idx = make_str_index_entry("<tt class=\"exception\">$excname</tt>");
Fred Drakeaf07b2c2001-10-26 03:09:27 +00001113 return ("<dl><dt><b>${TLSTART}exception$TLEND $idx</b>"
1114 . "\n<dd>"
1115 . $_
1116 . '</dl>');
Fred Drake42b31a51998-03-27 05:16:10 +00001117}
1118
Fred Drake62e43691998-08-10 19:40:44 +00001119sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +00001120
1121
Fred Drake643d76d2000-09-09 06:07:37 +00001122sub handle_classlike_descriptor{
1123 local($_, $what) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001124 $THIS_CLASS = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001125 my $arg_list = convert_args(next_argument());
Fred Drakeccc62721999-01-05 22:16:29 +00001126 $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +00001127 "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +00001128 $idx =~ s/ \(.*\)//;
Fred Drakeaf07b2c2001-10-26 03:09:27 +00001129 return ("<dl><dt><b>$TLSTART$what$TLEND $idx</b>"
1130 . "(<var>$arg_list</var>)\n<dd>"
Fred Drakeab357ec2001-03-02 18:57:05 +00001131 . $_
1132 . '</dl>');
Fred Drakec9a44381998-03-17 06:29:13 +00001133}
1134
Fred Drake643d76d2000-09-09 06:07:37 +00001135sub do_env_classdesc{
1136 return handle_classlike_descriptor(@_[0], "class");
1137}
1138
Fred Drake06a01e82001-05-11 01:00:30 +00001139sub do_env_classdescstar{
1140 local($_) = @_;
1141 $THIS_CLASS = next_argument();
1142 $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +00001143 "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)");
Fred Drake06a01e82001-05-11 01:00:30 +00001144 $idx =~ s/ \(.*\)//;
Fred Drakeaf07b2c2001-10-26 03:09:27 +00001145 return ("<dl><dt><b>${TLSTART}class$TLEND $idx</b>\n<dd>"
Fred Drake06a01e82001-05-11 01:00:30 +00001146 . $_
1147 . '</dl>');
1148}
1149
Fred Drake643d76d2000-09-09 06:07:37 +00001150sub do_env_excclassdesc{
1151 return handle_classlike_descriptor(@_[0], "exception");
1152}
1153
Fred Drake42b31a51998-03-27 05:16:10 +00001154
1155sub do_env_methoddesc{
1156 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001157 my $class_name = next_optional_argument();
1158 $class_name = $THIS_CLASS
1159 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +00001160 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001161 my $arg_list = convert_args(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001162 my $extra = '';
1163 if ($class_name) {
1164 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +00001165 }
Fred Drakef1927a62001-06-20 21:29:30 +00001166 my $idx = make_str_index_entry(
1167 "<tt class=\"method\">$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +00001168 $idx =~ s/ \(.*\)//;
1169 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +00001170 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001171}
1172
1173
Fred Drake7d45f6d1999-01-05 14:39:27 +00001174sub do_cmd_methodline{
1175 local($_) = @_;
1176 my $class_name = next_optional_argument();
1177 $class_name = $THIS_CLASS
1178 unless $class_name;
1179 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001180 my $arg_list = convert_args(next_argument());
Fred Drake7d45f6d1999-01-05 14:39:27 +00001181 my $extra = '';
1182 if ($class_name) {
1183 $extra = " ($class_name method)";
1184 }
Fred Drakef1927a62001-06-20 21:29:30 +00001185 my $idx = make_str_index_entry(
1186 "<tt class=\"method\">$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +00001187 $idx =~ s/ \(.*\)//;
1188 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +00001189 return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake7d45f6d1999-01-05 14:39:27 +00001190 . $_;
1191}
1192
1193
Fred Draked64a40d1998-09-10 18:59:13 +00001194sub do_cmd_methodlineni{
1195 local($_) = @_;
1196 next_optional_argument();
1197 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001198 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +00001199 return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Draked64a40d1998-09-10 18:59:13 +00001200 . $_;
1201}
1202
Fred Drake42b31a51998-03-27 05:16:10 +00001203sub do_env_methoddescni{
1204 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001205 next_optional_argument();
1206 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001207 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +00001208 return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +00001209 . $_
1210 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001211}
1212
1213
1214sub do_env_memberdesc{
1215 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001216 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001217 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +00001218 $class = $THIS_CLASS
1219 unless $class;
Fred Drake08932051998-04-17 02:15:42 +00001220 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +00001221 $extra = " ($class attribute)"
1222 if ($class ne '');
Fred Drakef1927a62001-06-20 21:29:30 +00001223 my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +00001224 $idx =~ s/ \(.*\)//;
1225 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001226 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001227}
1228
1229
Fred Drake5ccf3301998-04-17 20:04:09 +00001230sub do_cmd_memberline{
1231 local($_) = @_;
1232 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001233 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +00001234 $class = $THIS_CLASS
1235 unless $class;
1236 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +00001237 $extra = " ($class attribute)"
1238 if ($class ne '');
Fred Drakef1927a62001-06-20 21:29:30 +00001239 my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +00001240 $idx =~ s/ \(.*\)//;
1241 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001242 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001243}
1244
Fred Drakef269e592001-07-17 23:05:57 +00001245
Fred Drake42b31a51998-03-27 05:16:10 +00001246sub do_env_memberdescni{
1247 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001248 next_optional_argument();
1249 my $member = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001250 return "<dl><dt><b><tt class=\"member\">$member</tt></b>\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +00001251 . $_
1252 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001253}
1254
1255
Fred Drake5ccf3301998-04-17 20:04:09 +00001256sub do_cmd_memberlineni{
1257 local($_) = @_;
1258 next_optional_argument();
1259 my $member = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001260 return "<dt><b><tt class=\"member\">$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001261}
1262
Fred Drakef269e592001-07-17 23:05:57 +00001263
1264@col_aligns = ('<td>', '<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +00001265
Fred Drakecb199762001-08-16 21:56:24 +00001266%FontConversions = ('cdata' => 'tt class="cdata"',
1267 'character' => 'tt class="character"',
1268 'class' => 'tt class="class"',
1269 'command' => 'code',
1270 'constant' => 'tt class="constant"',
1271 'exception' => 'tt class="exception"',
1272 'file' => 'tt class="file"',
1273 'filenq' => 'tt class="file"',
1274 'kbd' => 'kbd',
1275 'member' => 'tt class="member"',
1276 'programopt' => 'b',
1277 'textrm' => '',
1278 );
1279
Fred Drakef74e5b71999-04-28 14:58:49 +00001280sub fix_font{
1281 # do a little magic on a font name to get the right behavior in the first
1282 # column of the output table
1283 my $font = @_[0];
Fred Drakecb199762001-08-16 21:56:24 +00001284 if (defined $FontConversions{$font}) {
1285 $font = $FontConversions{$font};
Fred Drakeafc7ce12001-01-22 17:33:24 +00001286 }
Fred Drakef74e5b71999-04-28 14:58:49 +00001287 return $font;
1288}
1289
Fred Drakee15956b2000-04-03 04:51:13 +00001290sub figure_column_alignment{
1291 my $a = @_[0];
1292 my $mark = substr($a, 0, 1);
1293 my $r = '';
1294 if ($mark eq 'c')
1295 { $r = ' align="center"'; }
1296 elsif ($mark eq 'r')
1297 { $r = ' align="right"'; }
1298 elsif ($mark eq 'l')
1299 { $r = ' align="left"'; }
1300 elsif ($mark eq 'p')
1301 { $r = ' align="left"'; }
1302 return $r;
1303}
1304
Fred Drake6659c301998-03-03 22:02:19 +00001305sub setup_column_alignments{
1306 local($_) = @_;
Fred Drakef269e592001-07-17 23:05:57 +00001307 my($s1,$s2,$s3,$s4,$a5) = split(/[|]/,$_);
Fred Drakee15956b2000-04-03 04:51:13 +00001308 my $a1 = figure_column_alignment($s1);
1309 my $a2 = figure_column_alignment($s2);
1310 my $a3 = figure_column_alignment($s3);
1311 my $a4 = figure_column_alignment($s4);
Fred Drakef269e592001-07-17 23:05:57 +00001312 my $a5 = figure_column_alignment($s5);
Fred Drakee15956b2000-04-03 04:51:13 +00001313 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
1314 $col_aligns[1] = "<td$a2>";
1315 $col_aligns[2] = "<td$a3>";
1316 $col_aligns[3] = "<td$a4>";
Fred Drakef269e592001-07-17 23:05:57 +00001317 $col_aligns[4] = "<td$a5>";
Fred Drake79189b51999-04-28 13:54:30 +00001318 # return the aligned header start tags
Fred Drakef269e592001-07-17 23:05:57 +00001319 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>", "<th$a5>");
Fred Drakee15956b2000-04-03 04:51:13 +00001320}
1321
1322sub get_table_col1_fonts{
1323 my $font = $globals{'lineifont'};
1324 my ($sfont,$efont) = ('', '');
1325 if ($font) {
1326 $sfont = "<$font>";
1327 $efont = "</$font>";
1328 $efont =~ s/ .*>/>/;
1329 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001330 return ($sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +00001331}
1332
1333sub do_env_tableii{
1334 local($_) = @_;
Fred Drakef269e592001-07-17 23:05:57 +00001335 my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001336 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001337 my $h1 = next_argument();
1338 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001339 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001340 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001341 my $a1 = $col_aligns[0];
1342 my $a2 = $col_aligns[1];
1343 s/\\lineii</\\lineii[$a1|$a2]</g;
1344 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001345 . "\n <thead>"
1346 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001347 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1348 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001349 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001350 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001351 . "\n <tbody valign=\"baseline\">"
Fred Drake351960d2000-10-26 20:14:58 +00001352 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001353 . "\n </tbody>"
1354 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001355}
1356
Fred Drakeda72b932000-09-21 15:58:02 +00001357sub do_env_longtableii{
1358 return do_env_tableii(@_);
1359}
1360
Fred Drake6659c301998-03-03 22:02:19 +00001361sub do_cmd_lineii{
1362 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001363 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001364 my $c1 = next_argument();
1365 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001366 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001367 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001368 $c2 = '&nbsp;' if ($c2 eq '');
1369 my($c1align,$c2align) = split('\|', $aligns);
1370 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001371 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001372 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001373 }
Fred Drakee15956b2000-04-03 04:51:13 +00001374 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1375 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001376 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001377}
1378
1379sub do_env_tableiii{
1380 local($_) = @_;
Fred Drakef269e592001-07-17 23:05:57 +00001381 my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001382 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001383 my $h1 = next_argument();
1384 my $h2 = next_argument();
1385 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001386 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001387 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001388 my $a1 = $col_aligns[0];
1389 my $a2 = $col_aligns[1];
1390 my $a3 = $col_aligns[2];
1391 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1392 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001393 . "\n <thead>"
1394 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001395 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1396 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1397 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001398 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001399 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001400 . "\n <tbody valign=\"baseline\">"
Fred Drake62e43691998-08-10 19:40:44 +00001401 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001402 . "\n </tbody>"
1403 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001404}
1405
Fred Drakeda72b932000-09-21 15:58:02 +00001406sub do_env_longtableiii{
1407 return do_env_tableiii(@_);
1408}
1409
Fred Drake6659c301998-03-03 22:02:19 +00001410sub do_cmd_lineiii{
1411 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001412 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001413 my $c1 = next_argument();
Fred Drakef269e592001-07-17 23:05:57 +00001414 my $c2 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +00001415 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001416 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001417 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001418 $c3 = '&nbsp;' if ($c3 eq '');
1419 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1420 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001421 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001422 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001423 }
Fred Drakee15956b2000-04-03 04:51:13 +00001424 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001425 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001426 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001427 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001428}
1429
Fred Drakea0f4c941998-07-24 22:16:04 +00001430sub do_env_tableiv{
1431 local($_) = @_;
Fred Drakef269e592001-07-17 23:05:57 +00001432 my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001433 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001434 my $h1 = next_argument();
1435 my $h2 = next_argument();
1436 my $h3 = next_argument();
1437 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001438 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001439 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001440 my $a1 = $col_aligns[0];
1441 my $a2 = $col_aligns[1];
1442 my $a3 = $col_aligns[2];
1443 my $a4 = $col_aligns[3];
1444 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1445 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001446 . "\n <thead>"
1447 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001448 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1449 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1450 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1451 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001452 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001453 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001454 . "\n <tbody valign=\"baseline\">"
Fred Drake62e43691998-08-10 19:40:44 +00001455 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001456 . "\n </tbody>"
1457 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001458}
1459
Fred Drakeda72b932000-09-21 15:58:02 +00001460sub do_env_longtableiv{
1461 return do_env_tableiv(@_);
1462}
1463
Fred Drakea0f4c941998-07-24 22:16:04 +00001464sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001465 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001466 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001467 my $c1 = next_argument();
1468 my $c2 = next_argument();
1469 my $c3 = next_argument();
1470 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001471 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001472 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001473 $c4 = '&nbsp;' if ($c4 eq '');
1474 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1475 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001476 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001477 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001478 }
Fred Drakee15956b2000-04-03 04:51:13 +00001479 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001480 . " $c2align$c2</td>\n"
1481 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001482 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001483 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001484}
1485
Fred Drakef269e592001-07-17 23:05:57 +00001486sub do_env_tablev{
1487 local($_) = @_;
1488 my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
1489 my $font = fix_font(next_argument());
1490 my $h1 = next_argument();
1491 my $h2 = next_argument();
1492 my $h3 = next_argument();
1493 my $h4 = next_argument();
1494 my $h5 = next_argument();
1495 s/[\s\n]+//;
1496 $globals{'lineifont'} = $font;
1497 my $a1 = $col_aligns[0];
1498 my $a2 = $col_aligns[1];
1499 my $a3 = $col_aligns[2];
1500 my $a4 = $col_aligns[3];
1501 my $a5 = $col_aligns[4];
1502 s/\\linev</\\linev[$a1|$a2|$a3|$a4|$a5]</g;
1503 return '<table border align="center" style="border-collapse: collapse">'
1504 . "\n <thead>"
1505 . "\n <tr class=\"tableheader\">"
1506 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1507 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1508 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1509 . "\n $th4<b>$h4</b>\&nbsp;</th>"
1510 . "\n $th5<b>$h5</b>\&nbsp;</th>"
1511 . "\n </tr>"
1512 . "\n </thead>"
1513 . "\n <tbody valign=\"baseline\">"
1514 . $_
1515 . "\n </tbody>"
1516 . "\n</table>";
1517}
1518
1519sub do_env_longtablev{
1520 return do_env_tablev(@_);
1521}
1522
1523sub do_cmd_linev{
1524 local($_) = @_;
1525 my $aligns = next_optional_argument();
1526 my $c1 = next_argument();
1527 my $c2 = next_argument();
1528 my $c3 = next_argument();
1529 my $c4 = next_argument();
1530 my $c5 = next_argument();
1531 s/[\s\n]+//;
1532 my($sfont,$efont) = get_table_col1_fonts();
1533 $c5 = '&nbsp;' if ($c5 eq '');
1534 my($c1align,$c2align,$c3align,$c4align,$c5align) = split('\|', $aligns);
1535 my $padding = '';
1536 if ($c1align =~ /align="right"/ || $c1 eq '') {
1537 $padding = '&nbsp;';
1538 }
1539 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1540 . " $c2align$c2</td>\n"
1541 . " $c3align$c3</td>\n"
1542 . " $c4align$c4</td>\n"
1543 . " $c5align$c5</td>"
1544 . $_;
1545}
1546
Fred Drake3be20742000-08-31 06:22:54 +00001547
1548# These can be used to control the title page appearance;
1549# they need a little bit of documentation.
1550#
1551# If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the
1552# $ICONSERVER directory, or include path information (other than "./"). The
1553# default image type will be assumed if an extension is not provided.
1554#
1555# If specified, the "title page" will contain two colums: one containing the
1556# title/author/etc., and the other containing the graphic. Use the other
1557# four variables listed here to control specific details of the layout; all
1558# are optional.
1559#
1560# $TITLE_PAGE_GRAPHIC = "my-company-logo";
1561# $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%";
1562# $TITLE_PAGE_GRAPHIC_WIDTH = 150;
1563# $TITLE_PAGE_GRAPHIC_HEIGHT = 150;
1564# $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0;
1565
1566sub make_my_titlepage() {
1567 my $the_title = "";
Fred Drake6659c301998-03-03 22:02:19 +00001568 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001569 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake3be20742000-08-31 06:22:54 +00001570 }
1571 else {
1572 write_warnings("\nThis document has no title.");
1573 }
Fred Drake6659c301998-03-03 22:02:19 +00001574 if ($t_author) {
1575 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001576 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001577 $href = make_named_href('author', $href,
Fred Drakef1927a62001-06-20 21:29:30 +00001578 "<b><font size=\"+2\">$t_author"
1579 . '</font></b>');
Fred Drakec9a44381998-03-17 06:29:13 +00001580 $the_title .= "\n<p>$href</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001581 }
1582 else {
Fred Drakef1927a62001-06-20 21:29:30 +00001583 $the_title .= ("\n<p><b><font size=\"+2\">$t_author"
1584 . '</font></b></p>');
Fred Drake6659c301998-03-03 22:02:19 +00001585 }
Fred Drake3be20742000-08-31 06:22:54 +00001586 }
1587 else {
1588 write_warnings("\nThere is no author for this document.");
1589 }
Fred Drake6659c301998-03-03 22:02:19 +00001590 if ($t_institute) {
Fred Drake3be20742000-08-31 06:22:54 +00001591 $the_title .= "\n<p>$t_institute</p>";
1592 }
Fred Draked07868a1998-05-14 21:00:28 +00001593 if ($DEVELOPER_ADDRESS) {
Fred Drake3be20742000-08-31 06:22:54 +00001594 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";
1595 }
Fred Drake6659c301998-03-03 22:02:19 +00001596 if ($t_affil) {
Fred Drake3be20742000-08-31 06:22:54 +00001597 $the_title .= "\n<p><i>$t_affil</i></p>";
1598 }
Fred Drake6659c301998-03-03 22:02:19 +00001599 if ($t_date) {
Fred Drakede77bc52000-12-14 18:36:12 +00001600 $the_title .= "\n<p>";
Fred Draked04592a2000-10-25 16:15:13 +00001601 if ($PACKAGE_VERSION) {
Fred Drakef1927a62001-06-20 21:29:30 +00001602 $the_title .= ('<strong>Release '
1603 . "$PACKAGE_VERSION$RELEASE_INFO</strong><br>\n");
Fred Drake3be20742000-08-31 06:22:54 +00001604 }
Fred Drakede77bc52000-12-14 18:36:12 +00001605 $the_title .= "<strong>$t_date</strong></p>"
Fred Drake6659c301998-03-03 22:02:19 +00001606 }
1607 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001608 $the_title .= "\n<p>$t_address</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001609 }
1610 else {
1611 $the_title .= "\n<p>";
1612 }
Fred Drake6659c301998-03-03 22:02:19 +00001613 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001614 $the_title .= "\n<p>$t_email</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001615 }
1616 return $the_title;
1617}
1618
Fred Drake3be20742000-08-31 06:22:54 +00001619sub make_my_titlegraphic() {
Fred Drake7a40c072000-10-02 14:43:38 +00001620 my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC);
Fred Drake3be20742000-08-31 06:22:54 +00001621 my $graphic = "<td class=\"titlegraphic\"";
1622 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\""
1623 if ($TITLE_PAGE_GRAPHIC_COLWIDTH);
1624 $graphic .= "><img";
1625 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\""
1626 if ($TITLE_PAGE_GRAPHIC_WIDTH);
1627 $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\""
1628 if ($TITLE_PAGE_GRAPHIC_HEIGHT);
Fred Drake5f84c9b2000-10-03 06:05:25 +00001629 $graphic .= "\n src=\"$filename\"></td>\n";
Fred Drake3be20742000-08-31 06:22:54 +00001630 return $graphic;
1631}
1632
1633sub do_cmd_maketitle {
1634 local($_) = @_;
1635 my $the_title = "\n<div class=\"titlepage\">";
1636 if ($TITLE_PAGE_GRAPHIC) {
1637 if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) {
1638 $the_title .= ("\n<table border=\"0\" width=\"100%\">"
1639 . "<tr align=\"right\">\n<td>"
1640 . make_my_titlepage()
1641 . "</td>\n"
1642 . make_my_titlegraphic()
1643 . "</tr>\n</table>");
1644 }
1645 else {
1646 $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n"
1647 . make_my_titlegraphic()
1648 . "<td>"
1649 . make_my_titlepage()
1650 . "</td></tr>\n</table>");
1651 }
1652 }
1653 else {
1654 $the_title .= ("\n<center>"
1655 . make_my_titlepage()
1656 . "\n</center>");
1657 }
1658 $the_title .= "\n</div>";
1659 return $the_title . $_;
Fred Drake90fdda51999-02-16 20:27:42 +00001660 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001661 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001662}
1663
1664
Fred Drake885215c1998-05-20 21:32:09 +00001665#
Fred Drakea0f4c941998-07-24 22:16:04 +00001666# Module synopsis support
1667#
1668
1669require SynopsisTable;
1670
Fred Drakef7685d71998-07-25 03:31:46 +00001671sub get_chapter_id(){
1672 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001673 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1674 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001675 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001676}
1677
Fred Drake643d76d2000-09-09 06:07:37 +00001678# 'chapter' => 'SynopsisTable instance'
1679%ModuleSynopses = ();
Fred Drakef7685d71998-07-25 03:31:46 +00001680
1681sub get_synopsis_table($){
1682 my($chap) = @_;
Fred Drakef7685d71998-07-25 03:31:46 +00001683 my $key;
1684 foreach $key (keys %ModuleSynopses) {
1685 if ($key eq $chap) {
1686 return $ModuleSynopses{$chap};
1687 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001688 }
Fred Drake643d76d2000-09-09 06:07:37 +00001689 my $st = SynopsisTable->new();
Fred Drakef7685d71998-07-25 03:31:46 +00001690 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001691 return $st;
1692}
1693
Fred Drake62e43691998-08-10 19:40:44 +00001694sub do_cmd_moduleauthor{
1695 local($_) = @_;
1696 next_argument();
1697 next_argument();
1698 return $_;
1699}
1700
1701sub do_cmd_sectionauthor{
1702 local($_) = @_;
1703 next_argument();
1704 next_argument();
1705 return $_;
1706}
1707
Fred Drakea0f4c941998-07-24 22:16:04 +00001708sub do_cmd_declaremodule{
1709 local($_) = @_;
1710 my $key = next_optional_argument();
1711 my $type = next_argument();
1712 my $name = next_argument();
1713 my $st = get_synopsis_table(get_chapter_id());
1714 #
1715 $key = $name unless $key;
1716 $type = 'built-in' if $type eq 'builtin';
1717 $st->declare($name, $key, $type);
1718 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001719 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001720}
1721
1722sub do_cmd_modulesynopsis{
1723 local($_) = @_;
1724 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001725 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001726 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001727}
1728
1729sub do_cmd_localmoduletable{
1730 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001731 my $chap = get_chapter_id();
Fred Drake643d76d2000-09-09 06:07:37 +00001732 my $st = get_synopsis_table($chap);
1733 $st->set_file("$CURRENT_FILE");
Fred Drake557460c1999-03-02 16:05:35 +00001734 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001735}
1736
1737sub process_all_localmoduletables{
Fred Drake643d76d2000-09-09 06:07:37 +00001738 my $key;
1739 my $st, $file;
1740 foreach $key (keys %ModuleSynopses) {
1741 $st = $ModuleSynopses{$key};
1742 $file = $st->get_file();
1743 if ($file) {
1744 process_localmoduletables_in_file($file);
1745 }
1746 else {
Fred Drake6fe46602001-06-23 03:13:30 +00001747 print "\nsynopsis table $key has no file association\n";
Fred Drake643d76d2000-09-09 06:07:37 +00001748 }
1749 }
1750}
1751
1752sub process_localmoduletables_in_file{
1753 my $file = @_[0];
1754 open(MYFILE, "<$file");
1755 local($_);
1756 sysread(MYFILE, $_, 1024*1024);
1757 close(MYFILE);
1758 # need to get contents of file in $_
Fred Drake557460c1999-03-02 16:05:35 +00001759 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001760 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001761 my $chap = $1;
1762 my $st = get_synopsis_table($chap);
1763 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001764 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001765 }
Fred Drake643d76d2000-09-09 06:07:37 +00001766 open(MYFILE,">$file");
1767 print MYFILE $_;
1768 close(MYFILE);
Fred Drakea0f4c941998-07-24 22:16:04 +00001769}
Fred Drake557460c1999-03-02 16:05:35 +00001770sub process_python_state{
1771 process_all_localmoduletables();
Fred Drake77602f22001-07-06 22:43:02 +00001772 process_grammar_files();
Fred Drake557460c1999-03-02 16:05:35 +00001773}
Fred Drakea0f4c941998-07-24 22:16:04 +00001774
1775
1776#
1777# "See also:" -- references placed at the end of a \section
1778#
1779
1780sub do_env_seealso{
Fred Drakef1927a62001-06-20 21:29:30 +00001781 return ("<div class=\"seealso\">\n "
1782 . "<p class=\"heading\"><b>See Also:</b></p>\n"
1783 . @_[0]
1784 . '</div>');
Fred Drakea0f4c941998-07-24 22:16:04 +00001785}
1786
Fred Drake5ed35fd2001-11-30 18:09:54 +00001787sub do_env_seealsostar{
1788 return ("<div class=\"seealso-simple\">\n "
1789 . @_[0]
1790 . '</div>');
1791}
1792
Fred Drakea0f4c941998-07-24 22:16:04 +00001793sub do_cmd_seemodule{
1794 # Insert the right magic to jump to the module definition. This should
1795 # work most of the time, at least for repeat builds....
1796 local($_) = @_;
1797 my $key = next_optional_argument();
1798 my $module = next_argument();
1799 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001800 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001801 $key = $module
1802 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001803 if ($text =~ /\.$/) {
1804 $period = '';
1805 }
Fred Drakef1927a62001-06-20 21:29:30 +00001806 return ('<dl compact class="seemodule">'
1807 . "\n <dt>Module <b><tt class=\"module\">"
1808 . "<a href=\"module-$key.html\">$module</a></tt>:</b>"
1809 . "\n <dd>$text$period\n </dl>"
1810 . $_);
Fred Drakea0f4c941998-07-24 22:16:04 +00001811}
1812
Fred Drakee0197bf2001-04-12 04:03:22 +00001813sub strip_html_markup($){
1814 my $str = @_[0];
1815 my $s = "$str";
1816 $s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g;
1817 $s =~ s/<\/[a-zA-Z0-9]+>//g;
1818 return $s;
1819}
1820
Fred Drake643d76d2000-09-09 06:07:37 +00001821sub handle_rfclike_reference{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001822 local($_, $what, $format) = @_;
Fred Drake37cc0c02000-04-26 18:05:24 +00001823 my $rfcnum = next_argument();
1824 my $title = next_argument();
1825 my $text = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +00001826 my $url = get_rfc_url($rfcnum, $format);
Fred Drake7a40c072000-10-02 14:43:38 +00001827 my $icon = get_link_icon($url);
Fred Drakee0197bf2001-04-12 04:03:22 +00001828 my $attrtitle = strip_html_markup($title);
Fred Drake37cc0c02000-04-26 18:05:24 +00001829 return '<dl compact class="seerfc">'
1830 . "\n <dt><a href=\"$url\""
Fred Drakee0197bf2001-04-12 04:03:22 +00001831 . "\n title=\"$attrtitle\""
Fred Drake5f84c9b2000-10-03 06:05:25 +00001832 . "\n >$what $rfcnum, <em>$title</em>$icon</a>"
Fred Drake37cc0c02000-04-26 18:05:24 +00001833 . "\n <dd>$text\n </dl>"
1834 . $_;
1835}
1836
Fred Drake643d76d2000-09-09 06:07:37 +00001837sub do_cmd_seepep{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001838 return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001839}
1840
1841sub do_cmd_seerfc{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001842 return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001843}
1844
Fred Drake48449982000-09-12 17:52:33 +00001845sub do_cmd_seetitle{
1846 local($_) = @_;
1847 my $url = next_optional_argument();
1848 my $title = next_argument();
1849 my $text = next_argument();
1850 if ($url) {
Fred Drake5f84c9b2000-10-03 06:05:25 +00001851 my $icon = get_link_icon($url);
Fred Drake48449982000-09-12 17:52:33 +00001852 return '<dl compact class="seetitle">'
1853 . "\n <dt><em class=\"citetitle\"><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001854 . "\n >$title$icon</a></em>"
Fred Drake48449982000-09-12 17:52:33 +00001855 . "\n <dd>$text\n </dl>"
1856 . $_;
1857 }
1858 return '<dl compact class="seetitle">'
1859 . "\n <dt><em class=\"citetitle\""
1860 . "\n >$title</em>"
1861 . "\n <dd>$text\n </dl>"
1862 . $_;
1863}
1864
Fred Drakeef4d1112000-05-09 16:17:51 +00001865sub do_cmd_seeurl{
1866 local($_) = @_;
1867 my $url = next_argument();
1868 my $text = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +00001869 my $icon = get_link_icon($url);
Fred Drakeef4d1112000-05-09 16:17:51 +00001870 return '<dl compact class="seeurl">'
1871 . "\n <dt><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001872 . "\n class=\"url\">$url$icon</a>"
Fred Drakeef4d1112000-05-09 16:17:51 +00001873 . "\n <dd>$text\n </dl>"
1874 . $_;
1875}
1876
Fred Drakea0f4c941998-07-24 22:16:04 +00001877sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001878 local($_) = @_;
1879 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001880 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001881}
1882
1883
1884#
Fred Drake885215c1998-05-20 21:32:09 +00001885# Definition list support.
1886#
1887
1888sub do_env_definitions{
Fred Drakef1927a62001-06-20 21:29:30 +00001889 return "<dl class=\"definitions\">" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001890}
1891
1892sub do_cmd_term{
1893 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001894 my $term = next_argument();
1895 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001896 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001897 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001898}
1899
1900
Fred Drake38178fd2000-09-22 17:05:04 +00001901# I don't recall exactly why this was needed, but it was very much needed.
1902# We'll see if anything breaks when I move the "code" line out -- some
1903# things broke with it in.
1904
1905#code # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001906process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001907declaremodule # [] # {} # {}
1908memberline # [] # {}
1909methodline # [] # {} # {}
1910modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001911platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001912samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001913setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001914withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001915_RAW_ARG_DEFERRED_CMDS_
1916
1917
Fred Drake8a5e6792002-04-15 18:41:31 +00001918$alltt_start = '<div class="verbatim"><pre>';
1919$alltt_end = '</pre></div>';
Fred Drake86333602001-04-10 17:13:39 +00001920
1921sub do_env_alltt {
1922 local ($_) = @_;
1923 local($closures,$reopens,@open_block_tags);
1924
1925 # get the tag-strings for all open tags
1926 local(@keep_open_tags) = @$open_tags_R;
1927 ($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R);
1928
1929 # get the tags for text-level tags only
1930 $open_tags_R = [ @keep_open_tags ];
1931 local($local_closures, $local_reopens);
1932 ($local_closures, $local_reopens,@open_block_tags)
1933 = &preserve_open_block_tags
1934 if (@$open_tags_R);
1935
1936 $open_tags_R = [ @open_block_tags ];
1937
1938 do {
1939 local($open_tags_R) = [ @open_block_tags ];
1940 local(@save_open_tags) = ();
1941
1942 local($cnt) = ++$global{'max_id'};
1943 $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C
1944 , $_ , $O, $global{'max_id'}, "$C$O$cnt$C");
1945
1946 $_ = &translate_environments($_);
1947 $_ = &translate_commands($_) if (/\\/);
1948
1949 # preserve space-runs, using &nbsp;
1950 while (s/(\S) ( +)/$1$2;SPMnbsp;/g){};
1951 s/(<BR>) /$1;SPMnbsp;/g;
1952
1953 $_ = join('', $closures, $alltt_start, $local_reopens
1954 , $_
1955 , &balance_tags() #, $local_closures
1956 , $alltt_end, $reopens);
1957 undef $open_tags_R; undef @save_open_tags;
1958 };
1959 $open_tags_R = [ @keep_open_tags ];
1960 $_;
1961}
1962
Fred Drake57e52ef2001-06-15 21:31:57 +00001963sub do_cmd_verbatiminput{
1964 local($_) = @_;
1965 my $fname = next_argument();
1966 my $file;
1967 my $found = 0;
1968 my $texpath;
1969 # Search TEXINPUTS for the input file, the way we're supposed to:
1970 foreach $texpath (split /$envkey/, $TEXINPUTS) {
1971 $file = "$texpath$dd$fname";
1972 last if ($found = (-f $file));
1973 }
Fred Drake77602f22001-07-06 22:43:02 +00001974 my $srcname;
Fred Drake57e52ef2001-06-15 21:31:57 +00001975 my $text;
1976 if ($found) {
1977 open(MYFILE, "<$file") || die "\n$!\n";
1978 read(MYFILE, $text, 1024*1024);
1979 close(MYFILE);
Fred Drake77602f22001-07-06 22:43:02 +00001980 use File::Basename;
1981 my $srcdir, $srcext;
1982 ($srcname, $srcdir, $srcext) = fileparse($file, '\..*');
1983 open(MYFILE, ">$srcname.txt");
1984 print MYFILE $text;
1985 close(MYFILE);
Fred Drake57e52ef2001-06-15 21:31:57 +00001986 #
1987 # These rewrites convert the raw text to something that will
1988 # be properly visible as HTML and also will pass through the
1989 # vagaries of conversion through LaTeX2HTML. The order in
1990 # which the specific rewrites are performed is significant.
1991 #
1992 $text =~ s/\&/\&amp;/g;
1993 # These need to happen before the normal < and > re-writes,
1994 # since we need to avoid LaTeX2HTML's attempt to perform
1995 # ligature processing without regard to context (since it
1996 # doesn't have font information).
1997 $text =~ s/--/-&\#45;/g;
1998 $text =~ s/<</\&lt;\&\#60;/g;
1999 $text =~ s/>>/\&gt;\&\#62;/g;
2000 # Just normal re-writes...
2001 $text =~ s/</\&lt;/g;
2002 $text =~ s/>/\&gt;/g;
2003 # These last isn't needed for the HTML, but is needed to get
2004 # past LaTeX2HTML processing TeX macros. We use &#92; instead
2005 # of &sol; since many browsers don't support that.
2006 $text =~ s/\\/\&\#92;/g;
2007 }
2008 else {
2009 $text = '<b>Could not locate requested file <i>$fname</i>!</b>\n';
2010 }
Fred Drake8a5e6792002-04-15 18:41:31 +00002011 return ("<div class=\"verbatim\">\n<pre>"
Fred Drake57e52ef2001-06-15 21:31:57 +00002012 . $text
Fred Drake8a5e6792002-04-15 18:41:31 +00002013 . "</pre>\n<div class=\"footer\">\n"
Fred Drake77602f22001-07-06 22:43:02 +00002014 . "<a href=\"$srcname.txt\" type=\"text/plain\""
2015 . ">Download as text.</a>"
Fred Drake8a5e6792002-04-15 18:41:31 +00002016 . "\n</div></div>"
Fred Drake57e52ef2001-06-15 21:31:57 +00002017 . $_);
2018}
Fred Drake86333602001-04-10 17:13:39 +00002019
Fred Drake6659c301998-03-03 22:02:19 +000020201; # This must be the last line