Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1 | # 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 | |
| 9 | package main; |
| 10 | |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 11 | use File::Basename; |
| 12 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 13 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 14 | sub next_argument{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 15 | 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 Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 19 | return $param; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | sub next_optional_argument{ |
| 23 | my($param,$rx) = ('', "^\\s*(\\[([^]]*)\\])?"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 24 | s/$rx/$param=$2;''/eo; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 25 | return $param; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 28 | sub 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 Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 39 | sub 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 Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 44 | return (" <img src=\"$icon\"\n" |
| 45 | . ' border="0" class="offsitelink"' |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 46 | . ($OFF_SITE_LINK_ICON_HEIGHT |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 47 | ? " height=\"$OFF_SITE_LINK_ICON_HEIGHT\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 48 | : '') |
| 49 | . ($OFF_SITE_LINK_ICON_WIDTH |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 50 | ? " width=\"$OFF_SITE_LINK_ICON_WIDTH\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 51 | : '') |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 52 | . " alt=\"[off-site link]\"\n" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 53 | . " >"); |
| 54 | } |
| 55 | return ''; |
| 56 | } |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 57 | |
| 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 Drake | 5b73cdf | 1998-05-15 16:59:38 +0000 | [diff] [blame] | 60 | # Many possible uses of \let aren't supported or aren't supported correctly. |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 61 | # |
| 62 | sub do_cmd_let{ |
| 63 | local($_) = @_; |
| 64 | my $matched = 0; |
Fred Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 65 | s/[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 66 | 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 Drake | 7a4ad0f | 1998-05-15 13:45:54 +0000 | [diff] [blame] | 71 | 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 Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 82 | return $_; |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | |
Fred Drake | c3fd45f | 2000-06-15 22:41:48 +0000 | [diff] [blame] | 86 | # the older version of LaTeX2HTML we use doesn't support this, but we use it: |
| 87 | |
Fred Drake | f171ad9 | 2002-03-13 02:44:50 +0000 | [diff] [blame] | 88 | sub do_cmd_textasciitilde{ '~' . @_[0]; } |
Fred Drake | 056a71d | 2001-04-21 05:48:07 +0000 | [diff] [blame] | 89 | sub do_cmd_textasciicircum{ '^' . @_[0]; } |
Fred Drake | 6fe4660 | 2001-06-23 03:13:30 +0000 | [diff] [blame] | 90 | sub do_cmd_textbar{ '|' . @_[0]; } |
Fred Drake | 58fb237 | 2002-03-05 04:04:06 +0000 | [diff] [blame] | 91 | sub do_cmd_textgreater{ '>' . @_[0]; } |
| 92 | sub do_cmd_textless{ '<' . @_[0]; } |
Fred Drake | 6fe4660 | 2001-06-23 03:13:30 +0000 | [diff] [blame] | 93 | sub do_cmd_infinity{ '∞' . @_[0]; } |
| 94 | sub do_cmd_plusminus{ '±' . @_[0]; } |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 95 | sub do_cmd_menuselection{ @_[0]; } |
| 96 | sub do_cmd_sub{ ' > ' . @_[0]; } |
Fred Drake | c3fd45f | 2000-06-15 22:41:48 +0000 | [diff] [blame] | 97 | |
| 98 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 99 | # words typeset in a special way (not in HTML though) |
| 100 | |
| 101 | sub do_cmd_ABC{ 'ABC' . @_[0]; } |
| 102 | sub do_cmd_UNIX{ 'Unix'. @_[0]; } |
| 103 | sub do_cmd_ASCII{ 'ASCII' . @_[0]; } |
| 104 | sub do_cmd_POSIX{ 'POSIX' . @_[0]; } |
| 105 | sub do_cmd_C{ 'C' . @_[0]; } |
| 106 | sub do_cmd_Cpp{ 'C++' . @_[0]; } |
| 107 | sub do_cmd_EOF{ 'EOF' . @_[0]; } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 108 | sub do_cmd_NULL{ '<tt class="constant">NULL</tt>' . @_[0]; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 109 | |
| 110 | sub do_cmd_e{ '\' . @_[0]; } |
| 111 | |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 112 | $DEVELOPER_ADDRESS = ''; |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 113 | $SHORT_VERSION = ''; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 114 | $RELEASE_INFO = ''; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 115 | $PACKAGE_VERSION = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 116 | |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 117 | sub do_cmd_version{ $PACKAGE_VERSION . @_[0]; } |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 118 | sub do_cmd_shortversion{ $SHORT_VERSION . @_[0]; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 119 | sub do_cmd_release{ |
| 120 | local($_) = @_; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 121 | $PACKAGE_VERSION = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 122 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 123 | } |
| 124 | |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 125 | sub do_cmd_setreleaseinfo{ |
| 126 | local($_) = @_; |
| 127 | $RELEASE_INFO = next_argument(); |
| 128 | return $_; |
| 129 | } |
| 130 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 131 | sub do_cmd_setshortversion{ |
| 132 | local($_) = @_; |
| 133 | $SHORT_VERSION = next_argument(); |
| 134 | return $_; |
| 135 | } |
| 136 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 137 | sub do_cmd_authoraddress{ |
| 138 | local($_) = @_; |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 139 | $DEVELOPER_ADDRESS = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 140 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Fred Drake | e16f679 | 1998-05-15 04:28:37 +0000 | [diff] [blame] | 143 | #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 Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 146 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 147 | sub do_cmd_hackscore{ |
| 148 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 149 | next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 150 | return '_' . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 153 | sub use_wrappers{ |
| 154 | local($_,$before,$after) = @_; |
| 155 | my $stuff = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 156 | return $before . $stuff . $after . $_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 157 | } |
| 158 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 159 | $IN_DESC_HANDLER = 0; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 160 | sub do_cmd_optional{ |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 161 | 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 168 | } |
| 169 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 170 | # 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 174 | |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 175 | # \file and \samp are at the end of this file since they screw up fontlock. |
| 176 | |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 177 | sub do_cmd_pytype{ return @_[0]; } |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 178 | sub do_cmd_makevar{ |
| 179 | return use_wrappers(@_[0], '<span class="makevar">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 180 | sub do_cmd_code{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 181 | return use_wrappers(@_[0], '<code>', '</code>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 182 | sub do_cmd_module{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 183 | return use_wrappers(@_[0], '<tt class="module">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 184 | sub do_cmd_keyword{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 185 | return use_wrappers(@_[0], '<tt class="keyword">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 186 | sub do_cmd_exception{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 187 | return use_wrappers(@_[0], '<tt class="exception">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 188 | sub do_cmd_class{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 189 | return use_wrappers(@_[0], '<tt class="class">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 190 | sub do_cmd_function{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 191 | return use_wrappers(@_[0], '<tt class="function">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 192 | sub do_cmd_constant{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 193 | return use_wrappers(@_[0], '<tt class="constant">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 194 | sub do_cmd_member{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 195 | return use_wrappers(@_[0], '<tt class="member">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 196 | sub do_cmd_method{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 197 | return use_wrappers(@_[0], '<tt class="method">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 198 | sub do_cmd_cfunction{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 199 | return use_wrappers(@_[0], '<tt class="cfunction">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 200 | sub do_cmd_cdata{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 201 | return use_wrappers(@_[0], '<tt class="cdata">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 202 | sub do_cmd_ctype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 203 | return use_wrappers(@_[0], '<tt class="ctype">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 204 | sub do_cmd_regexp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 205 | return use_wrappers(@_[0], '<tt class="regexp">', '</tt>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 206 | sub do_cmd_character{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 207 | return use_wrappers(@_[0], '"<tt class="character">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 208 | sub do_cmd_program{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 209 | return use_wrappers(@_[0], '<b class="program">', '</b>'); } |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 210 | sub do_cmd_programopt{ |
| 211 | return use_wrappers(@_[0], '<b class="programopt">', '</b>'); } |
Fred Drake | 0cd6021 | 2000-04-11 18:46:59 +0000 | [diff] [blame] | 212 | sub do_cmd_longprogramopt{ |
| 213 | # note that the --- will be later converted to -- by LaTeX2HTML |
| 214 | return use_wrappers(@_[0], '<b class="programopt">---', '</b>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 215 | sub do_cmd_email{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 216 | return use_wrappers(@_[0], '<span class="email">', '</span>'); } |
Fred Drake | 7eac0cb | 2001-08-03 18:36:17 +0000 | [diff] [blame] | 217 | sub do_cmd_mailheader{ |
Fred Drake | 479384e | 2001-09-26 18:46:36 +0000 | [diff] [blame] | 218 | return use_wrappers(@_[0], '<span class="mailheader">', ':</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 219 | sub do_cmd_mimetype{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 220 | return use_wrappers(@_[0], '<span class="mimetype">', '</span>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 221 | sub do_cmd_var{ |
| 222 | return use_wrappers(@_[0], "<var>", "</var>"); } |
| 223 | sub do_cmd_dfn{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 224 | return use_wrappers(@_[0], '<i class="dfn">', '</i>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 225 | sub do_cmd_emph{ |
Fred Drake | 38178fd | 2000-09-22 17:05:04 +0000 | [diff] [blame] | 226 | return use_wrappers(@_[0], '<i>', '</i>'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 227 | sub do_cmd_file{ |
Fred Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 228 | return use_wrappers(@_[0], '<span class="file">', '</span>'); } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 229 | sub do_cmd_filenq{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 230 | return do_cmd_file(@_[0]); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 231 | sub do_cmd_samp{ |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 232 | return use_wrappers(@_[0], '"<tt class="samp">', '</tt>"'); } |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 233 | sub do_cmd_kbd{ |
| 234 | return use_wrappers(@_[0], '<kbd>', '</kbd>'); } |
| 235 | sub do_cmd_strong{ |
| 236 | return use_wrappers(@_[0], '<b>', '</b>'); } |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 237 | sub do_cmd_textbf{ |
| 238 | return use_wrappers(@_[0], '<b>', '</b>'); } |
| 239 | sub do_cmd_textit{ |
| 240 | return use_wrappers(@_[0], '<i>', '</i>'); } |
Fred Drake | 6ca3377 | 2001-12-14 22:50:06 +0000 | [diff] [blame] | 241 | # This can be changed/overridden for translations: |
| 242 | %NoticeNames = ('note' => 'Note:', |
| 243 | 'warning' => 'Warning:', |
| 244 | ); |
| 245 | |
Fred Drake | 92350b3 | 2001-10-09 18:01:23 +0000 | [diff] [blame] | 246 | sub do_cmd_note{ |
Fred Drake | 6ca3377 | 2001-12-14 22:50:06 +0000 | [diff] [blame] | 247 | my $label = $NoticeNames{'note'}; |
Fred Drake | 92350b3 | 2001-10-09 18:01:23 +0000 | [diff] [blame] | 248 | return use_wrappers( |
| 249 | @_[0], |
Fred Drake | 6ca3377 | 2001-12-14 22:50:06 +0000 | [diff] [blame] | 250 | "<span class=\"note\"><b class=\"label\">$label</b>\n", |
Fred Drake | 92350b3 | 2001-10-09 18:01:23 +0000 | [diff] [blame] | 251 | '</span>'); } |
| 252 | sub do_cmd_warning{ |
Fred Drake | 6ca3377 | 2001-12-14 22:50:06 +0000 | [diff] [blame] | 253 | my $label = $NoticeNames{'warning'}; |
Fred Drake | 92350b3 | 2001-10-09 18:01:23 +0000 | [diff] [blame] | 254 | return use_wrappers( |
| 255 | @_[0], |
Fred Drake | 6ca3377 | 2001-12-14 22:50:06 +0000 | [diff] [blame] | 256 | "<span class=\"warning\"><b class=\"label\">$label</b>\n", |
Fred Drake | 92350b3 | 2001-10-09 18:01:23 +0000 | [diff] [blame] | 257 | '</span>'); } |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 258 | |
Fred Drake | 6ca3377 | 2001-12-14 22:50:06 +0000 | [diff] [blame] | 259 | sub 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 Drake | 3d5a04a | 2000-08-03 17:25:44 +0000 | [diff] [blame] | 271 | sub do_cmd_moreargs{ |
| 272 | return '...' . @_[0]; } |
| 273 | sub do_cmd_unspecified{ |
| 274 | return '...' . @_[0]; } |
| 275 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 276 | |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 277 | sub 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 Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 284 | return "<tt class=\"module\"><a href=\"module-$key.html\">$module</a></tt>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 285 | . $_; |
Fred Drake | 2581704 | 1999-01-13 17:06:34 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 288 | sub do_cmd_newsgroup{ |
| 289 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 290 | my $newsgroup = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 291 | my $icon = get_link_icon("news:$newsgroup"); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 292 | my $stuff = ("<a class=\"newsgroup\" href=\"news:$newsgroup\">" |
| 293 | . "$newsgroup$icon</a>"); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 294 | return $stuff . $_; |
Fred Drake | 1a7af39 | 1998-04-01 22:44:56 +0000 | [diff] [blame] | 295 | } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 296 | |
| 297 | sub do_cmd_envvar{ |
| 298 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 299 | my $envvar = next_argument(); |
| 300 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 301 | # The <tt> here is really to keep buildindex.py from making |
| 302 | # the variable name case-insensitive. |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 303 | add_index_entry("environment variables!$envvar@<tt>$envvar</tt>", |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 304 | $ahref); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 305 | add_index_entry("$envvar (environment variable)", $ahref); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 306 | $aname =~ s/<a/<a class="envvar"/; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 307 | return "$aname$envvar</a>" . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 308 | } |
| 309 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 310 | sub do_cmd_url{ |
| 311 | # use the URL as both text and hyperlink |
| 312 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 313 | my $url = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 314 | my $icon = get_link_icon($url); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 315 | $url =~ s/~/~/g; |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 316 | return "<a class=\"url\" href=\"$url\">$url$icon</a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | sub do_cmd_manpage{ |
| 320 | # two parameters: \manpage{name}{section} |
| 321 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 322 | my $page = next_argument(); |
| 323 | my $section = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 324 | return "<span class=\"manpage\"><i>$page</i>($section)</span>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 327 | $PEP_FORMAT = "http://python.sourceforge.net/peps/pep-%04d.html"; |
| 328 | #$RFC_FORMAT = "http://www.ietf.org/rfc/rfc%04d.txt"; |
| 329 | $RFC_FORMAT = "http://www.faqs.org/rfcs/rfc%d.html"; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 330 | |
| 331 | sub get_rfc_url($$){ |
| 332 | my($rfcnum, $format) = @_; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 333 | return sprintf($format, $rfcnum); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | sub do_cmd_pep{ |
| 337 | local($_) = @_; |
| 338 | my $rfcnumber = next_argument(); |
| 339 | my $id = "rfcref-" . ++$global{'max_id'}; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 340 | my $href = get_rfc_url($rfcnumber, $PEP_FORMAT); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 341 | my $icon = get_link_icon($href); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 342 | # Save the reference |
| 343 | my $nstr = gen_index_id("Python Enhancement Proposals!PEP $rfcnumber", ''); |
| 344 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 345 | return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">PEP $rfcnumber" |
| 346 | . "$icon</a>" . $_); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 347 | } |
| 348 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 349 | sub do_cmd_rfc{ |
| 350 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 351 | my $rfcnumber = next_argument(); |
| 352 | my $id = "rfcref-" . ++$global{'max_id'}; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 353 | my $href = get_rfc_url($rfcnumber, $RFC_FORMAT); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 354 | my $icon = get_link_icon($href); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 355 | # Save the reference |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 356 | my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 357 | $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 358 | return ("<a class=\"rfc\" name=\"$id\"\nhref=\"$href\">RFC $rfcnumber" |
| 359 | . "$icon</a>" . $_); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 360 | } |
| 361 | |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 362 | sub 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 Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 369 | sub do_cmd_citetitle{ |
| 370 | local($_) = @_; |
| 371 | my $url = next_optional_argument(); |
| 372 | my $title = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 373 | my $icon = get_link_icon($url); |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 374 | my $repl = ''; |
| 375 | if ($url) { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 376 | $repl = ("<em class=\"citetitle\"><a\n" |
| 377 | . " href=\"$url\"\n" |
| 378 | . " title=\"$title\"\n" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 379 | . " >$title$icon</a></em>"); |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 380 | } |
| 381 | else { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 382 | $repl = "<em class=\"citetitle\"\n >$title</em>"; |
Fred Drake | c9f5fe0 | 1999-11-09 16:59:42 +0000 | [diff] [blame] | 383 | } |
| 384 | return $repl . $_; |
| 385 | } |
| 386 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 387 | sub do_cmd_deprecated{ |
| 388 | # two parameters: \deprecated{version}{whattodo} |
| 389 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 390 | my $release = next_argument(); |
| 391 | my $reason = next_argument(); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 392 | return ('<div class="versionnote">' |
| 393 | . "<b>Deprecated since release $release.</b>" |
| 394 | . "\n$reason</div><p>" |
| 395 | . $_); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 396 | } |
| 397 | |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 398 | sub versionnote{ |
| 399 | # one or two parameters: \versionnote[explanation]{version} |
| 400 | my $type = @_[0]; |
| 401 | local $_ = @_[1]; |
| 402 | my $explanation = next_optional_argument(); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 403 | my $release = next_argument(); |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 404 | my $text = "$type in version $release."; |
| 405 | if ($explanation) { |
| 406 | $text = "$type in version $release:\n$explanation."; |
| 407 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 408 | return "\n<span class=\"versionnote\">$text</span>\n" . $_; |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | sub do_cmd_versionadded{ |
| 412 | return versionnote('New', @_); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | sub do_cmd_versionchanged{ |
Fred Drake | c2b29d0 | 2001-04-18 03:11:04 +0000 | [diff] [blame] | 416 | return versionnote('Changed', @_); |
Fred Drake | 897d12b | 1998-07-27 20:33:17 +0000 | [diff] [blame] | 417 | } |
| 418 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 419 | # |
Fred Drake | 2cafcbb | 1999-03-25 16:57:04 +0000 | [diff] [blame] | 420 | # These function handle platform dependency tracking. |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 421 | # |
| 422 | sub do_cmd_platform{ |
| 423 | local($_) = @_; |
| 424 | my $platform = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 425 | $ModulePlatforms{"<tt class=\"module\">$THIS_MODULE</tt>"} = $platform; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 426 | $platform = "Macintosh" |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 427 | if $platform eq 'Mac'; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 428 | return "\n<p class=\"availability\">Availability: <span" |
| 429 | . "\n class=\"platform\">$platform</span>.</p>\n" . $_; |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 430 | } |
| 431 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 432 | $IGNORE_PLATFORM_ANNOTATION = ''; |
| 433 | sub do_cmd_ignorePlatformAnnotation{ |
| 434 | local($_) = @_; |
| 435 | $IGNORE_PLATFORM_ANNOTATION = next_argument(); |
| 436 | return $_; |
| 437 | } |
| 438 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 439 | |
| 440 | # index commands |
| 441 | |
| 442 | $INDEX_SUBITEM = ""; |
| 443 | |
| 444 | sub get_indexsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 445 | return $INDEX_SUBITEM ? " $INDEX_SUBITEM" : ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | sub do_cmd_setindexsubitem{ |
| 449 | local($_) = @_; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 450 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 451 | return $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 452 | } |
| 453 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 454 | sub do_cmd_withsubitem{ |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 455 | # We can't really do the right thing, because LaTeX2HTML doesn't |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 456 | # 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 Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 460 | my $oldsubitem = $INDEX_SUBITEM; |
| 461 | $INDEX_SUBITEM = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 462 | my $stuff = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 463 | my $br_id = ++$globals{'max_id'}; |
| 464 | my $marker = "$O$br_id$C"; |
Fred Drake | be6dd30 | 2001-12-11 20:49:23 +0000 | [diff] [blame] | 465 | $stuff =~ s/^\s+//; |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 466 | return |
| 467 | $stuff |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 468 | . "\\setindexsubitem$marker$oldsubitem$marker" |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 469 | . $_; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 470 | } |
| 471 | |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 472 | # This is the prologue macro which is required to start writing the |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 473 | # mod\jobname.idx file; we can just ignore it. (Defining this suppresses |
| 474 | # a warning that \makemodindex is unknown.) |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 475 | # |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 476 | sub do_cmd_makemodindex{ return @_[0]; } |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 477 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 478 | # We're in the document subdirectory when this happens! |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 479 | # |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 480 | open(IDXFILE, '>index.dat') || die "\n$!\n"; |
| 481 | open(INTLABELS, '>intlabels.pl') || die "\n$!\n"; |
Fred Drake | 166abba | 1998-04-08 23:10:54 +0000 | [diff] [blame] | 482 | print INTLABELS "%internal_labels = ();\n"; |
| 483 | print 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 Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 490 | sub write_idxfile{ |
| 491 | my ($ahref, $str) = @_; |
| 492 | print IDXFILE $ahref, $IDXFILE_FIELD_SEP, $str, "\n"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 493 | } |
| 494 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 495 | |
| 496 | sub gen_link{ |
| 497 | my($node,$target) = @_; |
| 498 | print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 499 | return "<a href=\"$node#$target\">"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 500 | } |
| 501 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 502 | sub 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 Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 507 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 510 | sub new_link_info{ |
| 511 | my $name = "l2h-" . ++$globals{'max_id'}; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 512 | my $aname = "<a name=\"$name\">"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 513 | my $ahref = gen_link($CURRENT_FILE, $name); |
| 514 | return ($name, $aname, $ahref); |
| 515 | } |
| 516 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 517 | $IndexMacroPattern = ''; |
| 518 | sub 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; |
| 538 | sub process_index_macros{ |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 539 | local($_) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 540 | my $cmdname = @_[1]; # This is what triggered us in the first place; |
| 541 | # we know it's real, so just process it. |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 542 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 543 | 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 Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 560 | if (/^[ \t\r\n]/) { |
| 561 | $_ = substr($_, 1); |
| 562 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 563 | return "$aname$anchor_invisible_mark</a>" . $_; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 564 | } |
| 565 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 566 | define_indexing_macro('index'); |
| 567 | sub idx_cmd_index{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 568 | my $str = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 569 | add_index_entry("$str", @_[0]); |
Fred Drake | 2e7edb8 | 1998-05-11 18:31:17 +0000 | [diff] [blame] | 570 | } |
| 571 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 572 | define_indexing_macro('kwindex'); |
| 573 | sub 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 | |
| 579 | define_indexing_macro('indexii'); |
| 580 | sub idx_cmd_indexii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 581 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 582 | my $str2 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 583 | add_index_entry("$str1!$str2", @_[0]); |
| 584 | add_index_entry("$str2!$str1", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 585 | } |
| 586 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 587 | define_indexing_macro('indexiii'); |
| 588 | sub idx_cmd_indexiii{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 589 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 590 | my $str2 = next_argument(); |
| 591 | my $str3 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 592 | add_index_entry("$str1!$str2 $str3", @_[0]); |
| 593 | add_index_entry("$str2!$str3, $str1", @_[0]); |
| 594 | add_index_entry("$str3!$str1 $str2", @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 595 | } |
| 596 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 597 | define_indexing_macro('indexiv'); |
| 598 | sub idx_cmd_indexiv{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 599 | my $str1 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 600 | my $str2 = next_argument(); |
| 601 | my $str3 = next_argument(); |
| 602 | my $str4 = next_argument(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 603 | 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 607 | } |
| 608 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 609 | define_indexing_macro('ttindex'); |
| 610 | sub idx_cmd_ttindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 611 | my $str = next_argument(); |
| 612 | my $entry = $str . get_indexsubitem(); |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 613 | add_index_entry($entry, @_[0]); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 614 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 615 | |
| 616 | sub my_typed_index_helper{ |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 617 | my($word,$ahref) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 618 | my $str = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 619 | add_index_entry("$str $word", $ahref); |
| 620 | add_index_entry("$word!$str", $ahref); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 621 | } |
| 622 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 623 | define_indexing_macro('stindex', 'opindex', 'exindex', 'obindex'); |
| 624 | sub idx_cmd_stindex{ my_typed_index_helper('statement', @_[0]); } |
| 625 | sub idx_cmd_opindex{ my_typed_index_helper('operator', @_[0]); } |
| 626 | sub idx_cmd_exindex{ my_typed_index_helper('exception', @_[0]); } |
| 627 | sub idx_cmd_obindex{ my_typed_index_helper('object', @_[0]); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 628 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 629 | define_indexing_macro('bifuncindex'); |
| 630 | sub idx_cmd_bifuncindex{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 631 | my $str = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 632 | add_index_entry("<tt class=\"function\">$str()</tt> (built-in function)", |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 633 | @_[0]); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 637 | sub make_mod_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 638 | my($str,$define) = @_; |
| 639 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 640 | # equivalent of add_index_entry() using $define instead of '' |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 641 | $ahref =~ s/\#[-_a-zA-Z0-9]*\"/\"/ |
| 642 | if ($define eq 'DEF'); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 643 | $str = gen_index_id($str, $define); |
| 644 | $index{$str} .= $ahref; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 645 | write_idxfile($ahref, $str); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 646 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 647 | if ($define eq 'DEF') { |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 648 | # add to the module index |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 649 | $str =~ /(<tt.*<\/tt>)/; |
| 650 | my $nstr = $1; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 651 | $Modules{$nstr} .= $ahref; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 652 | } |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 653 | return "$aname$anchor_invisible_mark2</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 654 | } |
| 655 | |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 656 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 657 | $THIS_MODULE = ''; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 658 | $THIS_CLASS = ''; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 659 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 660 | sub define_module{ |
| 661 | my($word,$name) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 662 | my $section_tag = join('', @curr_sec_id); |
Fred Drake | 3e4c614 | 1999-05-17 15:00:32 +0000 | [diff] [blame] | 663 | 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 669 | $word = "$word " if $word; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 670 | $THIS_MODULE = "$name"; |
Fred Drake | 5942b43 | 2000-10-30 06:24:56 +0000 | [diff] [blame] | 671 | $INDEX_SUBITEM = "(in module $name)"; |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 672 | print "[$name]"; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 673 | return make_mod_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 674 | "<tt class=\"module\">$name</tt> (${word}module)", 'DEF'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 675 | } |
| 676 | |
| 677 | sub my_module_index_helper{ |
| 678 | local($word, $_) = @_; |
| 679 | my $name = next_argument(); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 680 | return define_module($word, $name) . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 681 | } |
| 682 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 683 | sub do_cmd_modindex{ return my_module_index_helper('', @_); } |
| 684 | sub do_cmd_bimodindex{ return my_module_index_helper('built-in', @_); } |
| 685 | sub do_cmd_exmodindex{ return my_module_index_helper('extension', @_); } |
| 686 | sub do_cmd_stmodindex{ return my_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 687 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 688 | sub ref_module_index_helper{ |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 689 | my($word, $ahref) = @_; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 690 | my $str = next_argument(); |
| 691 | $word = "$word " if $word; |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 692 | $str = "<tt class=\"module\">$str</tt> (${word}module)"; |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 693 | # 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 Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 700 | # these should be adjusted a bit.... |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 701 | define_indexing_macro('refmodindex', 'refbimodindex', |
| 702 | 'refexmodindex', 'refstmodindex'); |
| 703 | sub idx_cmd_refmodindex{ return ref_module_index_helper('', @_); } |
| 704 | sub idx_cmd_refbimodindex{ return ref_module_index_helper('built-in', @_); } |
| 705 | sub idx_cmd_refexmodindex{ return ref_module_index_helper('extension', @_); } |
| 706 | sub idx_cmd_refstmodindex{ return ref_module_index_helper('standard', @_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 707 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 708 | sub do_cmd_nodename{ return do_cmd_label(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 709 | |
| 710 | sub init_myformat{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 711 | $anchor_invisible_mark = ' '; |
| 712 | $anchor_invisible_mark2 = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 713 | $anchor_mark = ''; |
| 714 | $icons{'anchor_mark'} = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 715 | } |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 716 | init_myformat(); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 717 | |
Fred Drake | ab03215 | 1999-05-13 18:36:54 +0000 | [diff] [blame] | 718 | # Create an index entry, but include the string in the target anchor |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 719 | # instead of the dummy filler. |
| 720 | # |
| 721 | sub make_str_index_entry{ |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 722 | my($str) = @_; |
| 723 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 724 | add_index_entry($str, $ahref); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 725 | return "$aname$str</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 726 | } |
| 727 | |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 728 | |
| 729 | %TokenToTargetMapping = (); |
| 730 | %DefinedGrammars = (); |
| 731 | %BackpatchGrammarFiles = (); |
| 732 | |
| 733 | sub 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 Drake | 16bb419 | 2001-08-20 21:36:38 +0000 | [diff] [blame] | 751 | sub do_cmd_grammartoken{ |
| 752 | return do_cmd_token(@_); |
| 753 | } |
| 754 | |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 755 | sub 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 Drake | e27f868 | 2001-12-14 16:54:53 +0000 | [diff] [blame] | 766 | . "<table cellpadding=\"2\">\n" |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 767 | . 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 | |
| 778 | sub 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 Drake | e27f868 | 2001-12-14 16:54:53 +0000 | [diff] [blame] | 785 | return ("<tr valign=\"baseline\">\n" |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 786 | . " <td><code>$token</code></td>\n" |
| 787 | . " <td> ::= </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 Drake | e27f868 | 2001-12-14 16:54:53 +0000 | [diff] [blame] | 801 | return ("<tr valign=\"baseline\">\n" |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 802 | . " <td><code><a name=\"tok-$token\">$token</a></code></td>\n" |
| 803 | . " <td> ::= </td>\n" |
| 804 | . " <td><code>" |
| 805 | . translate_commands($defn) |
| 806 | . "</code></td></tr>" |
| 807 | . $_); |
| 808 | } |
| 809 | |
Fred Drake | 5381588 | 2002-03-15 23:21:37 +0000 | [diff] [blame^] | 810 | sub do_cmd_productioncont{ |
| 811 | local($_) = @_; |
| 812 | my $defn = next_argument(); |
| 813 | return ("<tr valign=\"baseline\">\n" |
| 814 | . " <td> </td>\n" |
| 815 | . " <td> </td>\n" |
| 816 | . " <td><code>" |
| 817 | . translate_commands($defn) |
| 818 | . "</code></td></tr>" |
| 819 | . $_); |
| 820 | } |
| 821 | |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 822 | sub 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 | |
| 860 | sub strip_grammar_markup{ |
| 861 | local($_) = @_; |
Fred Drake | 5381588 | 2002-03-15 23:21:37 +0000 | [diff] [blame^] | 862 | s/\\productioncont/ /g; |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 863 | 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 Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 874 | $REFCOUNTS_LOADED = 0; |
| 875 | |
| 876 | sub load_refcounts{ |
| 877 | $REFCOUNTS_LOADED = 1; |
| 878 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 879 | 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 Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 891 | if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1|null):(.*)$/) { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 892 | my($func, $param, $count, $comment) = ($1, $2, $3, $4); |
| 893 | #print "\n$func($param) --> $count"; |
| 894 | $REFCOUNTS{"$func:$param"} = $count; |
| 895 | } |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | sub get_refcount{ |
| 900 | my ($func, $param) = @_; |
| 901 | load_refcounts() |
| 902 | unless $REFCOUNTS_LOADED; |
| 903 | return $REFCOUNTS{"$func:$param"}; |
| 904 | } |
| 905 | |
Fred Drake | af07b2c | 2001-10-26 03:09:27 +0000 | [diff] [blame] | 906 | |
| 907 | $TLSTART = '<span class="typelabel">'; |
| 908 | $TLEND = '</span>'; |
| 909 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 910 | sub do_env_cfuncdesc{ |
| 911 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 912 | my $return_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 913 | my $function_name = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 914 | my $arg_list = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 915 | my $idx = make_str_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 916 | "<tt class=\"cfunction\">$function_name()</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 917 | $idx =~ s/ \(.*\)//; |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 918 | $idx =~ s/\(\)//; # ???? - why both of these? |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 919 | my $result_rc = get_refcount($function_name, ''); |
| 920 | my $rcinfo = ''; |
| 921 | if ($result_rc eq '+1') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 922 | $rcinfo = 'New reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 923 | } |
| 924 | elsif ($result_rc eq '0') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 925 | $rcinfo = 'Borrowed reference'; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 926 | } |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 927 | elsif ($result_rc eq 'null') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 928 | $rcinfo = 'Always <tt class="constant">NULL</tt>'; |
Fred Drake | c2578c5 | 2000-04-10 18:26:45 +0000 | [diff] [blame] | 929 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 930 | if ($rcinfo ne '') { |
Fred Drake | 241551c | 2000-08-11 20:04:19 +0000 | [diff] [blame] | 931 | $rcinfo = ( "\n<div class=\"refcount-info\">" |
| 932 | . "\n <span class=\"label\">Return value:</span>" |
| 933 | . "\n <span class=\"value\">$rcinfo.</span>" |
| 934 | . "\n</div>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 935 | } |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 936 | return "<dl><dt>$return_type <b>$idx</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 937 | . $rcinfo |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 938 | . $_ |
| 939 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 940 | } |
| 941 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 942 | sub do_env_csimplemacrodesc{ |
| 943 | local($_) = @_; |
| 944 | my $name = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 945 | my $idx = make_str_index_entry("<tt class=\"macro\">$name</tt>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 946 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 947 | . $_ |
| 948 | . '</dl>' |
| 949 | } |
| 950 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 951 | sub do_env_ctypedesc{ |
| 952 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 953 | my $index_name = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 954 | my $type_name = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 955 | $index_name = $type_name |
| 956 | unless $index_name; |
| 957 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 958 | add_index_entry("<tt class=\"ctype\">$index_name</tt> (C type)", $ahref); |
| 959 | return "<dl><dt><b><tt class=\"ctype\">$aname$type_name</a></tt></b>\n<dd>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 960 | . $_ |
| 961 | . '</dl>' |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | sub do_env_cvardesc{ |
| 965 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 966 | my $var_type = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 967 | my $var_name = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 968 | my $idx = make_str_index_entry("<tt class=\"cdata\">$var_name</tt>" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 969 | . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 970 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 971 | return "<dl><dt>$var_type <b>$idx</b>\n" |
| 972 | . '<dd>' |
| 973 | . $_ |
| 974 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 975 | } |
| 976 | |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 977 | sub convert_args($){ |
| 978 | local($IN_DESC_HANDLER) = 1; |
| 979 | local($_) = @_; |
| 980 | return translate_commands($_); |
| 981 | } |
| 982 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 983 | sub do_env_funcdesc{ |
| 984 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 985 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 986 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 987 | my $idx = make_str_index_entry("<tt class=\"function\">$function_name()" |
| 988 | . '</tt>' |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 989 | . get_indexsubitem()); |
| 990 | $idx =~ s/ \(.*\)//; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 991 | $idx =~ s/\(\)<\/tt>/<\/tt>/; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 992 | return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | sub do_env_funcdescni{ |
| 996 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 997 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 998 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 999 | return "<dl><dt><b><tt class=\"function\">$function_name</tt></b>" |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1000 | . "(<var>$arg_list</var>)\n" |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1001 | . '<dd>' |
| 1002 | . $_ |
| 1003 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1004 | } |
| 1005 | |
| 1006 | sub do_cmd_funcline{ |
| 1007 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1008 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1009 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1010 | my $prefix = "<tt class=\"function\">$function_name()</tt>"; |
Fred Drake | ca675e4 | 1999-04-21 15:58:58 +0000 | [diff] [blame] | 1011 | my $idx = make_str_index_entry($prefix . get_indexsubitem()); |
| 1012 | $prefix =~ s/\(\)//; |
| 1013 | |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1014 | return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1015 | } |
| 1016 | |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 1017 | sub do_cmd_funclineni{ |
| 1018 | local($_) = @_; |
| 1019 | my $function_name = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1020 | my $arg_list = convert_args(next_argument()); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1021 | my $prefix = "<tt class=\"function\">$function_name</tt>"; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 1022 | |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1023 | return "<dt><b>$prefix</b>(<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 6b3fb78 | 1999-07-12 16:50:09 +0000 | [diff] [blame] | 1024 | } |
| 1025 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1026 | # Change this flag to index the opcode entries. I don't think it's very |
| 1027 | # useful to index them, since they're only presented to describe the dis |
| 1028 | # module. |
| 1029 | # |
| 1030 | $INDEX_OPCODES = 0; |
| 1031 | |
| 1032 | sub do_env_opcodedesc{ |
| 1033 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1034 | my $opcode_name = next_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1035 | my $arg_list = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1036 | my $idx; |
| 1037 | if ($INDEX_OPCODES) { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1038 | $idx = make_str_index_entry("<tt class=\"opcode\">$opcode_name</tt>" |
| 1039 | . ' (byte code instruction)'); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1040 | $idx =~ s/ \(byte code instruction\)//; |
| 1041 | } |
| 1042 | else { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1043 | $idx = "<tt class=\"opcode\">$opcode_name</tt>"; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1044 | } |
| 1045 | my $stuff = "<dl><dt><b>$idx</b>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1046 | if ($arg_list) { |
| 1047 | $stuff .= " <var>$arg_list</var>"; |
| 1048 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1049 | return $stuff . "\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1050 | } |
| 1051 | |
| 1052 | sub do_env_datadesc{ |
| 1053 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1054 | my $dataname = next_argument(); |
| 1055 | my $idx = make_str_index_entry("<tt>$dataname</tt>" . get_indexsubitem()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1056 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1057 | return "<dl><dt><b>$idx</b>\n<dd>" |
| 1058 | . $_ |
| 1059 | . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | sub do_env_datadescni{ |
| 1063 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1064 | my $idx = next_argument(); |
| 1065 | if (! $STRING_INDEX_TT) { |
| 1066 | $idx = "<tt>$idx</tt>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1067 | } |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1068 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1069 | } |
| 1070 | |
| 1071 | sub do_cmd_dataline{ |
| 1072 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1073 | my $data_name = next_argument(); |
| 1074 | my $idx = make_str_index_entry("<tt>$data_name</tt>" . get_indexsubitem()); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1075 | $idx =~ s/ \(.*\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1076 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1077 | } |
| 1078 | |
Fred Drake | adb272c | 2000-04-10 17:47:14 +0000 | [diff] [blame] | 1079 | sub do_cmd_datalineni{ |
| 1080 | local($_) = @_; |
| 1081 | my $data_name = next_argument(); |
| 1082 | return "<dt><b><tt>$data_name</tt></b><dd>" . $_; |
| 1083 | } |
| 1084 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1085 | sub do_env_excdesc{ |
| 1086 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1087 | my $excname = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1088 | my $idx = make_str_index_entry("<tt class=\"exception\">$excname</tt>"); |
Fred Drake | af07b2c | 2001-10-26 03:09:27 +0000 | [diff] [blame] | 1089 | return ("<dl><dt><b>${TLSTART}exception$TLEND $idx</b>" |
| 1090 | . "\n<dd>" |
| 1091 | . $_ |
| 1092 | . '</dl>'); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1093 | } |
| 1094 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1095 | sub do_env_fulllineitems{ return do_env_itemize(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1096 | |
| 1097 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1098 | sub handle_classlike_descriptor{ |
| 1099 | local($_, $what) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1100 | $THIS_CLASS = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1101 | my $arg_list = convert_args(next_argument()); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1102 | $idx = make_str_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1103 | "<tt class=\"$what\">$THIS_CLASS</tt> ($what in $THIS_MODULE)" ); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1104 | $idx =~ s/ \(.*\)//; |
Fred Drake | af07b2c | 2001-10-26 03:09:27 +0000 | [diff] [blame] | 1105 | return ("<dl><dt><b>$TLSTART$what$TLEND $idx</b>" |
| 1106 | . "(<var>$arg_list</var>)\n<dd>" |
Fred Drake | ab357ec | 2001-03-02 18:57:05 +0000 | [diff] [blame] | 1107 | . $_ |
| 1108 | . '</dl>'); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1109 | } |
| 1110 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1111 | sub do_env_classdesc{ |
| 1112 | return handle_classlike_descriptor(@_[0], "class"); |
| 1113 | } |
| 1114 | |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 1115 | sub do_env_classdescstar{ |
| 1116 | local($_) = @_; |
| 1117 | $THIS_CLASS = next_argument(); |
| 1118 | $idx = make_str_index_entry( |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1119 | "<tt class=\"class\">$THIS_CLASS</tt> (class in $THIS_MODULE)"); |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 1120 | $idx =~ s/ \(.*\)//; |
Fred Drake | af07b2c | 2001-10-26 03:09:27 +0000 | [diff] [blame] | 1121 | return ("<dl><dt><b>${TLSTART}class$TLEND $idx</b>\n<dd>" |
Fred Drake | 06a01e8 | 2001-05-11 01:00:30 +0000 | [diff] [blame] | 1122 | . $_ |
| 1123 | . '</dl>'); |
| 1124 | } |
| 1125 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1126 | sub do_env_excclassdesc{ |
| 1127 | return handle_classlike_descriptor(@_[0], "exception"); |
| 1128 | } |
| 1129 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1130 | |
| 1131 | sub do_env_methoddesc{ |
| 1132 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1133 | my $class_name = next_optional_argument(); |
| 1134 | $class_name = $THIS_CLASS |
| 1135 | unless $class_name; |
Fred Drake | 5a0ca4e | 1999-01-12 04:16:51 +0000 | [diff] [blame] | 1136 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1137 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1138 | my $extra = ''; |
| 1139 | if ($class_name) { |
| 1140 | $extra = " ($class_name method)"; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1141 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1142 | my $idx = make_str_index_entry( |
| 1143 | "<tt class=\"method\">$method()</tt>$extra"); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1144 | $idx =~ s/ \(.*\)//; |
| 1145 | $idx =~ s/\(\)//; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1146 | return "<dl><dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1147 | } |
| 1148 | |
| 1149 | |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1150 | sub do_cmd_methodline{ |
| 1151 | local($_) = @_; |
| 1152 | my $class_name = next_optional_argument(); |
| 1153 | $class_name = $THIS_CLASS |
| 1154 | unless $class_name; |
| 1155 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1156 | my $arg_list = convert_args(next_argument()); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1157 | my $extra = ''; |
| 1158 | if ($class_name) { |
| 1159 | $extra = " ($class_name method)"; |
| 1160 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1161 | my $idx = make_str_index_entry( |
| 1162 | "<tt class=\"method\">$method()</tt>$extra"); |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1163 | $idx =~ s/ \(.*\)//; |
| 1164 | $idx =~ s/\(\)//; |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1165 | return "<dt><b>$idx</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | 7d45f6d | 1999-01-05 14:39:27 +0000 | [diff] [blame] | 1166 | . $_; |
| 1167 | } |
| 1168 | |
| 1169 | |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 1170 | sub do_cmd_methodlineni{ |
| 1171 | local($_) = @_; |
| 1172 | next_optional_argument(); |
| 1173 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1174 | my $arg_list = convert_args(next_argument()); |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1175 | return "<dt><b>$method</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | d64a40d | 1998-09-10 18:59:13 +0000 | [diff] [blame] | 1176 | . $_; |
| 1177 | } |
| 1178 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1179 | sub do_env_methoddescni{ |
| 1180 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1181 | next_optional_argument(); |
| 1182 | my $method = next_argument(); |
Fred Drake | 3cdb89d | 2000-09-14 20:17:23 +0000 | [diff] [blame] | 1183 | my $arg_list = convert_args(next_argument()); |
Fred Drake | c612a14 | 2001-03-29 18:24:08 +0000 | [diff] [blame] | 1184 | return "<dl><dt><b>$method</b>(<var>$arg_list</var>)\n<dd>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1185 | . $_ |
| 1186 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1187 | } |
| 1188 | |
| 1189 | |
| 1190 | sub do_env_memberdesc{ |
| 1191 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1192 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1193 | my $member = next_argument(); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1194 | $class = $THIS_CLASS |
| 1195 | unless $class; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1196 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 1197 | $extra = " ($class attribute)" |
| 1198 | if ($class ne ''); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1199 | my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra"); |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1200 | $idx =~ s/ \(.*\)//; |
| 1201 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1202 | return "<dl><dt><b>$idx</b>\n<dd>" . $_ . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1206 | sub do_cmd_memberline{ |
| 1207 | local($_) = @_; |
| 1208 | my $class = next_optional_argument(); |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1209 | my $member = next_argument(); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1210 | $class = $THIS_CLASS |
| 1211 | unless $class; |
| 1212 | my $extra = ''; |
Fred Drake | 085b812 | 1999-04-21 14:00:29 +0000 | [diff] [blame] | 1213 | $extra = " ($class attribute)" |
| 1214 | if ($class ne ''); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1215 | my $idx = make_str_index_entry("<tt class=\"member\">$member</tt>$extra"); |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1216 | $idx =~ s/ \(.*\)//; |
| 1217 | $idx =~ s/\(\)//; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1218 | return "<dt><b>$idx</b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1219 | } |
| 1220 | |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1221 | |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1222 | sub do_env_memberdescni{ |
| 1223 | local($_) = @_; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1224 | next_optional_argument(); |
| 1225 | my $member = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1226 | return "<dl><dt><b><tt class=\"member\">$member</tt></b>\n<dd>" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1227 | . $_ |
| 1228 | . '</dl>'; |
Fred Drake | 42b31a5 | 1998-03-27 05:16:10 +0000 | [diff] [blame] | 1229 | } |
| 1230 | |
| 1231 | |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1232 | sub do_cmd_memberlineni{ |
| 1233 | local($_) = @_; |
| 1234 | next_optional_argument(); |
| 1235 | my $member = next_argument(); |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1236 | return "<dt><b><tt class=\"member\">$member</tt></b><dd>" . $_; |
Fred Drake | 5ccf330 | 1998-04-17 20:04:09 +0000 | [diff] [blame] | 1237 | } |
| 1238 | |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1239 | |
| 1240 | @col_aligns = ('<td>', '<td>', '<td>', '<td>', '<td>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1241 | |
Fred Drake | cb19976 | 2001-08-16 21:56:24 +0000 | [diff] [blame] | 1242 | %FontConversions = ('cdata' => 'tt class="cdata"', |
| 1243 | 'character' => 'tt class="character"', |
| 1244 | 'class' => 'tt class="class"', |
| 1245 | 'command' => 'code', |
| 1246 | 'constant' => 'tt class="constant"', |
| 1247 | 'exception' => 'tt class="exception"', |
| 1248 | 'file' => 'tt class="file"', |
| 1249 | 'filenq' => 'tt class="file"', |
| 1250 | 'kbd' => 'kbd', |
| 1251 | 'member' => 'tt class="member"', |
| 1252 | 'programopt' => 'b', |
| 1253 | 'textrm' => '', |
| 1254 | ); |
| 1255 | |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1256 | sub fix_font{ |
| 1257 | # do a little magic on a font name to get the right behavior in the first |
| 1258 | # column of the output table |
| 1259 | my $font = @_[0]; |
Fred Drake | cb19976 | 2001-08-16 21:56:24 +0000 | [diff] [blame] | 1260 | if (defined $FontConversions{$font}) { |
| 1261 | $font = $FontConversions{$font}; |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1262 | } |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1263 | return $font; |
| 1264 | } |
| 1265 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1266 | sub figure_column_alignment{ |
| 1267 | my $a = @_[0]; |
| 1268 | my $mark = substr($a, 0, 1); |
| 1269 | my $r = ''; |
| 1270 | if ($mark eq 'c') |
| 1271 | { $r = ' align="center"'; } |
| 1272 | elsif ($mark eq 'r') |
| 1273 | { $r = ' align="right"'; } |
| 1274 | elsif ($mark eq 'l') |
| 1275 | { $r = ' align="left"'; } |
| 1276 | elsif ($mark eq 'p') |
| 1277 | { $r = ' align="left"'; } |
| 1278 | return $r; |
| 1279 | } |
| 1280 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1281 | sub setup_column_alignments{ |
| 1282 | local($_) = @_; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1283 | my($s1,$s2,$s3,$s4,$a5) = split(/[|]/,$_); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1284 | my $a1 = figure_column_alignment($s1); |
| 1285 | my $a2 = figure_column_alignment($s2); |
| 1286 | my $a3 = figure_column_alignment($s3); |
| 1287 | my $a4 = figure_column_alignment($s4); |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1288 | my $a5 = figure_column_alignment($s5); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1289 | $col_aligns[0] = "<td$a1 valign=\"baseline\">"; |
| 1290 | $col_aligns[1] = "<td$a2>"; |
| 1291 | $col_aligns[2] = "<td$a3>"; |
| 1292 | $col_aligns[3] = "<td$a4>"; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1293 | $col_aligns[4] = "<td$a5>"; |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1294 | # return the aligned header start tags |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1295 | return ("<th$a1>", "<th$a2>", "<th$a3>", "<th$a4>", "<th$a5>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1296 | } |
| 1297 | |
| 1298 | sub get_table_col1_fonts{ |
| 1299 | my $font = $globals{'lineifont'}; |
| 1300 | my ($sfont,$efont) = ('', ''); |
| 1301 | if ($font) { |
| 1302 | $sfont = "<$font>"; |
| 1303 | $efont = "</$font>"; |
| 1304 | $efont =~ s/ .*>/>/; |
| 1305 | } |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1306 | return ($sfont, $efont); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1307 | } |
| 1308 | |
| 1309 | sub do_env_tableii{ |
| 1310 | local($_) = @_; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1311 | my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1312 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1313 | my $h1 = next_argument(); |
| 1314 | my $h2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1315 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1316 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1317 | my $a1 = $col_aligns[0]; |
| 1318 | my $a2 = $col_aligns[1]; |
| 1319 | s/\\lineii</\\lineii[$a1|$a2]</g; |
| 1320 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1321 | . "\n <thead>" |
| 1322 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1323 | . "\n $th1<b>$h1</b>\ </th>" |
| 1324 | . "\n $th2<b>$h2</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1325 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1326 | . "\n </thead>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1327 | . "\n <tbody valign=\"baseline\">" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1328 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1329 | . "\n </tbody>" |
| 1330 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1331 | } |
| 1332 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1333 | sub do_env_longtableii{ |
| 1334 | return do_env_tableii(@_); |
| 1335 | } |
| 1336 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1337 | sub do_cmd_lineii{ |
| 1338 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1339 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1340 | my $c1 = next_argument(); |
| 1341 | my $c2 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1342 | s/[\s\n]+//; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1343 | my($sfont,$efont) = get_table_col1_fonts(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1344 | $c2 = ' ' if ($c2 eq ''); |
| 1345 | my($c1align,$c2align) = split('\|', $aligns); |
| 1346 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1347 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1348 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1349 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1350 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
| 1351 | . " $c2align$c2</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1352 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1353 | } |
| 1354 | |
| 1355 | sub do_env_tableiii{ |
| 1356 | local($_) = @_; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1357 | my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1358 | my $font = fix_font(next_argument()); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1359 | my $h1 = next_argument(); |
| 1360 | my $h2 = next_argument(); |
| 1361 | my $h3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1362 | s/[\s\n]+//; |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1363 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1364 | my $a1 = $col_aligns[0]; |
| 1365 | my $a2 = $col_aligns[1]; |
| 1366 | my $a3 = $col_aligns[2]; |
| 1367 | s/\\lineiii</\\lineiii[$a1|$a2|$a3]</g; |
| 1368 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1369 | . "\n <thead>" |
| 1370 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1371 | . "\n $th1<b>$h1</b>\ </th>" |
| 1372 | . "\n $th2<b>$h2</b>\ </th>" |
| 1373 | . "\n $th3<b>$h3</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1374 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1375 | . "\n </thead>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1376 | . "\n <tbody valign=\"baseline\">" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1377 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1378 | . "\n </tbody>" |
| 1379 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1380 | } |
| 1381 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1382 | sub do_env_longtableiii{ |
| 1383 | return do_env_tableiii(@_); |
| 1384 | } |
| 1385 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1386 | sub do_cmd_lineiii{ |
| 1387 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1388 | my $aligns = next_optional_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1389 | my $c1 = next_argument(); |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1390 | my $c2 = next_argument(); |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1391 | my $c3 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1392 | s/[\s\n]+//; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1393 | my($sfont,$efont) = get_table_col1_fonts(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1394 | $c3 = ' ' if ($c3 eq ''); |
| 1395 | my($c1align,$c2align,$c3align) = split('\|', $aligns); |
| 1396 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1397 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1398 | $padding = ' '; |
Fred Drake | 58b2bfd | 1998-04-02 20:14:04 +0000 | [diff] [blame] | 1399 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1400 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1401 | . " $c2align$c2</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1402 | . " $c3align$c3</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1403 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1404 | } |
| 1405 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1406 | sub do_env_tableiv{ |
| 1407 | local($_) = @_; |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1408 | my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument()); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1409 | my $font = fix_font(next_argument()); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1410 | my $h1 = next_argument(); |
| 1411 | my $h2 = next_argument(); |
| 1412 | my $h3 = next_argument(); |
| 1413 | my $h4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1414 | s/[\s\n]+//; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1415 | $globals{'lineifont'} = $font; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1416 | my $a1 = $col_aligns[0]; |
| 1417 | my $a2 = $col_aligns[1]; |
| 1418 | my $a3 = $col_aligns[2]; |
| 1419 | my $a4 = $col_aligns[3]; |
| 1420 | s/\\lineiv</\\lineiv[$a1|$a2|$a3|$a4]</g; |
| 1421 | return '<table border align="center" style="border-collapse: collapse">' |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1422 | . "\n <thead>" |
| 1423 | . "\n <tr class=\"tableheader\">" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1424 | . "\n $th1<b>$h1</b>\ </th>" |
| 1425 | . "\n $th2<b>$h2</b>\ </th>" |
| 1426 | . "\n $th3<b>$h3</b>\ </th>" |
| 1427 | . "\n $th4<b>$h4</b>\ </th>" |
Fred Drake | 351960d | 2000-10-26 20:14:58 +0000 | [diff] [blame] | 1428 | . "\n </tr>" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1429 | . "\n </thead>" |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1430 | . "\n <tbody valign=\"baseline\">" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1431 | . $_ |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1432 | . "\n </tbody>" |
| 1433 | . "\n</table>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1434 | } |
| 1435 | |
Fred Drake | da72b93 | 2000-09-21 15:58:02 +0000 | [diff] [blame] | 1436 | sub do_env_longtableiv{ |
| 1437 | return do_env_tableiv(@_); |
| 1438 | } |
| 1439 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1440 | sub do_cmd_lineiv{ |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1441 | local($_) = @_; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1442 | my $aligns = next_optional_argument(); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1443 | my $c1 = next_argument(); |
| 1444 | my $c2 = next_argument(); |
| 1445 | my $c3 = next_argument(); |
| 1446 | my $c4 = next_argument(); |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1447 | s/[\s\n]+//; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1448 | my($sfont,$efont) = get_table_col1_fonts(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1449 | $c4 = ' ' if ($c4 eq ''); |
| 1450 | my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns); |
| 1451 | my $padding = ''; |
Fred Drake | e463f8e | 2000-11-30 07:17:27 +0000 | [diff] [blame] | 1452 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1453 | $padding = ' '; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1454 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1455 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
Fred Drake | f74e5b7 | 1999-04-28 14:58:49 +0000 | [diff] [blame] | 1456 | . " $c2align$c2</td>\n" |
| 1457 | . " $c3align$c3</td>\n" |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1458 | . " $c4align$c4</td>" |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1459 | . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1460 | } |
| 1461 | |
Fred Drake | f269e59 | 2001-07-17 23:05:57 +0000 | [diff] [blame] | 1462 | sub do_env_tablev{ |
| 1463 | local($_) = @_; |
| 1464 | my($th1,$th2,$th3,$th4,$th5) = setup_column_alignments(next_argument()); |
| 1465 | my $font = fix_font(next_argument()); |
| 1466 | my $h1 = next_argument(); |
| 1467 | my $h2 = next_argument(); |
| 1468 | my $h3 = next_argument(); |
| 1469 | my $h4 = next_argument(); |
| 1470 | my $h5 = next_argument(); |
| 1471 | s/[\s\n]+//; |
| 1472 | $globals{'lineifont'} = $font; |
| 1473 | my $a1 = $col_aligns[0]; |
| 1474 | my $a2 = $col_aligns[1]; |
| 1475 | my $a3 = $col_aligns[2]; |
| 1476 | my $a4 = $col_aligns[3]; |
| 1477 | my $a5 = $col_aligns[4]; |
| 1478 | s/\\linev</\\linev[$a1|$a2|$a3|$a4|$a5]</g; |
| 1479 | return '<table border align="center" style="border-collapse: collapse">' |
| 1480 | . "\n <thead>" |
| 1481 | . "\n <tr class=\"tableheader\">" |
| 1482 | . "\n $th1<b>$h1</b>\ </th>" |
| 1483 | . "\n $th2<b>$h2</b>\ </th>" |
| 1484 | . "\n $th3<b>$h3</b>\ </th>" |
| 1485 | . "\n $th4<b>$h4</b>\ </th>" |
| 1486 | . "\n $th5<b>$h5</b>\ </th>" |
| 1487 | . "\n </tr>" |
| 1488 | . "\n </thead>" |
| 1489 | . "\n <tbody valign=\"baseline\">" |
| 1490 | . $_ |
| 1491 | . "\n </tbody>" |
| 1492 | . "\n</table>"; |
| 1493 | } |
| 1494 | |
| 1495 | sub do_env_longtablev{ |
| 1496 | return do_env_tablev(@_); |
| 1497 | } |
| 1498 | |
| 1499 | sub do_cmd_linev{ |
| 1500 | local($_) = @_; |
| 1501 | my $aligns = next_optional_argument(); |
| 1502 | my $c1 = next_argument(); |
| 1503 | my $c2 = next_argument(); |
| 1504 | my $c3 = next_argument(); |
| 1505 | my $c4 = next_argument(); |
| 1506 | my $c5 = next_argument(); |
| 1507 | s/[\s\n]+//; |
| 1508 | my($sfont,$efont) = get_table_col1_fonts(); |
| 1509 | $c5 = ' ' if ($c5 eq ''); |
| 1510 | my($c1align,$c2align,$c3align,$c4align,$c5align) = split('\|', $aligns); |
| 1511 | my $padding = ''; |
| 1512 | if ($c1align =~ /align="right"/ || $c1 eq '') { |
| 1513 | $padding = ' '; |
| 1514 | } |
| 1515 | return "\n <tr>$c1align$sfont$c1$efont$padding</td>\n" |
| 1516 | . " $c2align$c2</td>\n" |
| 1517 | . " $c3align$c3</td>\n" |
| 1518 | . " $c4align$c4</td>\n" |
| 1519 | . " $c5align$c5</td>" |
| 1520 | . $_; |
| 1521 | } |
| 1522 | |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1523 | |
| 1524 | # These can be used to control the title page appearance; |
| 1525 | # they need a little bit of documentation. |
| 1526 | # |
| 1527 | # If $TITLE_PAGE_GRAPHIC is set, it should be the name of a file in the |
| 1528 | # $ICONSERVER directory, or include path information (other than "./"). The |
| 1529 | # default image type will be assumed if an extension is not provided. |
| 1530 | # |
| 1531 | # If specified, the "title page" will contain two colums: one containing the |
| 1532 | # title/author/etc., and the other containing the graphic. Use the other |
| 1533 | # four variables listed here to control specific details of the layout; all |
| 1534 | # are optional. |
| 1535 | # |
| 1536 | # $TITLE_PAGE_GRAPHIC = "my-company-logo"; |
| 1537 | # $TITLE_PAGE_GRAPHIC_COLWIDTH = "30%"; |
| 1538 | # $TITLE_PAGE_GRAPHIC_WIDTH = 150; |
| 1539 | # $TITLE_PAGE_GRAPHIC_HEIGHT = 150; |
| 1540 | # $TITLE_PAGE_GRAPHIC_ON_RIGHT = 0; |
| 1541 | |
| 1542 | sub make_my_titlepage() { |
| 1543 | my $the_title = ""; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1544 | if ($t_title) { |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1545 | $the_title .= "\n<h1>$t_title</h1>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1546 | } |
| 1547 | else { |
| 1548 | write_warnings("\nThis document has no title."); |
| 1549 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1550 | if ($t_author) { |
| 1551 | if ($t_authorURL) { |
Fred Drake | 0893205 | 1998-04-17 02:15:42 +0000 | [diff] [blame] | 1552 | my $href = translate_commands($t_authorURL); |
Fred Drake | 2d1f81e | 1999-02-09 16:03:31 +0000 | [diff] [blame] | 1553 | $href = make_named_href('author', $href, |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1554 | "<b><font size=\"+2\">$t_author" |
| 1555 | . '</font></b>'); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1556 | $the_title .= "\n<p>$href</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1557 | } |
| 1558 | else { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1559 | $the_title .= ("\n<p><b><font size=\"+2\">$t_author" |
| 1560 | . '</font></b></p>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1561 | } |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1562 | } |
| 1563 | else { |
| 1564 | write_warnings("\nThere is no author for this document."); |
| 1565 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1566 | if ($t_institute) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1567 | $the_title .= "\n<p>$t_institute</p>"; |
| 1568 | } |
Fred Drake | d07868a | 1998-05-14 21:00:28 +0000 | [diff] [blame] | 1569 | if ($DEVELOPER_ADDRESS) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1570 | $the_title .= "\n<p>$DEVELOPER_ADDRESS</p>"; |
| 1571 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1572 | if ($t_affil) { |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1573 | $the_title .= "\n<p><i>$t_affil</i></p>"; |
| 1574 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1575 | if ($t_date) { |
Fred Drake | de77bc5 | 2000-12-14 18:36:12 +0000 | [diff] [blame] | 1576 | $the_title .= "\n<p>"; |
Fred Drake | d04592a | 2000-10-25 16:15:13 +0000 | [diff] [blame] | 1577 | if ($PACKAGE_VERSION) { |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1578 | $the_title .= ('<strong>Release ' |
| 1579 | . "$PACKAGE_VERSION$RELEASE_INFO</strong><br>\n"); |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1580 | } |
Fred Drake | de77bc5 | 2000-12-14 18:36:12 +0000 | [diff] [blame] | 1581 | $the_title .= "<strong>$t_date</strong></p>" |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1582 | } |
| 1583 | if ($t_address) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1584 | $the_title .= "\n<p>$t_address</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1585 | } |
| 1586 | else { |
| 1587 | $the_title .= "\n<p>"; |
| 1588 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1589 | if ($t_email) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 1590 | $the_title .= "\n<p>$t_email</p>"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1591 | } |
| 1592 | return $the_title; |
| 1593 | } |
| 1594 | |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1595 | sub make_my_titlegraphic() { |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1596 | my $filename = make_icon_filename($TITLE_PAGE_GRAPHIC); |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1597 | my $graphic = "<td class=\"titlegraphic\""; |
| 1598 | $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_COLWIDTH\"" |
| 1599 | if ($TITLE_PAGE_GRAPHIC_COLWIDTH); |
| 1600 | $graphic .= "><img"; |
| 1601 | $graphic .= " width=\"$TITLE_PAGE_GRAPHIC_WIDTH\"" |
| 1602 | if ($TITLE_PAGE_GRAPHIC_WIDTH); |
| 1603 | $graphic .= " height=\"$TITLE_PAGE_GRAPHIC_HEIGHT\"" |
| 1604 | if ($TITLE_PAGE_GRAPHIC_HEIGHT); |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1605 | $graphic .= "\n src=\"$filename\"></td>\n"; |
Fred Drake | 3be2074 | 2000-08-31 06:22:54 +0000 | [diff] [blame] | 1606 | return $graphic; |
| 1607 | } |
| 1608 | |
| 1609 | sub do_cmd_maketitle { |
| 1610 | local($_) = @_; |
| 1611 | my $the_title = "\n<div class=\"titlepage\">"; |
| 1612 | if ($TITLE_PAGE_GRAPHIC) { |
| 1613 | if ($TITLE_PAGE_GRAPHIC_ON_RIGHT) { |
| 1614 | $the_title .= ("\n<table border=\"0\" width=\"100%\">" |
| 1615 | . "<tr align=\"right\">\n<td>" |
| 1616 | . make_my_titlepage() |
| 1617 | . "</td>\n" |
| 1618 | . make_my_titlegraphic() |
| 1619 | . "</tr>\n</table>"); |
| 1620 | } |
| 1621 | else { |
| 1622 | $the_title .= ("\n<table border=\"0\" width=\"100%\"><tr>\n" |
| 1623 | . make_my_titlegraphic() |
| 1624 | . "<td>" |
| 1625 | . make_my_titlepage() |
| 1626 | . "</td></tr>\n</table>"); |
| 1627 | } |
| 1628 | } |
| 1629 | else { |
| 1630 | $the_title .= ("\n<center>" |
| 1631 | . make_my_titlepage() |
| 1632 | . "\n</center>"); |
| 1633 | } |
| 1634 | $the_title .= "\n</div>"; |
| 1635 | return $the_title . $_; |
Fred Drake | 90fdda5 | 1999-02-16 20:27:42 +0000 | [diff] [blame] | 1636 | $the_title .= "\n</center></div>"; |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1637 | return $the_title . $_ ; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1638 | } |
| 1639 | |
| 1640 | |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1641 | # |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1642 | # Module synopsis support |
| 1643 | # |
| 1644 | |
| 1645 | require SynopsisTable; |
| 1646 | |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1647 | sub get_chapter_id(){ |
| 1648 | my $id = do_cmd_thechapter(''); |
Fred Drake | 45f2601 | 1998-08-04 22:07:18 +0000 | [diff] [blame] | 1649 | $id =~ s/<SPAN CLASS="arabic">(\d+)<\/SPAN>/\1/; |
| 1650 | $id =~ s/\.//; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1651 | return $id; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1652 | } |
| 1653 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1654 | # 'chapter' => 'SynopsisTable instance' |
| 1655 | %ModuleSynopses = (); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1656 | |
| 1657 | sub get_synopsis_table($){ |
| 1658 | my($chap) = @_; |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1659 | my $key; |
| 1660 | foreach $key (keys %ModuleSynopses) { |
| 1661 | if ($key eq $chap) { |
| 1662 | return $ModuleSynopses{$chap}; |
| 1663 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1664 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1665 | my $st = SynopsisTable->new(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1666 | $ModuleSynopses{$chap} = $st; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1667 | return $st; |
| 1668 | } |
| 1669 | |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1670 | sub do_cmd_moduleauthor{ |
| 1671 | local($_) = @_; |
| 1672 | next_argument(); |
| 1673 | next_argument(); |
| 1674 | return $_; |
| 1675 | } |
| 1676 | |
| 1677 | sub do_cmd_sectionauthor{ |
| 1678 | local($_) = @_; |
| 1679 | next_argument(); |
| 1680 | next_argument(); |
| 1681 | return $_; |
| 1682 | } |
| 1683 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1684 | sub do_cmd_declaremodule{ |
| 1685 | local($_) = @_; |
| 1686 | my $key = next_optional_argument(); |
| 1687 | my $type = next_argument(); |
| 1688 | my $name = next_argument(); |
| 1689 | my $st = get_synopsis_table(get_chapter_id()); |
| 1690 | # |
| 1691 | $key = $name unless $key; |
| 1692 | $type = 'built-in' if $type eq 'builtin'; |
| 1693 | $st->declare($name, $key, $type); |
| 1694 | define_module($type, $name); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1695 | return anchor_label("module-$key",$CURRENT_FILE,$_) |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1696 | } |
| 1697 | |
| 1698 | sub do_cmd_modulesynopsis{ |
| 1699 | local($_) = @_; |
| 1700 | my $st = get_synopsis_table(get_chapter_id()); |
Fred Drake | 1cc5899 | 1999-04-13 22:08:59 +0000 | [diff] [blame] | 1701 | $st->set_synopsis($THIS_MODULE, translate_commands(next_argument())); |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1702 | return $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1703 | } |
| 1704 | |
| 1705 | sub do_cmd_localmoduletable{ |
| 1706 | local($_) = @_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1707 | my $chap = get_chapter_id(); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1708 | my $st = get_synopsis_table($chap); |
| 1709 | $st->set_file("$CURRENT_FILE"); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1710 | return "<tex2html-localmoduletable><$chap>\\tableofchildlinks[off]" . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1711 | } |
| 1712 | |
| 1713 | sub process_all_localmoduletables{ |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1714 | my $key; |
| 1715 | my $st, $file; |
| 1716 | foreach $key (keys %ModuleSynopses) { |
| 1717 | $st = $ModuleSynopses{$key}; |
| 1718 | $file = $st->get_file(); |
| 1719 | if ($file) { |
| 1720 | process_localmoduletables_in_file($file); |
| 1721 | } |
| 1722 | else { |
Fred Drake | 6fe4660 | 2001-06-23 03:13:30 +0000 | [diff] [blame] | 1723 | print "\nsynopsis table $key has no file association\n"; |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1724 | } |
| 1725 | } |
| 1726 | } |
| 1727 | |
| 1728 | sub process_localmoduletables_in_file{ |
| 1729 | my $file = @_[0]; |
| 1730 | open(MYFILE, "<$file"); |
| 1731 | local($_); |
| 1732 | sysread(MYFILE, $_, 1024*1024); |
| 1733 | close(MYFILE); |
| 1734 | # need to get contents of file in $_ |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1735 | while (/<tex2html-localmoduletable><(\d+)>/) { |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1736 | my $match = $&; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1737 | my $chap = $1; |
| 1738 | my $st = get_synopsis_table($chap); |
| 1739 | my $data = $st->tohtml(); |
Fred Drake | f7685d7 | 1998-07-25 03:31:46 +0000 | [diff] [blame] | 1740 | s/$match/$data/; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1741 | } |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1742 | open(MYFILE,">$file"); |
| 1743 | print MYFILE $_; |
| 1744 | close(MYFILE); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1745 | } |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1746 | sub process_python_state{ |
| 1747 | process_all_localmoduletables(); |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1748 | process_grammar_files(); |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1749 | } |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1750 | |
| 1751 | |
| 1752 | # |
| 1753 | # "See also:" -- references placed at the end of a \section |
| 1754 | # |
| 1755 | |
| 1756 | sub do_env_seealso{ |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1757 | return ("<div class=\"seealso\">\n " |
| 1758 | . "<p class=\"heading\"><b>See Also:</b></p>\n" |
| 1759 | . @_[0] |
| 1760 | . '</div>'); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1761 | } |
| 1762 | |
Fred Drake | 5ed35fd | 2001-11-30 18:09:54 +0000 | [diff] [blame] | 1763 | sub do_env_seealsostar{ |
| 1764 | return ("<div class=\"seealso-simple\">\n " |
| 1765 | . @_[0] |
| 1766 | . '</div>'); |
| 1767 | } |
| 1768 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1769 | sub do_cmd_seemodule{ |
| 1770 | # Insert the right magic to jump to the module definition. This should |
| 1771 | # work most of the time, at least for repeat builds.... |
| 1772 | local($_) = @_; |
| 1773 | my $key = next_optional_argument(); |
| 1774 | my $module = next_argument(); |
| 1775 | my $text = next_argument(); |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1776 | my $period = '.'; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1777 | $key = $module |
| 1778 | unless $key; |
Fred Drake | 84bd6f3 | 1999-05-11 15:42:51 +0000 | [diff] [blame] | 1779 | if ($text =~ /\.$/) { |
| 1780 | $period = ''; |
| 1781 | } |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1782 | return ('<dl compact class="seemodule">' |
| 1783 | . "\n <dt>Module <b><tt class=\"module\">" |
| 1784 | . "<a href=\"module-$key.html\">$module</a></tt>:</b>" |
| 1785 | . "\n <dd>$text$period\n </dl>" |
| 1786 | . $_); |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1787 | } |
| 1788 | |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1789 | sub strip_html_markup($){ |
| 1790 | my $str = @_[0]; |
| 1791 | my $s = "$str"; |
| 1792 | $s =~ s/<[a-zA-Z0-9]+(\s+[a-zA-Z0-9]+(\s*=\s*(\'[^\']*\'|\"[^\"]*\"|[a-zA-Z0-9]+))?)*\s*>//g; |
| 1793 | $s =~ s/<\/[a-zA-Z0-9]+>//g; |
| 1794 | return $s; |
| 1795 | } |
| 1796 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1797 | sub handle_rfclike_reference{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1798 | local($_, $what, $format) = @_; |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1799 | my $rfcnum = next_argument(); |
| 1800 | my $title = next_argument(); |
| 1801 | my $text = next_argument(); |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1802 | my $url = get_rfc_url($rfcnum, $format); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1803 | my $icon = get_link_icon($url); |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1804 | my $attrtitle = strip_html_markup($title); |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1805 | return '<dl compact class="seerfc">' |
| 1806 | . "\n <dt><a href=\"$url\"" |
Fred Drake | e0197bf | 2001-04-12 04:03:22 +0000 | [diff] [blame] | 1807 | . "\n title=\"$attrtitle\"" |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1808 | . "\n >$what $rfcnum, <em>$title</em>$icon</a>" |
Fred Drake | 37cc0c0 | 2000-04-26 18:05:24 +0000 | [diff] [blame] | 1809 | . "\n <dd>$text\n </dl>" |
| 1810 | . $_; |
| 1811 | } |
| 1812 | |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1813 | sub do_cmd_seepep{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1814 | return handle_rfclike_reference(@_[0], "PEP", $PEP_FORMAT); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1815 | } |
| 1816 | |
| 1817 | sub do_cmd_seerfc{ |
Fred Drake | afc7ce1 | 2001-01-22 17:33:24 +0000 | [diff] [blame] | 1818 | return handle_rfclike_reference(@_[0], "RFC", $RFC_FORMAT); |
Fred Drake | 643d76d | 2000-09-09 06:07:37 +0000 | [diff] [blame] | 1819 | } |
| 1820 | |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1821 | sub do_cmd_seetitle{ |
| 1822 | local($_) = @_; |
| 1823 | my $url = next_optional_argument(); |
| 1824 | my $title = next_argument(); |
| 1825 | my $text = next_argument(); |
| 1826 | if ($url) { |
Fred Drake | 5f84c9b | 2000-10-03 06:05:25 +0000 | [diff] [blame] | 1827 | my $icon = get_link_icon($url); |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1828 | return '<dl compact class="seetitle">' |
| 1829 | . "\n <dt><em class=\"citetitle\"><a href=\"$url\"" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1830 | . "\n >$title$icon</a></em>" |
Fred Drake | 4844998 | 2000-09-12 17:52:33 +0000 | [diff] [blame] | 1831 | . "\n <dd>$text\n </dl>" |
| 1832 | . $_; |
| 1833 | } |
| 1834 | return '<dl compact class="seetitle">' |
| 1835 | . "\n <dt><em class=\"citetitle\"" |
| 1836 | . "\n >$title</em>" |
| 1837 | . "\n <dd>$text\n </dl>" |
| 1838 | . $_; |
| 1839 | } |
| 1840 | |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1841 | sub do_cmd_seeurl{ |
| 1842 | local($_) = @_; |
| 1843 | my $url = next_argument(); |
| 1844 | my $text = next_argument(); |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1845 | my $icon = get_link_icon($url); |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1846 | return '<dl compact class="seeurl">' |
| 1847 | . "\n <dt><a href=\"$url\"" |
Fred Drake | 7a40c07 | 2000-10-02 14:43:38 +0000 | [diff] [blame] | 1848 | . "\n class=\"url\">$url$icon</a>" |
Fred Drake | ef4d111 | 2000-05-09 16:17:51 +0000 | [diff] [blame] | 1849 | . "\n <dd>$text\n </dl>" |
| 1850 | . $_; |
| 1851 | } |
| 1852 | |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1853 | sub do_cmd_seetext{ |
Fred Drake | 79189b5 | 1999-04-28 13:54:30 +0000 | [diff] [blame] | 1854 | local($_) = @_; |
| 1855 | my $content = next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 1856 | return '<div class="seetext"><p>' . $content . '</div>' . $_; |
Fred Drake | a0f4c94 | 1998-07-24 22:16:04 +0000 | [diff] [blame] | 1857 | } |
| 1858 | |
| 1859 | |
| 1860 | # |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1861 | # Definition list support. |
| 1862 | # |
| 1863 | |
| 1864 | sub do_env_definitions{ |
Fred Drake | f1927a6 | 2001-06-20 21:29:30 +0000 | [diff] [blame] | 1865 | return "<dl class=\"definitions\">" . @_[0] . "</dl>\n"; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | sub do_cmd_term{ |
| 1869 | local($_) = @_; |
Fred Drake | ccc6272 | 1999-01-05 22:16:29 +0000 | [diff] [blame] | 1870 | my $term = next_argument(); |
| 1871 | my($name,$aname,$ahref) = new_link_info(); |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1872 | # could easily add an index entry here... |
Fred Drake | 62e4369 | 1998-08-10 19:40:44 +0000 | [diff] [blame] | 1873 | return "<dt><b>$aname" . $term . "</a></b>\n<dd>" . $_; |
Fred Drake | 885215c | 1998-05-20 21:32:09 +0000 | [diff] [blame] | 1874 | } |
| 1875 | |
| 1876 | |
Fred Drake | 38178fd | 2000-09-22 17:05:04 +0000 | [diff] [blame] | 1877 | # I don't recall exactly why this was needed, but it was very much needed. |
| 1878 | # We'll see if anything breaks when I move the "code" line out -- some |
| 1879 | # things broke with it in. |
| 1880 | |
| 1881 | #code # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1882 | process_commands_wrap_deferred(<<_RAW_ARG_DEFERRED_CMDS_); |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1883 | declaremodule # [] # {} # {} |
| 1884 | memberline # [] # {} |
| 1885 | methodline # [] # {} # {} |
| 1886 | modulesynopsis # {} |
Fred Drake | 557460c | 1999-03-02 16:05:35 +0000 | [diff] [blame] | 1887 | platform # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1888 | samp # {} |
Fred Drake | 2e1ee3e | 1999-02-10 21:17:04 +0000 | [diff] [blame] | 1889 | setindexsubitem # {} |
Fred Drake | f32834c | 1999-02-12 22:06:32 +0000 | [diff] [blame] | 1890 | withsubitem # {} # {} |
Fred Drake | 2ff880e | 1999-02-05 18:31:29 +0000 | [diff] [blame] | 1891 | _RAW_ARG_DEFERRED_CMDS_ |
| 1892 | |
| 1893 | |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 1894 | $alltt_start = '<dl><dd><pre class="verbatim">'; |
| 1895 | $alltt_end = '</pre></dl>'; |
| 1896 | |
| 1897 | sub do_env_alltt { |
| 1898 | local ($_) = @_; |
| 1899 | local($closures,$reopens,@open_block_tags); |
| 1900 | |
| 1901 | # get the tag-strings for all open tags |
| 1902 | local(@keep_open_tags) = @$open_tags_R; |
| 1903 | ($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R); |
| 1904 | |
| 1905 | # get the tags for text-level tags only |
| 1906 | $open_tags_R = [ @keep_open_tags ]; |
| 1907 | local($local_closures, $local_reopens); |
| 1908 | ($local_closures, $local_reopens,@open_block_tags) |
| 1909 | = &preserve_open_block_tags |
| 1910 | if (@$open_tags_R); |
| 1911 | |
| 1912 | $open_tags_R = [ @open_block_tags ]; |
| 1913 | |
| 1914 | do { |
| 1915 | local($open_tags_R) = [ @open_block_tags ]; |
| 1916 | local(@save_open_tags) = (); |
| 1917 | |
| 1918 | local($cnt) = ++$global{'max_id'}; |
| 1919 | $_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C |
| 1920 | , $_ , $O, $global{'max_id'}, "$C$O$cnt$C"); |
| 1921 | |
| 1922 | $_ = &translate_environments($_); |
| 1923 | $_ = &translate_commands($_) if (/\\/); |
| 1924 | |
| 1925 | # preserve space-runs, using |
| 1926 | while (s/(\S) ( +)/$1$2;SPMnbsp;/g){}; |
| 1927 | s/(<BR>) /$1;SPMnbsp;/g; |
| 1928 | |
| 1929 | $_ = join('', $closures, $alltt_start, $local_reopens |
| 1930 | , $_ |
| 1931 | , &balance_tags() #, $local_closures |
| 1932 | , $alltt_end, $reopens); |
| 1933 | undef $open_tags_R; undef @save_open_tags; |
| 1934 | }; |
| 1935 | $open_tags_R = [ @keep_open_tags ]; |
| 1936 | $_; |
| 1937 | } |
| 1938 | |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1939 | sub do_cmd_verbatiminput{ |
| 1940 | local($_) = @_; |
| 1941 | my $fname = next_argument(); |
| 1942 | my $file; |
| 1943 | my $found = 0; |
| 1944 | my $texpath; |
| 1945 | # Search TEXINPUTS for the input file, the way we're supposed to: |
| 1946 | foreach $texpath (split /$envkey/, $TEXINPUTS) { |
| 1947 | $file = "$texpath$dd$fname"; |
| 1948 | last if ($found = (-f $file)); |
| 1949 | } |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1950 | my $srcname; |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1951 | my $text; |
| 1952 | if ($found) { |
| 1953 | open(MYFILE, "<$file") || die "\n$!\n"; |
| 1954 | read(MYFILE, $text, 1024*1024); |
| 1955 | close(MYFILE); |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1956 | use File::Basename; |
| 1957 | my $srcdir, $srcext; |
| 1958 | ($srcname, $srcdir, $srcext) = fileparse($file, '\..*'); |
| 1959 | open(MYFILE, ">$srcname.txt"); |
| 1960 | print MYFILE $text; |
| 1961 | close(MYFILE); |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1962 | # |
| 1963 | # These rewrites convert the raw text to something that will |
| 1964 | # be properly visible as HTML and also will pass through the |
| 1965 | # vagaries of conversion through LaTeX2HTML. The order in |
| 1966 | # which the specific rewrites are performed is significant. |
| 1967 | # |
| 1968 | $text =~ s/\&/\&/g; |
| 1969 | # These need to happen before the normal < and > re-writes, |
| 1970 | # since we need to avoid LaTeX2HTML's attempt to perform |
| 1971 | # ligature processing without regard to context (since it |
| 1972 | # doesn't have font information). |
| 1973 | $text =~ s/--/-&\#45;/g; |
| 1974 | $text =~ s/<</\<\&\#60;/g; |
| 1975 | $text =~ s/>>/\>\&\#62;/g; |
| 1976 | # Just normal re-writes... |
| 1977 | $text =~ s/</\</g; |
| 1978 | $text =~ s/>/\>/g; |
| 1979 | # These last isn't needed for the HTML, but is needed to get |
| 1980 | # past LaTeX2HTML processing TeX macros. We use \ instead |
| 1981 | # of / since many browsers don't support that. |
| 1982 | $text =~ s/\\/\&\#92;/g; |
| 1983 | } |
| 1984 | else { |
| 1985 | $text = '<b>Could not locate requested file <i>$fname</i>!</b>\n'; |
| 1986 | } |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1987 | return ('<dl><dd><pre class="verbatim">' |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1988 | . $text |
Fred Drake | 77602f2 | 2001-07-06 22:43:02 +0000 | [diff] [blame] | 1989 | . "</pre>\n<div class=\"verbatiminput-footer\">\n" |
| 1990 | . "<a href=\"$srcname.txt\" type=\"text/plain\"" |
| 1991 | . ">Download as text.</a>" |
| 1992 | . "\n</div>\n</dd></dl>" |
Fred Drake | 57e52ef | 2001-06-15 21:31:57 +0000 | [diff] [blame] | 1993 | . $_); |
| 1994 | } |
Fred Drake | 8633360 | 2001-04-10 17:13:39 +0000 | [diff] [blame] | 1995 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 1996 | 1; # This must be the last line |