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