blob: 5d33a6b1c420b6c2ec6dc88ca0264555e86bb0b4 [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 Drake34adb8a2002-04-15 20:48:40 +0000910sub cfuncline_helper{
911 my ($type, $name, $args) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000912 my $idx = make_str_index_entry(
Fred Drake34adb8a2002-04-15 20:48:40 +0000913 "<tt class=\"cfunction\">$name()</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +0000914 $idx =~ s/ \(.*\)//;
Fred Drake241551c2000-08-11 20:04:19 +0000915 $idx =~ s/\(\)//; # ???? - why both of these?
Fred Drake34adb8a2002-04-15 20:48:40 +0000916 return "$type <b>$idx</b>(<var>$args</var>)";
917}
918sub do_cmd_cfuncline{
919 local($_) = @_;
920 my $type = next_argument();
921 my $name = next_argument();
922 my $args = next_argument();
923 my $siginfo = cfuncline_helper($type, $name, $args);
924 return "<dt>$siginfo\n<dd>" . $_;
925}
926sub do_env_cfuncdesc{
927 local($_) = @_;
928 my $type = next_argument();
929 my $name = next_argument();
930 my $args = next_argument();
931 my $siginfo = cfuncline_helper($type, $name, $args);
932 my $result_rc = get_refcount($name, '');
Fred Drakee15956b2000-04-03 04:51:13 +0000933 my $rcinfo = '';
934 if ($result_rc eq '+1') {
Fred Drake241551c2000-08-11 20:04:19 +0000935 $rcinfo = 'New reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000936 }
937 elsif ($result_rc eq '0') {
Fred Drake241551c2000-08-11 20:04:19 +0000938 $rcinfo = 'Borrowed reference';
Fred Drakee15956b2000-04-03 04:51:13 +0000939 }
Fred Drakec2578c52000-04-10 18:26:45 +0000940 elsif ($result_rc eq 'null') {
Fred Drake241551c2000-08-11 20:04:19 +0000941 $rcinfo = 'Always <tt class="constant">NULL</tt>';
Fred Drakec2578c52000-04-10 18:26:45 +0000942 }
Fred Drakee15956b2000-04-03 04:51:13 +0000943 if ($rcinfo ne '') {
Fred Drake241551c2000-08-11 20:04:19 +0000944 $rcinfo = ( "\n<div class=\"refcount-info\">"
945 . "\n <span class=\"label\">Return value:</span>"
946 . "\n <span class=\"value\">$rcinfo.</span>"
947 . "\n</div>");
Fred Drakee15956b2000-04-03 04:51:13 +0000948 }
Fred Drake34adb8a2002-04-15 20:48:40 +0000949 return "<dl><dt>$siginfo\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +0000950 . $rcinfo
Fred Drake62e43691998-08-10 19:40:44 +0000951 . $_
952 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +0000953}
954
Fred Drakeeeb5ec42002-04-15 17:46:00 +0000955sub do_cmd_cmemberline{
956 local($_) = @_;
957 my $container = next_argument();
958 my $type = next_argument();
959 my $name = next_argument();
960 my $idx = make_str_index_entry("<tt class=\"cmember\">$name</tt>"
Fred Drake01572762002-04-15 19:35:29 +0000961 . " ($container member)");
Fred Drakeeeb5ec42002-04-15 17:46:00 +0000962 $idx =~ s/ \(.*\)//;
963 return "<dt>$type <b>$idx</b>\n<dd>"
964 . $_;
965}
966sub do_env_cmemberdesc{
967 local($_) = @_;
968 my $container = next_argument();
969 my $type = next_argument();
970 my $name = next_argument();
971 my $idx = make_str_index_entry("<tt class=\"cmember\">$name</tt>"
Fred Drake01572762002-04-15 19:35:29 +0000972 . " ($container member)");
Fred Drakeeeb5ec42002-04-15 17:46:00 +0000973 $idx =~ s/ \(.*\)//;
974 return "<dl><dt>$type <b>$idx</b>\n<dd>"
975 . $_
976 . '</dl>';
977}
978
Fred Drakee15956b2000-04-03 04:51:13 +0000979sub do_env_csimplemacrodesc{
980 local($_) = @_;
981 my $name = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +0000982 my $idx = make_str_index_entry("<tt class=\"macro\">$name</tt>");
Fred Drakee15956b2000-04-03 04:51:13 +0000983 return "<dl><dt><b>$idx</b>\n<dd>"
984 . $_
985 . '</dl>'
986}
987
Fred Drake6659c301998-03-03 22:02:19 +0000988sub do_env_ctypedesc{
989 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +0000990 my $index_name = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +0000991 my $type_name = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +0000992 $index_name = $type_name
993 unless $index_name;
994 my($name,$aname,$ahref) = new_link_info();
Fred Drakef1927a62001-06-20 21:29:30 +0000995 add_index_entry("<tt class=\"ctype\">$index_name</tt> (C type)", $ahref);
996 return "<dl><dt><b><tt class=\"ctype\">$aname$type_name</a></tt></b>\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +0000997 . $_
998 . '</dl>'
Fred Drake6659c301998-03-03 22:02:19 +0000999}
1000
1001sub do_env_cvardesc{
1002 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001003 my $var_type = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001004 my $var_name = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001005 my $idx = make_str_index_entry("<tt class=\"cdata\">$var_name</tt>"
Fred Drake90fdda51999-02-16 20:27:42 +00001006 . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +00001007 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001008 return "<dl><dt>$var_type <b>$idx</b>\n"
1009 . '<dd>'
1010 . $_
1011 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001012}
1013
Fred Drake3cdb89d2000-09-14 20:17:23 +00001014sub convert_args($){
1015 local($IN_DESC_HANDLER) = 1;
1016 local($_) = @_;
1017 return translate_commands($_);
1018}
1019
Fred Drake6659c301998-03-03 22:02:19 +00001020sub do_env_funcdesc{
1021 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001022 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001023 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +00001024 my $idx = make_str_index_entry("<tt class=\"function\">$function_name()"
1025 . '</tt>'
Fred Drake08932051998-04-17 02:15:42 +00001026 . get_indexsubitem());
1027 $idx =~ s/ \(.*\)//;
Fred Drakeccc62721999-01-05 22:16:29 +00001028 $idx =~ s/\(\)<\/tt>/<\/tt>/;
Fred Drakec612a142001-03-29 18:24:08 +00001029 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001030}
1031
1032sub do_env_funcdescni{
1033 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001034 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001035 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +00001036 return "<dl><dt><b><tt class=\"function\">$function_name</tt></b>"
Fred Drakec612a142001-03-29 18:24:08 +00001037 . "(<var>$arg_list</var>)\n"
Fred Drake90fdda51999-02-16 20:27:42 +00001038 . '<dd>'
1039 . $_
1040 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001041}
1042
1043sub do_cmd_funcline{
1044 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001045 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001046 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +00001047 my $prefix = "<tt class=\"function\">$function_name()</tt>";
Fred Drakeca675e41999-04-21 15:58:58 +00001048 my $idx = make_str_index_entry($prefix . get_indexsubitem());
1049 $prefix =~ s/\(\)//;
1050
Fred Drakec612a142001-03-29 18:24:08 +00001051 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001052}
1053
Fred Drake6b3fb781999-07-12 16:50:09 +00001054sub do_cmd_funclineni{
1055 local($_) = @_;
1056 my $function_name = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001057 my $arg_list = convert_args(next_argument());
Fred Drakef1927a62001-06-20 21:29:30 +00001058 my $prefix = "<tt class=\"function\">$function_name</tt>";
Fred Drake6b3fb781999-07-12 16:50:09 +00001059
Fred Drakec612a142001-03-29 18:24:08 +00001060 return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_;
Fred Drake6b3fb781999-07-12 16:50:09 +00001061}
1062
Fred Drake6659c301998-03-03 22:02:19 +00001063# Change this flag to index the opcode entries. I don't think it's very
1064# useful to index them, since they're only presented to describe the dis
1065# module.
1066#
1067$INDEX_OPCODES = 0;
1068
1069sub do_env_opcodedesc{
1070 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001071 my $opcode_name = next_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001072 my $arg_list = next_argument();
Fred Drake08932051998-04-17 02:15:42 +00001073 my $idx;
1074 if ($INDEX_OPCODES) {
Fred Drakef1927a62001-06-20 21:29:30 +00001075 $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>"
1076 . ' (byte code instruction)');
Fred Drake08932051998-04-17 02:15:42 +00001077 $idx =~ s/ \(byte code instruction\)//;
1078 }
1079 else {
Fred Drakef1927a62001-06-20 21:29:30 +00001080 $idx = "<tt class=\"opcode\">$opcode_name</tt>";
Fred Drake08932051998-04-17 02:15:42 +00001081 }
1082 my $stuff = "<dl><dt><b>$idx</b>";
Fred Drake6659c301998-03-03 22:02:19 +00001083 if ($arg_list) {
1084 $stuff .= "&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
1085 }
Fred Drake62e43691998-08-10 19:40:44 +00001086 return $stuff . "\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001087}
1088
1089sub do_env_datadesc{
1090 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001091 my $dataname = next_argument();
1092 my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem());
Fred Drake08932051998-04-17 02:15:42 +00001093 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001094 return "<dl><dt><b>$idx</b>\n<dd>"
1095 . $_
1096 . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001097}
1098
1099sub do_env_datadescni{
1100 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001101 my $idx = next_argument();
1102 if (! $STRING_INDEX_TT) {
1103 $idx = "<tt>$idx</tt>";
Fred Drake6659c301998-03-03 22:02:19 +00001104 }
Fred Drake62e43691998-08-10 19:40:44 +00001105 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake6659c301998-03-03 22:02:19 +00001106}
1107
1108sub do_cmd_dataline{
1109 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001110 my $data_name = next_argument();
1111 my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem());
Fred Drake6659c301998-03-03 22:02:19 +00001112 $idx =~ s/ \(.*\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001113 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001114}
1115
Fred Drakeadb272c2000-04-10 17:47:14 +00001116sub do_cmd_datalineni{
1117 local($_) = @_;
1118 my $data_name = next_argument();
1119 return "<dt><b><tt>$data_name</tt></b><dd>" . $_;
1120}
1121
Fred Drake42b31a51998-03-27 05:16:10 +00001122sub do_env_excdesc{
1123 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001124 my $excname = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001125 my $idx = make_str_index_entry("<tt class=\"exception\">$excname</tt>");
Fred Drakeaf07b2c2001-10-26 03:09:27 +00001126 return ("<dl><dt><b>${TLSTART}exception$TLEND $idx</b>"
1127 . "\n<dd>"
1128 . $_
1129 . '</dl>');
Fred Drake42b31a51998-03-27 05:16:10 +00001130}
1131
Fred Drake62e43691998-08-10 19:40:44 +00001132sub do_env_fulllineitems{ return do_env_itemize(@_); }
Fred Drake6659c301998-03-03 22:02:19 +00001133
1134
Fred Drake643d76d2000-09-09 06:07:37 +00001135sub handle_classlike_descriptor{
1136 local($_, $what) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001137 $THIS_CLASS = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001138 my $arg_list = convert_args(next_argument());
Fred Drakeccc62721999-01-05 22:16:29 +00001139 $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +00001140 "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" );
Fred Drake08932051998-04-17 02:15:42 +00001141 $idx =~ s/ \(.*\)//;
Fred Drakeaf07b2c2001-10-26 03:09:27 +00001142 return ("<dl><dt><b>$TLSTART$what$TLEND $idx</b>"
1143 . "(<var>$arg_list</var>)\n<dd>"
Fred Drakeab357ec2001-03-02 18:57:05 +00001144 . $_
1145 . '</dl>');
Fred Drakec9a44381998-03-17 06:29:13 +00001146}
1147
Fred Drake643d76d2000-09-09 06:07:37 +00001148sub do_env_classdesc{
1149 return handle_classlike_descriptor(@_[0], "class");
1150}
1151
Fred Drake06a01e82001-05-11 01:00:30 +00001152sub do_env_classdescstar{
1153 local($_) = @_;
1154 $THIS_CLASS = next_argument();
1155 $idx = make_str_index_entry(
Fred Drakef1927a62001-06-20 21:29:30 +00001156 "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)");
Fred Drake06a01e82001-05-11 01:00:30 +00001157 $idx =~ s/ \(.*\)//;
Fred Drakeaf07b2c2001-10-26 03:09:27 +00001158 return ("<dl><dt><b>${TLSTART}class$TLEND $idx</b>\n<dd>"
Fred Drake06a01e82001-05-11 01:00:30 +00001159 . $_
1160 . '</dl>');
1161}
1162
Fred Drake643d76d2000-09-09 06:07:37 +00001163sub do_env_excclassdesc{
1164 return handle_classlike_descriptor(@_[0], "exception");
1165}
1166
Fred Drake42b31a51998-03-27 05:16:10 +00001167
1168sub do_env_methoddesc{
1169 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001170 my $class_name = next_optional_argument();
1171 $class_name = $THIS_CLASS
1172 unless $class_name;
Fred Drake5a0ca4e1999-01-12 04:16:51 +00001173 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001174 my $arg_list = convert_args(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001175 my $extra = '';
1176 if ($class_name) {
1177 $extra = " ($class_name method)";
Fred Drake42b31a51998-03-27 05:16:10 +00001178 }
Fred Drakef1927a62001-06-20 21:29:30 +00001179 my $idx = make_str_index_entry(
1180 "<tt class=\"method\">$method()</tt>$extra");
Fred Drake08932051998-04-17 02:15:42 +00001181 $idx =~ s/ \(.*\)//;
1182 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +00001183 return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001184}
1185
1186
Fred Drake7d45f6d1999-01-05 14:39:27 +00001187sub do_cmd_methodline{
1188 local($_) = @_;
1189 my $class_name = next_optional_argument();
1190 $class_name = $THIS_CLASS
1191 unless $class_name;
1192 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001193 my $arg_list = convert_args(next_argument());
Fred Drake7d45f6d1999-01-05 14:39:27 +00001194 my $extra = '';
1195 if ($class_name) {
1196 $extra = " ($class_name method)";
1197 }
Fred Drakef1927a62001-06-20 21:29:30 +00001198 my $idx = make_str_index_entry(
1199 "<tt class=\"method\">$method()</tt>$extra");
Fred Drake7d45f6d1999-01-05 14:39:27 +00001200 $idx =~ s/ \(.*\)//;
1201 $idx =~ s/\(\)//;
Fred Drakec612a142001-03-29 18:24:08 +00001202 return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake7d45f6d1999-01-05 14:39:27 +00001203 . $_;
1204}
1205
1206
Fred Draked64a40d1998-09-10 18:59:13 +00001207sub do_cmd_methodlineni{
1208 local($_) = @_;
1209 next_optional_argument();
1210 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001211 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +00001212 return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Draked64a40d1998-09-10 18:59:13 +00001213 . $_;
1214}
1215
Fred Drake42b31a51998-03-27 05:16:10 +00001216sub do_env_methoddescni{
1217 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001218 next_optional_argument();
1219 my $method = next_argument();
Fred Drake3cdb89d2000-09-14 20:17:23 +00001220 my $arg_list = convert_args(next_argument());
Fred Drakec612a142001-03-29 18:24:08 +00001221 return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>"
Fred Drake62e43691998-08-10 19:40:44 +00001222 . $_
1223 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001224}
1225
1226
1227sub do_env_memberdesc{
1228 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001229 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001230 my $member = next_argument();
Fred Drake42b31a51998-03-27 05:16:10 +00001231 $class = $THIS_CLASS
1232 unless $class;
Fred Drake08932051998-04-17 02:15:42 +00001233 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +00001234 $extra = " ($class attribute)"
1235 if ($class ne '');
Fred Drakef1927a62001-06-20 21:29:30 +00001236 my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra");
Fred Drake42b31a51998-03-27 05:16:10 +00001237 $idx =~ s/ \(.*\)//;
1238 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001239 return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001240}
1241
1242
Fred Drake5ccf3301998-04-17 20:04:09 +00001243sub do_cmd_memberline{
1244 local($_) = @_;
1245 my $class = next_optional_argument();
Fred Drakeccc62721999-01-05 22:16:29 +00001246 my $member = next_argument();
Fred Drake5ccf3301998-04-17 20:04:09 +00001247 $class = $THIS_CLASS
1248 unless $class;
1249 my $extra = '';
Fred Drake085b8121999-04-21 14:00:29 +00001250 $extra = " ($class attribute)"
1251 if ($class ne '');
Fred Drakef1927a62001-06-20 21:29:30 +00001252 my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra");
Fred Drake5ccf3301998-04-17 20:04:09 +00001253 $idx =~ s/ \(.*\)//;
1254 $idx =~ s/\(\)//;
Fred Drake62e43691998-08-10 19:40:44 +00001255 return "<dt><b>$idx</b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001256}
1257
Fred Drakef269e592001-07-17 23:05:57 +00001258
Fred Drake42b31a51998-03-27 05:16:10 +00001259sub do_env_memberdescni{
1260 local($_) = @_;
Fred Drake08932051998-04-17 02:15:42 +00001261 next_optional_argument();
1262 my $member = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001263 return "<dl><dt><b><tt class=\"member\">$member</tt></b>\n<dd>"
Fred Drakee15956b2000-04-03 04:51:13 +00001264 . $_
1265 . '</dl>';
Fred Drake42b31a51998-03-27 05:16:10 +00001266}
1267
1268
Fred Drake5ccf3301998-04-17 20:04:09 +00001269sub do_cmd_memberlineni{
1270 local($_) = @_;
1271 next_optional_argument();
1272 my $member = next_argument();
Fred Drakef1927a62001-06-20 21:29:30 +00001273 return "<dt><b><tt class=\"member\">$member</tt></b><dd>" . $_;
Fred Drake5ccf3301998-04-17 20:04:09 +00001274}
1275
Fred Drakef269e592001-07-17 23:05:57 +00001276
1277@col_aligns = ('<td>', '<td>', '<td>', '<td>', '<td>');
Fred Drake6659c301998-03-03 22:02:19 +00001278
Fred Drakecb199762001-08-16 21:56:24 +00001279%FontConversions = ('cdata' => 'tt class="cdata"',
1280 'character' => 'tt class="character"',
1281 'class' => 'tt class="class"',
1282 'command' => 'code',
1283 'constant' => 'tt class="constant"',
1284 'exception' => 'tt class="exception"',
1285 'file' => 'tt class="file"',
1286 'filenq' => 'tt class="file"',
1287 'kbd' => 'kbd',
1288 'member' => 'tt class="member"',
1289 'programopt' => 'b',
1290 'textrm' => '',
1291 );
1292
Fred Drakef74e5b71999-04-28 14:58:49 +00001293sub fix_font{
1294 # do a little magic on a font name to get the right behavior in the first
1295 # column of the output table
1296 my $font = @_[0];
Fred Drakecb199762001-08-16 21:56:24 +00001297 if (defined $FontConversions{$font}) {
1298 $font = $FontConversions{$font};
Fred Drakeafc7ce12001-01-22 17:33:24 +00001299 }
Fred Drakef74e5b71999-04-28 14:58:49 +00001300 return $font;
1301}
1302
Fred Drakee15956b2000-04-03 04:51:13 +00001303sub figure_column_alignment{
1304 my $a = @_[0];
1305 my $mark = substr($a, 0, 1);
1306 my $r = '';
1307 if ($mark eq 'c')
1308 { $r = ' align="center"'; }
1309 elsif ($mark eq 'r')
1310 { $r = ' align="right"'; }
1311 elsif ($mark eq 'l')
1312 { $r = ' align="left"'; }
1313 elsif ($mark eq 'p')
1314 { $r = ' align="left"'; }
1315 return $r;
1316}
1317
Fred Drake6659c301998-03-03 22:02:19 +00001318sub setup_column_alignments{
1319 local($_) = @_;
Fred Drakef269e592001-07-17 23:05:57 +00001320 my($s1,$s2,$s3,$s4,$a5) = split(/[|]/,$_);
Fred Drakee15956b2000-04-03 04:51:13 +00001321 my $a1 = figure_column_alignment($s1);
1322 my $a2 = figure_column_alignment($s2);
1323 my $a3 = figure_column_alignment($s3);
1324 my $a4 = figure_column_alignment($s4);
Fred Drakef269e592001-07-17 23:05:57 +00001325 my $a5 = figure_column_alignment($s5);
Fred Drakee15956b2000-04-03 04:51:13 +00001326 $col_aligns[0] = "<td$a1 valign=\"baseline\">";
1327 $col_aligns[1] = "<td$a2>";
1328 $col_aligns[2] = "<td$a3>";
1329 $col_aligns[3] = "<td$a4>";
Fred Drakef269e592001-07-17 23:05:57 +00001330 $col_aligns[4] = "<td$a5>";
Fred Drake79189b51999-04-28 13:54:30 +00001331 # return the aligned header start tags
Fred Drakef269e592001-07-17 23:05:57 +00001332 return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>", "<th$a5>");
Fred Drakee15956b2000-04-03 04:51:13 +00001333}
1334
1335sub get_table_col1_fonts{
1336 my $font = $globals{'lineifont'};
1337 my ($sfont,$efont) = ('', '');
1338 if ($font) {
1339 $sfont = "<$font>";
1340 $efont = "</$font>";
1341 $efont =~ s/ .*>/>/;
1342 }
Fred Drakee463f8e2000-11-30 07:17:27 +00001343 return ($sfont, $efont);
Fred Drake6659c301998-03-03 22:02:19 +00001344}
1345
1346sub do_env_tableii{
1347 local($_) = @_;
Fred Drakef269e592001-07-17 23:05:57 +00001348 my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001349 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001350 my $h1 = next_argument();
1351 my $h2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001352 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001353 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001354 my $a1 = $col_aligns[0];
1355 my $a2 = $col_aligns[1];
1356 s/\\lineii</\\lineii[$a1|$a2]</g;
1357 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001358 . "\n <thead>"
1359 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001360 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1361 . "\n $th2<b>$h2</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001362 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001363 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001364 . "\n <tbody valign=\"baseline\">"
Fred Drake351960d2000-10-26 20:14:58 +00001365 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001366 . "\n </tbody>"
1367 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001368}
1369
Fred Drakeda72b932000-09-21 15:58:02 +00001370sub do_env_longtableii{
1371 return do_env_tableii(@_);
1372}
1373
Fred Drake6659c301998-03-03 22:02:19 +00001374sub do_cmd_lineii{
1375 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001376 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001377 my $c1 = next_argument();
1378 my $c2 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001379 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001380 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001381 $c2 = '&nbsp;' if ($c2 eq '');
1382 my($c1align,$c2align) = split('\|', $aligns);
1383 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001384 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001385 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001386 }
Fred Drakee15956b2000-04-03 04:51:13 +00001387 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1388 . " $c2align$c2</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001389 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001390}
1391
1392sub do_env_tableiii{
1393 local($_) = @_;
Fred Drakef269e592001-07-17 23:05:57 +00001394 my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001395 my $font = fix_font(next_argument());
Fred Drake08932051998-04-17 02:15:42 +00001396 my $h1 = next_argument();
1397 my $h2 = next_argument();
1398 my $h3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001399 s/[\s\n]+//;
Fred Drake08932051998-04-17 02:15:42 +00001400 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001401 my $a1 = $col_aligns[0];
1402 my $a2 = $col_aligns[1];
1403 my $a3 = $col_aligns[2];
1404 s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g;
1405 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001406 . "\n <thead>"
1407 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001408 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1409 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1410 . "\n $th3<b>$h3</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001411 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001412 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001413 . "\n <tbody valign=\"baseline\">"
Fred Drake62e43691998-08-10 19:40:44 +00001414 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001415 . "\n </tbody>"
1416 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001417}
1418
Fred Drakeda72b932000-09-21 15:58:02 +00001419sub do_env_longtableiii{
1420 return do_env_tableiii(@_);
1421}
1422
Fred Drake6659c301998-03-03 22:02:19 +00001423sub do_cmd_lineiii{
1424 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001425 my $aligns = next_optional_argument();
Fred Drake08932051998-04-17 02:15:42 +00001426 my $c1 = next_argument();
Fred Drakef269e592001-07-17 23:05:57 +00001427 my $c2 = next_argument();
Fred Drake08932051998-04-17 02:15:42 +00001428 my $c3 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001429 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001430 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001431 $c3 = '&nbsp;' if ($c3 eq '');
1432 my($c1align,$c2align,$c3align) = split('\|', $aligns);
1433 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001434 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001435 $padding = '&nbsp;';
Fred Drake58b2bfd1998-04-02 20:14:04 +00001436 }
Fred Drakee15956b2000-04-03 04:51:13 +00001437 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001438 . " $c2align$c2</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001439 . " $c3align$c3</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001440 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001441}
1442
Fred Drakea0f4c941998-07-24 22:16:04 +00001443sub do_env_tableiv{
1444 local($_) = @_;
Fred Drakef269e592001-07-17 23:05:57 +00001445 my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
Fred Drakef74e5b71999-04-28 14:58:49 +00001446 my $font = fix_font(next_argument());
Fred Drakea0f4c941998-07-24 22:16:04 +00001447 my $h1 = next_argument();
1448 my $h2 = next_argument();
1449 my $h3 = next_argument();
1450 my $h4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001451 s/[\s\n]+//;
Fred Drakea0f4c941998-07-24 22:16:04 +00001452 $globals{'lineifont'} = $font;
Fred Drakee15956b2000-04-03 04:51:13 +00001453 my $a1 = $col_aligns[0];
1454 my $a2 = $col_aligns[1];
1455 my $a3 = $col_aligns[2];
1456 my $a4 = $col_aligns[3];
1457 s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g;
1458 return '<table border align="center" style="border-collapse: collapse">'
Fred Drake351960d2000-10-26 20:14:58 +00001459 . "\n <thead>"
1460 . "\n <tr class=\"tableheader\">"
Fred Drakee15956b2000-04-03 04:51:13 +00001461 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1462 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1463 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1464 . "\n $th4<b>$h4</b>\&nbsp;</th>"
Fred Drake351960d2000-10-26 20:14:58 +00001465 . "\n </tr>"
Fred Drakef74e5b71999-04-28 14:58:49 +00001466 . "\n </thead>"
Fred Drakef1927a62001-06-20 21:29:30 +00001467 . "\n <tbody valign=\"baseline\">"
Fred Drake62e43691998-08-10 19:40:44 +00001468 . $_
Fred Drakef74e5b71999-04-28 14:58:49 +00001469 . "\n </tbody>"
1470 . "\n</table>";
Fred Drake6659c301998-03-03 22:02:19 +00001471}
1472
Fred Drakeda72b932000-09-21 15:58:02 +00001473sub do_env_longtableiv{
1474 return do_env_tableiv(@_);
1475}
1476
Fred Drakea0f4c941998-07-24 22:16:04 +00001477sub do_cmd_lineiv{
Fred Drake6659c301998-03-03 22:02:19 +00001478 local($_) = @_;
Fred Drakee15956b2000-04-03 04:51:13 +00001479 my $aligns = next_optional_argument();
Fred Drakea0f4c941998-07-24 22:16:04 +00001480 my $c1 = next_argument();
1481 my $c2 = next_argument();
1482 my $c3 = next_argument();
1483 my $c4 = next_argument();
Fred Drakef74e5b71999-04-28 14:58:49 +00001484 s/[\s\n]+//;
Fred Drakee463f8e2000-11-30 07:17:27 +00001485 my($sfont,$efont) = get_table_col1_fonts();
Fred Drakee15956b2000-04-03 04:51:13 +00001486 $c4 = '&nbsp;' if ($c4 eq '');
1487 my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns);
1488 my $padding = '';
Fred Drakee463f8e2000-11-30 07:17:27 +00001489 if ($c1align =~ /align="right"/ || $c1 eq '') {
Fred Drakee15956b2000-04-03 04:51:13 +00001490 $padding = '&nbsp;';
Fred Drakea0f4c941998-07-24 22:16:04 +00001491 }
Fred Drakee15956b2000-04-03 04:51:13 +00001492 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
Fred Drakef74e5b71999-04-28 14:58:49 +00001493 . " $c2align$c2</td>\n"
1494 . " $c3align$c3</td>\n"
Fred Drakee15956b2000-04-03 04:51:13 +00001495 . " $c4align$c4</td>"
Fred Drake62e43691998-08-10 19:40:44 +00001496 . $_;
Fred Drake6659c301998-03-03 22:02:19 +00001497}
1498
Fred Drakef269e592001-07-17 23:05:57 +00001499sub do_env_tablev{
1500 local($_) = @_;
1501 my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument());
1502 my $font = fix_font(next_argument());
1503 my $h1 = next_argument();
1504 my $h2 = next_argument();
1505 my $h3 = next_argument();
1506 my $h4 = next_argument();
1507 my $h5 = next_argument();
1508 s/[\s\n]+//;
1509 $globals{'lineifont'} = $font;
1510 my $a1 = $col_aligns[0];
1511 my $a2 = $col_aligns[1];
1512 my $a3 = $col_aligns[2];
1513 my $a4 = $col_aligns[3];
1514 my $a5 = $col_aligns[4];
1515 s/\\linev</\\linev[$a1|$a2|$a3|$a4|$a5]</g;
1516 return '<table border align="center" style="border-collapse: collapse">'
1517 . "\n <thead>"
1518 . "\n <tr class=\"tableheader\">"
1519 . "\n $th1<b>$h1</b>\&nbsp;</th>"
1520 . "\n $th2<b>$h2</b>\&nbsp;</th>"
1521 . "\n $th3<b>$h3</b>\&nbsp;</th>"
1522 . "\n $th4<b>$h4</b>\&nbsp;</th>"
1523 . "\n $th5<b>$h5</b>\&nbsp;</th>"
1524 . "\n </tr>"
1525 . "\n </thead>"
1526 . "\n <tbody valign=\"baseline\">"
1527 . $_
1528 . "\n </tbody>"
1529 . "\n</table>";
1530}
1531
1532sub do_env_longtablev{
1533 return do_env_tablev(@_);
1534}
1535
1536sub do_cmd_linev{
1537 local($_) = @_;
1538 my $aligns = next_optional_argument();
1539 my $c1 = next_argument();
1540 my $c2 = next_argument();
1541 my $c3 = next_argument();
1542 my $c4 = next_argument();
1543 my $c5 = next_argument();
1544 s/[\s\n]+//;
1545 my($sfont,$efont) = get_table_col1_fonts();
1546 $c5 = '&nbsp;' if ($c5 eq '');
1547 my($c1align,$c2align,$c3align,$c4align,$c5align) = split('\|', $aligns);
1548 my $padding = '';
1549 if ($c1align =~ /align="right"/ || $c1 eq '') {
1550 $padding = '&nbsp;';
1551 }
1552 return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n"
1553 . " $c2align$c2</td>\n"
1554 . " $c3align$c3</td>\n"
1555 . " $c4align$c4</td>\n"
1556 . " $c5align$c5</td>"
1557 . $_;
1558}
1559
Fred Drake3be20742000-08-31 06:22:54 +00001560
1561# These can be used to control the title page appearance;
1562# they need a little bit of documentation.
1563#
1564# If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the
1565# $ICONSERVER directory, or include path information (other than "./"). The
1566# default image type will be assumed if an extension is not provided.
1567#
1568# If specified, the "title page" will contain two colums: one containing the
1569# title/author/etc., and the other containing the graphic. Use the other
1570# four variables listed here to control specific details of the layout; all
1571# are optional.
1572#
1573# $TITLE_PAGE_GRAPHIC = "my-company-logo";
1574# $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%";
1575# $TITLE_PAGE_GRAPHIC_WIDTH = 150;
1576# $TITLE_PAGE_GRAPHIC_HEIGHT = 150;
1577# $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0;
1578
1579sub make_my_titlepage() {
1580 my $the_title = "";
Fred Drake6659c301998-03-03 22:02:19 +00001581 if ($t_title) {
Fred Drake90fdda51999-02-16 20:27:42 +00001582 $the_title .= "\n<h1>$t_title</h1>";
Fred Drake3be20742000-08-31 06:22:54 +00001583 }
1584 else {
1585 write_warnings("\nThis document has no title.");
1586 }
Fred Drake6659c301998-03-03 22:02:19 +00001587 if ($t_author) {
1588 if ($t_authorURL) {
Fred Drake08932051998-04-17 02:15:42 +00001589 my $href = translate_commands($t_authorURL);
Fred Drake2d1f81e1999-02-09 16:03:31 +00001590 $href = make_named_href('author', $href,
Fred Drakef1927a62001-06-20 21:29:30 +00001591 "<b><font size=\"+2\">$t_author"
1592 . '</font></b>');
Fred Drakec9a44381998-03-17 06:29:13 +00001593 $the_title .= "\n<p>$href</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001594 }
1595 else {
Fred Drakef1927a62001-06-20 21:29:30 +00001596 $the_title .= ("\n<p><b><font size=\"+2\">$t_author"
1597 . '</font></b></p>');
Fred Drake6659c301998-03-03 22:02:19 +00001598 }
Fred Drake3be20742000-08-31 06:22:54 +00001599 }
1600 else {
1601 write_warnings("\nThere is no author for this document.");
1602 }
Fred Drake6659c301998-03-03 22:02:19 +00001603 if ($t_institute) {
Fred Drake3be20742000-08-31 06:22:54 +00001604 $the_title .= "\n<p>$t_institute</p>";
1605 }
Fred Draked07868a1998-05-14 21:00:28 +00001606 if ($DEVELOPER_ADDRESS) {
Fred Drake3be20742000-08-31 06:22:54 +00001607 $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>";
1608 }
Fred Drake6659c301998-03-03 22:02:19 +00001609 if ($t_affil) {
Fred Drake3be20742000-08-31 06:22:54 +00001610 $the_title .= "\n<p><i>$t_affil</i></p>";
1611 }
Fred Drake6659c301998-03-03 22:02:19 +00001612 if ($t_date) {
Fred Drakede77bc52000-12-14 18:36:12 +00001613 $the_title .= "\n<p>";
Fred Draked04592a2000-10-25 16:15:13 +00001614 if ($PACKAGE_VERSION) {
Fred Drakef1927a62001-06-20 21:29:30 +00001615 $the_title .= ('<strong>Release '
1616 . "$PACKAGE_VERSION$RELEASE_INFO</strong><br>\n");
Fred Drake3be20742000-08-31 06:22:54 +00001617 }
Fred Drakede77bc52000-12-14 18:36:12 +00001618 $the_title .= "<strong>$t_date</strong></p>"
Fred Drake6659c301998-03-03 22:02:19 +00001619 }
1620 if ($t_address) {
Fred Drakec9a44381998-03-17 06:29:13 +00001621 $the_title .= "\n<p>$t_address</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001622 }
1623 else {
1624 $the_title .= "\n<p>";
1625 }
Fred Drake6659c301998-03-03 22:02:19 +00001626 if ($t_email) {
Fred Drakec9a44381998-03-17 06:29:13 +00001627 $the_title .= "\n<p>$t_email</p>";
Fred Drake3be20742000-08-31 06:22:54 +00001628 }
1629 return $the_title;
1630}
1631
Fred Drake3be20742000-08-31 06:22:54 +00001632sub make_my_titlegraphic() {
Fred Drake7a40c072000-10-02 14:43:38 +00001633 my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC);
Fred Drake3be20742000-08-31 06:22:54 +00001634 my $graphic = "<td class=\"titlegraphic\"";
1635 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\""
1636 if ($TITLE_PAGE_GRAPHIC_COLWIDTH);
1637 $graphic .= "><img";
1638 $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\""
1639 if ($TITLE_PAGE_GRAPHIC_WIDTH);
1640 $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\""
1641 if ($TITLE_PAGE_GRAPHIC_HEIGHT);
Fred Drake5f84c9b2000-10-03 06:05:25 +00001642 $graphic .= "\n src=\"$filename\"></td>\n";
Fred Drake3be20742000-08-31 06:22:54 +00001643 return $graphic;
1644}
1645
1646sub do_cmd_maketitle {
1647 local($_) = @_;
1648 my $the_title = "\n<div class=\"titlepage\">";
1649 if ($TITLE_PAGE_GRAPHIC) {
1650 if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) {
1651 $the_title .= ("\n<table border=\"0\" width=\"100%\">"
1652 . "<tr align=\"right\">\n<td>"
1653 . make_my_titlepage()
1654 . "</td>\n"
1655 . make_my_titlegraphic()
1656 . "</tr>\n</table>");
1657 }
1658 else {
1659 $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n"
1660 . make_my_titlegraphic()
1661 . "<td>"
1662 . make_my_titlepage()
1663 . "</td></tr>\n</table>");
1664 }
1665 }
1666 else {
1667 $the_title .= ("\n<center>"
1668 . make_my_titlepage()
1669 . "\n</center>");
1670 }
1671 $the_title .= "\n</div>";
1672 return $the_title . $_;
Fred Drake90fdda51999-02-16 20:27:42 +00001673 $the_title .= "\n</center></div>";
Fred Drake62e43691998-08-10 19:40:44 +00001674 return $the_title . $_ ;
Fred Drake6659c301998-03-03 22:02:19 +00001675}
1676
1677
Fred Drake885215c1998-05-20 21:32:09 +00001678#
Fred Drakea0f4c941998-07-24 22:16:04 +00001679# Module synopsis support
1680#
1681
1682require SynopsisTable;
1683
Fred Drakef7685d71998-07-25 03:31:46 +00001684sub get_chapter_id(){
1685 my $id = do_cmd_thechapter('');
Fred Drake45f26011998-08-04 22:07:18 +00001686 $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/;
1687 $id =~ s/\.//;
Fred Drakef7685d71998-07-25 03:31:46 +00001688 return $id;
Fred Drakea0f4c941998-07-24 22:16:04 +00001689}
1690
Fred Drake643d76d2000-09-09 06:07:37 +00001691# 'chapter' => 'SynopsisTable instance'
1692%ModuleSynopses = ();
Fred Drakef7685d71998-07-25 03:31:46 +00001693
1694sub get_synopsis_table($){
1695 my($chap) = @_;
Fred Drakef7685d71998-07-25 03:31:46 +00001696 my $key;
1697 foreach $key (keys %ModuleSynopses) {
1698 if ($key eq $chap) {
1699 return $ModuleSynopses{$chap};
1700 }
Fred Drakea0f4c941998-07-24 22:16:04 +00001701 }
Fred Drake643d76d2000-09-09 06:07:37 +00001702 my $st = SynopsisTable->new();
Fred Drakef7685d71998-07-25 03:31:46 +00001703 $ModuleSynopses{$chap} = $st;
Fred Drakea0f4c941998-07-24 22:16:04 +00001704 return $st;
1705}
1706
Fred Drake62e43691998-08-10 19:40:44 +00001707sub do_cmd_moduleauthor{
1708 local($_) = @_;
1709 next_argument();
1710 next_argument();
1711 return $_;
1712}
1713
1714sub do_cmd_sectionauthor{
1715 local($_) = @_;
1716 next_argument();
1717 next_argument();
1718 return $_;
1719}
1720
Fred Drakea0f4c941998-07-24 22:16:04 +00001721sub do_cmd_declaremodule{
1722 local($_) = @_;
1723 my $key = next_optional_argument();
1724 my $type = next_argument();
1725 my $name = next_argument();
1726 my $st = get_synopsis_table(get_chapter_id());
1727 #
1728 $key = $name unless $key;
1729 $type = 'built-in' if $type eq 'builtin';
1730 $st->declare($name, $key, $type);
1731 define_module($type, $name);
Fred Drake62e43691998-08-10 19:40:44 +00001732 return anchor_label("module-$key",$CURRENT_FILE,$_)
Fred Drakea0f4c941998-07-24 22:16:04 +00001733}
1734
1735sub do_cmd_modulesynopsis{
1736 local($_) = @_;
1737 my $st = get_synopsis_table(get_chapter_id());
Fred Drake1cc58991999-04-13 22:08:59 +00001738 $st->set_synopsis($THIS_MODULE, translate_commands(next_argument()));
Fred Drake62e43691998-08-10 19:40:44 +00001739 return $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001740}
1741
1742sub do_cmd_localmoduletable{
1743 local($_) = @_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001744 my $chap = get_chapter_id();
Fred Drake643d76d2000-09-09 06:07:37 +00001745 my $st = get_synopsis_table($chap);
1746 $st->set_file("$CURRENT_FILE");
Fred Drake557460c1999-03-02 16:05:35 +00001747 return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001748}
1749
1750sub process_all_localmoduletables{
Fred Drake643d76d2000-09-09 06:07:37 +00001751 my $key;
1752 my $st, $file;
1753 foreach $key (keys %ModuleSynopses) {
1754 $st = $ModuleSynopses{$key};
1755 $file = $st->get_file();
1756 if ($file) {
1757 process_localmoduletables_in_file($file);
1758 }
1759 else {
Fred Drake6fe46602001-06-23 03:13:30 +00001760 print "\nsynopsis table $key has no file association\n";
Fred Drake643d76d2000-09-09 06:07:37 +00001761 }
1762 }
1763}
1764
1765sub process_localmoduletables_in_file{
1766 my $file = @_[0];
1767 open(MYFILE, "<$file");
1768 local($_);
1769 sysread(MYFILE, $_, 1024*1024);
1770 close(MYFILE);
1771 # need to get contents of file in $_
Fred Drake557460c1999-03-02 16:05:35 +00001772 while (/<tex2html-localmoduletable><(\d+)>/) {
Fred Drakef7685d71998-07-25 03:31:46 +00001773 my $match = $&;
Fred Drakea0f4c941998-07-24 22:16:04 +00001774 my $chap = $1;
1775 my $st = get_synopsis_table($chap);
1776 my $data = $st->tohtml();
Fred Drakef7685d71998-07-25 03:31:46 +00001777 s/$match/$data/;
Fred Drakea0f4c941998-07-24 22:16:04 +00001778 }
Fred Drake643d76d2000-09-09 06:07:37 +00001779 open(MYFILE,">$file");
1780 print MYFILE $_;
1781 close(MYFILE);
Fred Drakea0f4c941998-07-24 22:16:04 +00001782}
Fred Drake557460c1999-03-02 16:05:35 +00001783sub process_python_state{
1784 process_all_localmoduletables();
Fred Drake77602f22001-07-06 22:43:02 +00001785 process_grammar_files();
Fred Drake557460c1999-03-02 16:05:35 +00001786}
Fred Drakea0f4c941998-07-24 22:16:04 +00001787
1788
1789#
1790# "See also:" -- references placed at the end of a \section
1791#
1792
1793sub do_env_seealso{
Fred Drakef1927a62001-06-20 21:29:30 +00001794 return ("<div class=\"seealso\">\n "
1795 . "<p class=\"heading\"><b>See Also:</b></p>\n"
1796 . @_[0]
1797 . '</div>');
Fred Drakea0f4c941998-07-24 22:16:04 +00001798}
1799
Fred Drake5ed35fd2001-11-30 18:09:54 +00001800sub do_env_seealsostar{
1801 return ("<div class=\"seealso-simple\">\n "
1802 . @_[0]
1803 . '</div>');
1804}
1805
Fred Drakea0f4c941998-07-24 22:16:04 +00001806sub do_cmd_seemodule{
1807 # Insert the right magic to jump to the module definition. This should
1808 # work most of the time, at least for repeat builds....
1809 local($_) = @_;
1810 my $key = next_optional_argument();
1811 my $module = next_argument();
1812 my $text = next_argument();
Fred Drake84bd6f31999-05-11 15:42:51 +00001813 my $period = '.';
Fred Drakea0f4c941998-07-24 22:16:04 +00001814 $key = $module
1815 unless $key;
Fred Drake84bd6f31999-05-11 15:42:51 +00001816 if ($text =~ /\.$/) {
1817 $period = '';
1818 }
Fred Drakef1927a62001-06-20 21:29:30 +00001819 return ('<dl compact class="seemodule">'
1820 . "\n <dt>Module <b><tt class=\"module\">"
1821 . "<a href=\"module-$key.html\">$module</a></tt>:</b>"
1822 . "\n <dd>$text$period\n </dl>"
1823 . $_);
Fred Drakea0f4c941998-07-24 22:16:04 +00001824}
1825
Fred Drakee0197bf2001-04-12 04:03:22 +00001826sub strip_html_markup($){
1827 my $str = @_[0];
1828 my $s = "$str";
1829 $s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g;
1830 $s =~ s/<\/[a-zA-Z0-9]+>//g;
1831 return $s;
1832}
1833
Fred Drake643d76d2000-09-09 06:07:37 +00001834sub handle_rfclike_reference{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001835 local($_, $what, $format) = @_;
Fred Drake37cc0c02000-04-26 18:05:24 +00001836 my $rfcnum = next_argument();
1837 my $title = next_argument();
1838 my $text = next_argument();
Fred Drakeafc7ce12001-01-22 17:33:24 +00001839 my $url = get_rfc_url($rfcnum, $format);
Fred Drake7a40c072000-10-02 14:43:38 +00001840 my $icon = get_link_icon($url);
Fred Drakee0197bf2001-04-12 04:03:22 +00001841 my $attrtitle = strip_html_markup($title);
Fred Drake37cc0c02000-04-26 18:05:24 +00001842 return '<dl compact class="seerfc">'
1843 . "\n <dt><a href=\"$url\""
Fred Drakee0197bf2001-04-12 04:03:22 +00001844 . "\n title=\"$attrtitle\""
Fred Drake5f84c9b2000-10-03 06:05:25 +00001845 . "\n >$what $rfcnum, <em>$title</em>$icon</a>"
Fred Drake37cc0c02000-04-26 18:05:24 +00001846 . "\n <dd>$text\n </dl>"
1847 . $_;
1848}
1849
Fred Drake643d76d2000-09-09 06:07:37 +00001850sub do_cmd_seepep{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001851 return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001852}
1853
1854sub do_cmd_seerfc{
Fred Drakeafc7ce12001-01-22 17:33:24 +00001855 return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT);
Fred Drake643d76d2000-09-09 06:07:37 +00001856}
1857
Fred Drake48449982000-09-12 17:52:33 +00001858sub do_cmd_seetitle{
1859 local($_) = @_;
1860 my $url = next_optional_argument();
1861 my $title = next_argument();
1862 my $text = next_argument();
1863 if ($url) {
Fred Drake5f84c9b2000-10-03 06:05:25 +00001864 my $icon = get_link_icon($url);
Fred Drake48449982000-09-12 17:52:33 +00001865 return '<dl compact class="seetitle">'
1866 . "\n <dt><em class=\"citetitle\"><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001867 . "\n >$title$icon</a></em>"
Fred Drake48449982000-09-12 17:52:33 +00001868 . "\n <dd>$text\n </dl>"
1869 . $_;
1870 }
1871 return '<dl compact class="seetitle">'
1872 . "\n <dt><em class=\"citetitle\""
1873 . "\n >$title</em>"
1874 . "\n <dd>$text\n </dl>"
1875 . $_;
1876}
1877
Fred Drakeef4d1112000-05-09 16:17:51 +00001878sub do_cmd_seeurl{
1879 local($_) = @_;
1880 my $url = next_argument();
1881 my $text = next_argument();
Fred Drake7a40c072000-10-02 14:43:38 +00001882 my $icon = get_link_icon($url);
Fred Drakeef4d1112000-05-09 16:17:51 +00001883 return '<dl compact class="seeurl">'
1884 . "\n <dt><a href=\"$url\""
Fred Drake7a40c072000-10-02 14:43:38 +00001885 . "\n class=\"url\">$url$icon</a>"
Fred Drakeef4d1112000-05-09 16:17:51 +00001886 . "\n <dd>$text\n </dl>"
1887 . $_;
1888}
1889
Fred Drakea0f4c941998-07-24 22:16:04 +00001890sub do_cmd_seetext{
Fred Drake79189b51999-04-28 13:54:30 +00001891 local($_) = @_;
1892 my $content = next_argument();
Fred Drakee15956b2000-04-03 04:51:13 +00001893 return '<div class="seetext"><p>' . $content . '</div>' . $_;
Fred Drakea0f4c941998-07-24 22:16:04 +00001894}
1895
1896
1897#
Fred Drake885215c1998-05-20 21:32:09 +00001898# Definition list support.
1899#
1900
1901sub do_env_definitions{
Fred Drakef1927a62001-06-20 21:29:30 +00001902 return "<dl class=\"definitions\">" . @_[0] . "</dl>\n";
Fred Drake885215c1998-05-20 21:32:09 +00001903}
1904
1905sub do_cmd_term{
1906 local($_) = @_;
Fred Drakeccc62721999-01-05 22:16:29 +00001907 my $term = next_argument();
1908 my($name,$aname,$ahref) = new_link_info();
Fred Drake885215c1998-05-20 21:32:09 +00001909 # could easily add an index entry here...
Fred Drake62e43691998-08-10 19:40:44 +00001910 return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_;
Fred Drake885215c1998-05-20 21:32:09 +00001911}
1912
1913
Fred Drake38178fd2000-09-22 17:05:04 +00001914# I don't recall exactly why this was needed, but it was very much needed.
1915# We'll see if anything breaks when I move the "code" line out -- some
1916# things broke with it in.
1917
1918#code # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001919process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_);
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001920declaremodule # [] # {} # {}
1921memberline # [] # {}
1922methodline # [] # {} # {}
1923modulesynopsis # {}
Fred Drake557460c1999-03-02 16:05:35 +00001924platform # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001925samp # {}
Fred Drake2e1ee3e1999-02-10 21:17:04 +00001926setindexsubitem # {}
Fred Drakef32834c1999-02-12 22:06:32 +00001927withsubitem # {} # {}
Fred Drake2ff880e1999-02-05 18:31:29 +00001928_RAW_ARG_DEFERRED_CMDS_
1929
1930
Fred Drake8a5e6792002-04-15 18:41:31 +00001931$alltt_start = '<div class="verbatim"><pre>';
1932$alltt_end = '</pre></div>';
Fred Drake86333602001-04-10 17:13:39 +00001933
1934sub do_env_alltt {
1935 local ($_) = @_;
1936 local($closures,$reopens,@open_block_tags);
1937
1938 # get the tag-strings for all open tags
1939 local(@keep_open_tags) = @$open_tags_R;
1940 ($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R);
1941
1942 # get the tags for text-level tags only
1943 $open_tags_R = [ @keep_open_tags ];
1944 local($local_closures, $local_reopens);
1945 ($local_closures, $local_reopens,@open_block_tags)
1946 = &preserve_open_block_tags
1947 if (@$open_tags_R);
1948
1949 $open_tags_R = [ @open_block_tags ];
1950
1951 do {
1952 local($open_tags_R) = [ @open_block_tags ];
1953 local(@save_open_tags) = ();
1954
1955 local($cnt) = ++$global{'max_id'};
1956 $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C
1957 , $_ , $O, $global{'max_id'}, "$C$O$cnt$C");
1958
1959 $_ = &translate_environments($_);
1960 $_ = &translate_commands($_) if (/\\/);
1961
1962 # preserve space-runs, using &nbsp;
1963 while (s/(\S) ( +)/$1$2;SPMnbsp;/g){};
1964 s/(<BR>) /$1;SPMnbsp;/g;
1965
1966 $_ = join('', $closures, $alltt_start, $local_reopens
1967 , $_
1968 , &balance_tags() #, $local_closures
1969 , $alltt_end, $reopens);
1970 undef $open_tags_R; undef @save_open_tags;
1971 };
1972 $open_tags_R = [ @keep_open_tags ];
1973 $_;
1974}
1975
Fred Drake57e52ef2001-06-15 21:31:57 +00001976sub do_cmd_verbatiminput{
1977 local($_) = @_;
1978 my $fname = next_argument();
1979 my $file;
1980 my $found = 0;
1981 my $texpath;
1982 # Search TEXINPUTS for the input file, the way we're supposed to:
1983 foreach $texpath (split /$envkey/, $TEXINPUTS) {
1984 $file = "$texpath$dd$fname";
1985 last if ($found = (-f $file));
1986 }
Fred Drake77602f22001-07-06 22:43:02 +00001987 my $srcname;
Fred Drake57e52ef2001-06-15 21:31:57 +00001988 my $text;
1989 if ($found) {
1990 open(MYFILE, "<$file") || die "\n$!\n";
1991 read(MYFILE, $text, 1024*1024);
1992 close(MYFILE);
Fred Drake77602f22001-07-06 22:43:02 +00001993 use File::Basename;
1994 my $srcdir, $srcext;
1995 ($srcname, $srcdir, $srcext) = fileparse($file, '\..*');
1996 open(MYFILE, ">$srcname.txt");
1997 print MYFILE $text;
1998 close(MYFILE);
Fred Drake57e52ef2001-06-15 21:31:57 +00001999 #
2000 # These rewrites convert the raw text to something that will
2001 # be properly visible as HTML and also will pass through the
2002 # vagaries of conversion through LaTeX2HTML. The order in
2003 # which the specific rewrites are performed is significant.
2004 #
2005 $text =~ s/\&/\&amp;/g;
2006 # These need to happen before the normal < and > re-writes,
2007 # since we need to avoid LaTeX2HTML's attempt to perform
2008 # ligature processing without regard to context (since it
2009 # doesn't have font information).
2010 $text =~ s/--/-&\#45;/g;
2011 $text =~ s/<</\&lt;\&\#60;/g;
2012 $text =~ s/>>/\&gt;\&\#62;/g;
2013 # Just normal re-writes...
2014 $text =~ s/</\&lt;/g;
2015 $text =~ s/>/\&gt;/g;
2016 # These last isn't needed for the HTML, but is needed to get
2017 # past LaTeX2HTML processing TeX macros. We use &#92; instead
2018 # of &sol; since many browsers don't support that.
2019 $text =~ s/\\/\&\#92;/g;
2020 }
2021 else {
2022 $text = '<b>Could not locate requested file <i>$fname</i>!</b>\n';
2023 }
Fred Drake8a5e6792002-04-15 18:41:31 +00002024 return ("<div class=\"verbatim\">\n<pre>"
Fred Drake57e52ef2001-06-15 21:31:57 +00002025 . $text
Fred Drake8a5e6792002-04-15 18:41:31 +00002026 . "</pre>\n<div class=\"footer\">\n"
Fred Drake77602f22001-07-06 22:43:02 +00002027 . "<a href=\"$srcname.txt\" type=\"text/plain\""
2028 . ">Download as text.</a>"
Fred Drake8a5e6792002-04-15 18:41:31 +00002029 . "\n</div></div>"
Fred Drake57e52ef2001-06-15 21:31:57 +00002030 . $_);
2031}
Fred Drake86333602001-04-10 17:13:39 +00002032
Fred Drake6659c301998-03-03 22:02:19 +000020331; # This must be the last line