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 | |
| 11 | |
| 12 | # words typeset in a special way (not in HTML though) |
| 13 | |
| 14 | sub do_cmd_ABC{ 'ABC' . @_[0]; } |
| 15 | sub do_cmd_UNIX{ 'Unix'. @_[0]; } |
| 16 | sub do_cmd_ASCII{ 'ASCII' . @_[0]; } |
| 17 | sub do_cmd_POSIX{ 'POSIX' . @_[0]; } |
| 18 | sub do_cmd_C{ 'C' . @_[0]; } |
| 19 | sub do_cmd_Cpp{ 'C++' . @_[0]; } |
| 20 | sub do_cmd_EOF{ 'EOF' . @_[0]; } |
| 21 | sub do_cmd_NULL{ '<tt>NULL</tt>' . @_[0]; } |
| 22 | |
| 23 | sub do_cmd_e{ '\' . @_[0]; } |
| 24 | |
| 25 | $AUTHOR_ADDRESS = ''; |
| 26 | $PYTHON_VERSION = ''; |
| 27 | |
| 28 | sub do_cmd_version{ $PYTHON_VERSION . @_[0]; } |
| 29 | sub do_cmd_release{ |
| 30 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 31 | s/$next_pair_pr_rx//; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 32 | $PYTHON_VERSION = "$2"; |
| 33 | $_; |
| 34 | } |
| 35 | |
| 36 | sub do_cmd_authoraddress{ |
| 37 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 38 | s/$next_pair_pr_rx//; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 39 | $AUTHOR_ADDRESS = "$2"; |
| 40 | $_; |
| 41 | } |
| 42 | |
| 43 | sub do_cmd_hackscore{ |
| 44 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 45 | s/$next_pair_pr_rx/_/; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 46 | $_; |
| 47 | } |
| 48 | |
| 49 | sub do_cmd_optional{ |
| 50 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 51 | s|$next_pair_pr_rx|</var><big>\[</big><var>\2</var><big>\]</big><var>|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 52 | $_; |
| 53 | } |
| 54 | |
| 55 | sub do_cmd_varvars{ |
| 56 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 57 | s|$next_pair_pr_rx|<var>\2</var>|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 58 | $_; |
| 59 | } |
| 60 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 61 | # Logical formatting (some based on texinfo), needs to be converted to |
| 62 | # minimalist HTML. The "minimalist" is primarily to reduce the size of |
| 63 | # output files for users that read them over the network rather than |
| 64 | # from local repositories. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 65 | |
| 66 | sub do_cmd_code{ |
| 67 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 68 | s|$next_pair_pr_rx|<tt>\2</tt>|; |
| 69 | $_; |
| 70 | } |
| 71 | |
| 72 | sub use_sans_serif{ |
| 73 | local($_) = @_; |
| 74 | s|$next_pair_pr_rx|<font face=sans-serif>\2</font>|; |
| 75 | $_; |
| 76 | } |
| 77 | |
| 78 | sub use_italics{ |
| 79 | local($_) = @_; |
| 80 | s|$next_pair_pr_rx|<i>\2</i>|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 81 | $_; |
| 82 | } |
| 83 | |
| 84 | sub do_cmd_sectcode{ &do_cmd_code(@_); } |
| 85 | sub do_cmd_module{ &do_cmd_code(@_); } |
| 86 | sub do_cmd_keyword{ &do_cmd_code(@_); } |
| 87 | sub do_cmd_exception{ &do_cmd_code(@_); } |
| 88 | sub do_cmd_class{ &do_cmd_code(@_); } |
| 89 | sub do_cmd_function{ &do_cmd_code(@_); } |
| 90 | sub do_cmd_constant{ &do_cmd_code(@_); } |
| 91 | sub do_cmd_member{ &do_cmd_code(@_); } |
| 92 | sub do_cmd_method{ &do_cmd_code(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 93 | sub do_cmd_cfunction{ &do_cmd_code(@_); } |
| 94 | sub do_cmd_cdata{ &do_cmd_code(@_); } |
| 95 | sub do_cmd_ctype{ &do_cmd_code(@_); } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 96 | sub do_cmd_regexp{ &do_cmd_code(@_); } |
| 97 | sub do_cmd_key{ &do_cmd_code(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 98 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 99 | sub do_cmd_character{ &do_cmd_samp(@_); } |
| 100 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 101 | sub do_cmd_program{ &do_cmd_strong(@_); } |
| 102 | |
| 103 | sub do_cmd_email{ &use_sans_serif(@_); } |
| 104 | sub do_cmd_mimetype{ &use_sans_serif(@_); } |
| 105 | |
| 106 | sub do_cmd_var{ &use_italics(@_); } |
| 107 | sub do_cmd_dfn{ &use_italics(@_); } |
| 108 | sub do_cmd_emph{ &use_italics(@_); } |
| 109 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 110 | |
| 111 | sub do_cmd_envvar{ |
| 112 | local($_) = @_; |
| 113 | s/$next_pair_pr_rx/\$\2/; |
| 114 | $_; |
| 115 | } |
| 116 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 117 | sub do_cmd_url{ |
| 118 | # use the URL as both text and hyperlink |
| 119 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 120 | s/$next_pair_pr_rx//; |
| 121 | my $url = $2; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 122 | $url =~ s/~/~/g; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 123 | "<a href=\"$url\"><font face=sans-serif>$url</font></a>" . $_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | sub do_cmd_manpage{ |
| 127 | # two parameters: \manpage{name}{section} |
| 128 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 129 | my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
| 130 | s|$pair_pr_rx$any_next_pair_pr_rx3|<i>\2</i>(\4)|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 131 | $_; |
| 132 | } |
| 133 | |
| 134 | sub do_cmd_rfc{ |
| 135 | local($_) = @_; |
| 136 | s/$next_pair_pr_rx//; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 137 | my($br_id,$rfcnumber) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 138 | |
| 139 | # Save the reference |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 140 | my $nstr = &gen_index_id("RFC!RFC $rfcnumber", ''); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 141 | $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id"); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 142 | "<a name=$br_id>RFC $rfcnumber</a>" .$_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | sub do_cmd_kbd{ |
| 146 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 147 | s|$next_pair_pr_rx|<kbd>\2</kbd>|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 148 | $_; |
| 149 | } |
| 150 | |
| 151 | sub do_cmd_strong{ |
| 152 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 153 | s|$next_pair_pr_rx|<b>\2</b>|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 154 | $_; |
| 155 | } |
| 156 | |
| 157 | sub do_cmd_deprecated{ |
| 158 | # two parameters: \deprecated{version}{whattodo} |
| 159 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 160 | my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
| 161 | my($release,$action) = ($2, $4); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 162 | s/$next_pair_pr_rx$any_next_pair_pr_rx3//; |
| 163 | "<b>Deprecated since release $release.</b>" |
| 164 | . "\n$action<p>" |
| 165 | . $_; |
| 166 | } |
| 167 | |
| 168 | # file and samp are at the end of this file since they screw up fontlock. |
| 169 | |
| 170 | # index commands |
| 171 | |
| 172 | $INDEX_SUBITEM = ""; |
| 173 | |
| 174 | sub get_indexsubitem{ |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 175 | #$INDEX_SUBITEM ? " $INDEX_SUBITEM" : ''; |
| 176 | ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | sub do_cmd_setindexsubitem{ |
| 180 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 181 | s/$next_pair_pr_rx//; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 182 | $INDEX_SUBITEM = $2; |
| 183 | $_; |
| 184 | } |
| 185 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 186 | sub do_cmd_withsubitem{ |
| 187 | # We can't really do the right right thing, because LaTeX2HTML doesn't |
| 188 | # do things in the right order, but we need to at least strip this stuff |
| 189 | # out, and leave anything that the second argument expanded out to. |
| 190 | # |
| 191 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 192 | my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 193 | s/$next_pair_pr_rx$any_next_pair_pr_rx3/\4/; |
| 194 | $_; |
| 195 | } |
| 196 | |
| 197 | sub do_cmd_makemodindex{ @_[0]; } |
| 198 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 199 | sub do_cmd_indexii{ |
| 200 | local($_) = @_; |
| 201 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 202 | my($br_id1,$str1) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 203 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 204 | my($br_id2,$str2) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 205 | join('', &make_index_entry($br_id1, "$str1 $str2"), |
| 206 | &make_index_entry($br_id2, "$str2, $str1"), $_); |
| 207 | } |
| 208 | |
| 209 | sub do_cmd_indexiii{ |
| 210 | local($_) = @_; |
| 211 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 212 | my($br_id1,$str1) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 213 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 214 | my($br_id2,$str2) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 215 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 216 | my($br_id3,$str3) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 217 | join('', &make_index_entry($br_id1, "$str1 $str2 $str3"), |
| 218 | &make_index_entry($br_id2, "$str2 $str3, $str1"), |
| 219 | &make_index_entry($br_id3, "$str3, $str1 $str2"), |
| 220 | $_); |
| 221 | } |
| 222 | |
| 223 | sub do_cmd_indexiv{ |
| 224 | local($_) = @_; |
| 225 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 226 | my($br_id1,$str1) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 227 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 228 | my($br_id2,$str2) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 229 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 230 | my($br_id3,$str3) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 231 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 232 | my($br_id4,$str4) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 233 | join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"), |
| 234 | &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"), |
| 235 | &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"), |
| 236 | &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"), |
| 237 | $_); |
| 238 | } |
| 239 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 240 | sub do_cmd_ttindex{ |
| 241 | local($_) = @_; |
| 242 | s/$next_pair_pr_rx//; |
| 243 | my($br_id,$str) = ($1, $2); |
| 244 | &make_index_entry($br_id, $str . &get_indexsubitem) . $_; |
| 245 | } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 246 | |
| 247 | sub my_typed_index_helper{ |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 248 | local($word,$_) = @_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 249 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 250 | my($br_id,$str) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 251 | join('', &make_index_entry($br_id, "$str $word"), |
| 252 | &make_index_entry($br_id, "$word, $str"), $_); |
| 253 | } |
| 254 | |
| 255 | sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); } |
| 256 | sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); } |
| 257 | sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); } |
| 258 | sub do_cmd_obindex{ &my_typed_index_helper('object', @_); } |
| 259 | |
| 260 | sub my_parword_index_helper{ |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 261 | local($word,$_) = @_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 262 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 263 | my($br_id,$str) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 264 | &make_index_entry($br_id, "$str ($word)") . $_; |
| 265 | } |
| 266 | |
| 267 | |
| 268 | # Set this to true to strip out the <tt>...</tt> from index entries; |
| 269 | # this is analogous to using the second definition of \idxcode{} from |
| 270 | # myformat.sty. |
| 271 | # |
| 272 | # It is used from &make_mod_index_entry() and &make_str_index_entry(). |
| 273 | # |
| 274 | $STRIP_INDEX_TT = 0; |
| 275 | |
| 276 | sub make_mod_index_entry{ |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 277 | my($br_id,$str,$define) = @_; |
| 278 | my $halfref = &make_half_href("$CURRENT_FILE#$br_id"); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 279 | # If TITLE is not yet available (i.e the \index command is in the title |
| 280 | # of the current section), use $ref_before. |
| 281 | $TITLE = $ref_before unless $TITLE; |
| 282 | # Save the reference |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 283 | if ($define eq 'DEF') { |
| 284 | my($nstr,$garbage) = split / /, $str, 2; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 285 | $Modules{$nstr} .= $halfref; |
| 286 | } |
| 287 | $str = &gen_index_id($str, $define); |
| 288 | if ($STRIP_INDEX_TT) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 289 | $str =~ s|<tt>(.*)</tt>|\1|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 290 | } |
| 291 | $index{$str} .= $halfref; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 292 | "<a name=$br_id>$anchor_invisible_mark</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 295 | $THIS_MODULE = ''; |
| 296 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 297 | sub my_module_index_helper{ |
| 298 | local($word, $_) = @_; |
| 299 | s/$next_pair_pr_rx[\n]*//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 300 | my($br_id, $str) = ($1, $2); |
| 301 | my $section_tag = join('', @curr_sec_id); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 302 | $word = "$word " if $word; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 303 | $THIS_MODULE = "$str"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 304 | &make_mod_index_entry("SECTION$section_tag", |
| 305 | "<tt>$str</tt> (${word}module)", 'DEF'); |
| 306 | $_; |
| 307 | } |
| 308 | |
| 309 | sub ref_module_index_helper{ |
| 310 | local($word, $_) = @_; |
| 311 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 312 | my($br_id, $str) = ($1, $2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 313 | $word = "$word " if $word; |
| 314 | &make_mod_index_entry($br_id, "<tt>$str</tt> (${word}module)", 'REF') . $_; |
| 315 | } |
| 316 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 317 | sub do_cmd_bifuncindex{ |
| 318 | local($_) = @_; |
| 319 | s/$next_pair_pr_rx//o; |
| 320 | my($br_id,$str,$fname) = ($1, $2, "<tt>$2()</tt>"); |
| 321 | $fname = "$str()" |
| 322 | if $STRIP_INDEX_TT; |
| 323 | &make_index_entry($br_id, "$fname (built-in function)") . $_; |
| 324 | } |
| 325 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 326 | sub do_cmd_modindex{ &my_module_index_helper('', @_); } |
| 327 | sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_); } |
| 328 | sub do_cmd_exmodindex{ &my_module_index_helper('extension', @_); } |
| 329 | sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_); } |
| 330 | |
| 331 | # these should be adjusted a bit.... |
| 332 | sub do_cmd_refmodindex{ &ref_module_index_helper('', @_); } |
| 333 | sub do_cmd_refbimodindex{ &ref_module_index_helper('built-in', @_); } |
| 334 | sub do_cmd_refexmodindex{ &ref_module_index_helper('extension', @_); } |
| 335 | sub do_cmd_refstmodindex{ &ref_module_index_helper('standard', @_); } |
| 336 | |
| 337 | sub do_cmd_nodename{ &do_cmd_label(@_); } |
| 338 | |
| 339 | sub init_myformat{ |
| 340 | # XXX need some way for this to be called after &initialise; ??? |
| 341 | $anchor_mark = ''; |
| 342 | $icons{'anchor_mark'} = ''; |
| 343 | # <<2>>...<<2>> |
| 344 | $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C"; |
| 345 | $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C"; |
| 346 | $any_next_pair_rx7 = "$O(\\d+)$C([\\s\\S]*)$O\\7$C"; |
| 347 | $any_next_pair_rx9 = "$O(\\d+)$C([\\s\\S]*)$O\\9$C"; |
| 348 | # <#2#>...<#2#> |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 349 | $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
| 350 | $any_next_pair_pr_rx5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP"; |
| 351 | $any_next_pair_pr_rx7 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP"; |
| 352 | $any_next_pair_pr_rx9 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP"; |
Fred Drake | 2da947a | 1998-03-04 05:30:49 +0000 | [diff] [blame] | 353 | # if (defined &process_commands_wrap_deferred) { |
| 354 | # &process_commands_wrap_deferred(<<THESE_COMMANDS); |
| 355 | # indexii # {} # {} |
| 356 | # indexiii # {} # {} # {} |
| 357 | # indexiv # {} # {} # {} # {} |
| 358 | # exindex # {} |
| 359 | # obindex # {} |
| 360 | # opindex # {} |
| 361 | # stindex # {} |
| 362 | # ttindex # {} |
| 363 | # bifuncindex # {} |
| 364 | # modindex # {} |
| 365 | # bimodindex # {} |
| 366 | # exmodindex # {} |
| 367 | # stmodindex # {} |
| 368 | # refmodindex # {} |
| 369 | # refbimodindex # {} |
| 370 | # refexmodindex # {} |
| 371 | # refstmodindex # {} |
| 372 | # rfc # {} |
| 373 | # THESE_COMMANDS |
| 374 | # } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | &init_myformat; |
| 378 | |
| 379 | # similar to make_index_entry(), but includes the string in the result |
| 380 | # instead of the dummy filler. |
| 381 | # |
| 382 | sub make_str_index_entry{ |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 383 | my($br_id,$str) = @_; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 384 | # If TITLE is not yet available (i.e the \index command is in the title |
| 385 | # of the current section), use $ref_before. |
| 386 | $TITLE = $ref_before unless $TITLE; |
| 387 | # Save the reference |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 388 | my $nstr = &gen_index_id($str, ''); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 389 | if ($STRIP_INDEX_TT) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 390 | $nstr =~ s|<tt>(.*)</tt>|\1|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 391 | } |
| 392 | $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id"); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 393 | "<a name=\"$br_id\">$str</a>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | # Changed from the stock version to indent {verbatim} sections, |
| 397 | # and make them smaller, to better match the LaTeX version: |
| 398 | |
| 399 | # (Used with LaTeX2HTML 96.1*) |
| 400 | sub replace_verbatim { |
| 401 | # Modifies $_ |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 402 | my($prefix,$suffix) = ("\n<p><dl><dd><pre>\n", "</pre></dl>"); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 403 | s/$verbatim_mark(verbatim)(\d+)/$prefix$verbatim{$2}$suffix/go; |
| 404 | s/$verbatim_mark(rawhtml)(\d+)/$verbatim{$2}/ego; # Raw HTML |
| 405 | } |
| 406 | |
| 407 | # (Used with LaTeX2HTML 98.1) |
| 408 | sub replace_verbatim_hook{ |
| 409 | # Modifies $_ |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 410 | my($prefix,$suffix) = ("\n<p><dl><dd>", "</dl>"); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 411 | s/$math_verbatim_rx/&put_comment("MATH: ".$verbatim{$1})/eg; |
| 412 | s/$verbatim_mark(\w*[vV]erbatim\*?)(\d+)\#/$prefix$verbatim{$2}$suffix/go; |
| 413 | # Raw HTML, but replacements may have protected characters |
| 414 | s/$verbatim_mark(rawhtml)(\d+)#/&unprotect_raw_html($verbatim{$2})/eg; |
| 415 | s/$verbatim_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX |
| 416 | s/$unfinished_mark$keepcomments(\d+)#/$verbatim{$2}/ego; # Raw TeX |
| 417 | } |
| 418 | |
| 419 | sub do_env_cfuncdesc{ |
| 420 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 421 | my($return_type,$function_name,$arg_list,$idx) = ('', '', '', ''); |
| 422 | my $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C"; |
| 423 | my $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C"; |
| 424 | my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 425 | if (/$cfuncdesc_rx/o) { |
| 426 | $return_type = "$2"; |
| 427 | $function_name = "$4"; |
| 428 | $arg_list = "$6"; |
| 429 | $idx = &make_str_index_entry($3, |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 430 | "<tt>$function_name()</tt>" . &get_indexsubitem); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 431 | $idx =~ s/ \(.*\)//; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 432 | $idx =~ s/\(\)//; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 433 | } |
| 434 | "<dl><dt>$return_type <b>$idx</b>" |
| 435 | . "(<var>$arg_list</var>)\n<dd>$'\n</dl>" |
| 436 | } |
| 437 | |
| 438 | sub do_env_ctypedesc{ |
| 439 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 440 | my $type_name = (''); |
| 441 | my $cfuncdesc_rx = "$next_pair_rx"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 442 | if (/$cfuncdesc_rx/o) { |
| 443 | $type_name = "$2"; |
| 444 | $idx = &make_str_index_entry($1, |
| 445 | "<tt>$type_name</tt>" . &get_indexsubitem); |
| 446 | $idx =~ s/ \(.*\)//; |
| 447 | } |
| 448 | "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>" |
| 449 | } |
| 450 | |
| 451 | sub do_env_cvardesc{ |
| 452 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 453 | my($var_type,$var_name,$idx) = ('', '', ''); |
| 454 | my $cfuncdesc_rx = "$next_pair_rx$any_next_pair_rx3"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 455 | if (/$cfuncdesc_rx/o) { |
| 456 | $var_type = "$2"; |
| 457 | $var_name = "$4"; |
| 458 | $idx = &make_str_index_entry($3, |
| 459 | "<tt>$var_name</tt>" . &get_indexsubitem); |
| 460 | $idx =~ s/ \(.*\)//; |
| 461 | } |
| 462 | "<dl><dt>$var_type <b>$idx</b>\n" |
| 463 | . "<dd>$'\n</dl>"; |
| 464 | } |
| 465 | |
| 466 | sub do_env_funcdesc{ |
| 467 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 468 | my($function_name,$arg_list,$idx) = ('', '', ''); |
| 469 | my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 470 | if (/$funcdesc_rx/o) { |
| 471 | $function_name = "$2"; |
| 472 | $arg_list = "$4"; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 473 | $idx = &make_str_index_entry($3, "<tt>$function_name()</tt>" |
| 474 | . &get_indexsubitem); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 475 | $idx =~ s/ \(.*\)//; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 476 | $idx =~ s/\(\)//; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 477 | } |
| 478 | "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>"; |
| 479 | } |
| 480 | |
| 481 | sub do_env_funcdescni{ |
| 482 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 483 | my($function_name,$arg_list,$idx) = ('', '', ''); |
| 484 | my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 485 | if (/$funcdesc_rx/o) { |
| 486 | $function_name = "$2"; |
| 487 | $arg_list = "$4"; |
| 488 | if ($STRIP_INDEX_TT) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 489 | $idx = "$function_name"; } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 490 | else { |
| 491 | $idx = "<tt>$function_name</tt>"; } |
| 492 | } |
| 493 | "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>"; |
| 494 | } |
| 495 | |
| 496 | sub do_cmd_funcline{ |
| 497 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 498 | my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 499 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 500 | s/$next_pair_pr_rx//o; |
| 501 | my $function_name = $2; |
| 502 | s/$next_pair_pr_rx//o; |
| 503 | my($br_id,$arg_list) = ($1, $2); |
| 504 | my $idx = &make_str_index_entry($br_id, "<tt>$function_name()</tt>" |
| 505 | . &get_indexsubitem); |
| 506 | $idx =~ s/\(\)//; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 507 | |
| 508 | "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_; |
| 509 | } |
| 510 | |
| 511 | # Change this flag to index the opcode entries. I don't think it's very |
| 512 | # useful to index them, since they're only presented to describe the dis |
| 513 | # module. |
| 514 | # |
| 515 | $INDEX_OPCODES = 0; |
| 516 | |
| 517 | sub do_env_opcodedesc{ |
| 518 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 519 | my($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', ''); |
| 520 | my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
| 521 | my $opcodedesc_rx = "$next_pair_rx$any_next_pair_rx3"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 522 | if (/$opcodedesc_rx/o) { |
| 523 | $opcode_name = "$2"; |
| 524 | $arg_list = "$4"; |
| 525 | if ($INDEX_OPCODES) { |
| 526 | $idx = &make_str_index_entry($3, |
| 527 | "<tt>$opcode_name</tt> (byte code instruction)"); |
| 528 | $idx =~ s/ \(byte code instruction\)//; |
| 529 | } |
| 530 | else { |
| 531 | $idx = "<tt>$opcode_name</tt>"; |
| 532 | } |
| 533 | } |
| 534 | $stuff = "<dl><dt><b>$idx</b>"; |
| 535 | if ($arg_list) { |
| 536 | $stuff .= " <var>$arg_list</var>"; |
| 537 | } |
| 538 | $stuff . "\n<dd>$'\n</dl>"; |
| 539 | } |
| 540 | |
| 541 | sub do_env_datadesc{ |
| 542 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 543 | my $idx = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 544 | if (/$next_pair_rx/o) { |
| 545 | $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem); |
| 546 | $idx =~ s/ \(.*\)//; |
| 547 | } |
| 548 | "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>" |
| 549 | } |
| 550 | |
| 551 | sub do_env_datadescni{ |
| 552 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 553 | my $idx = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 554 | if (/$next_pair_rx/o) { |
| 555 | if ($STRING_INDEX_TT) { |
| 556 | $idx = "$2"; } |
| 557 | else { |
| 558 | $idx = "<tt>$2</tt>"; } |
| 559 | } |
| 560 | "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>" |
| 561 | } |
| 562 | |
| 563 | sub do_cmd_dataline{ |
| 564 | local($_) = @_; |
| 565 | |
| 566 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 567 | my($br_id, $data_name) = ($1, $2); |
| 568 | my $idx = &make_str_index_entry($br_id, "<tt>$data_name</tt>" |
| 569 | . &get_indexsubitem); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 570 | $idx =~ s/ \(.*\)//; |
| 571 | |
| 572 | "<dt><b>$idx</b>\n<dd>" . $_; |
| 573 | } |
| 574 | |
| 575 | sub do_env_excdesc{ &do_env_datadesc(@_); } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 576 | #sub do_env_classdesc{ &do_env_funcdesc(@_); } |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 577 | sub do_env_fulllineitems{ &do_env_itemize(@_); } |
| 578 | |
| 579 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 580 | sub do_env_classdesc{ |
| 581 | local($_) = @_; |
| 582 | my($function_name,$arg_list,$idx) = ('', '', ''); |
| 583 | my $funcdesc_rx = "$next_pair_rx$any_next_pair_rx3"; |
| 584 | if (/$funcdesc_rx/o) { |
| 585 | $function_name = "$2"; |
| 586 | $arg_list = "$4"; |
| 587 | $idx = &make_str_index_entry($3, |
| 588 | "<tt>$function_name</tt> (class in $THIS_MODULE)" ); |
| 589 | $idx =~ s/ \(.*\)//; |
| 590 | } |
| 591 | "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>"; |
| 592 | } |
| 593 | |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 594 | @col_aligns = ("<td>", "<td>", "<td>"); |
| 595 | |
| 596 | sub setup_column_alignments{ |
| 597 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 598 | my($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_); |
| 599 | my($th1,$th2,$th3) = ('<th>', '<th>', '<th>'); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 600 | $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>"); |
| 601 | $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>"); |
| 602 | $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>"); |
| 603 | # return the aligned header start tags; only used for \begin{tableiii?} |
| 604 | $th1 = (($a1 eq "l") ? "<th align=left>" |
| 605 | : ($a1 eq "r" ? "<th align=right>" : "<th>")); |
| 606 | $th2 = (($a2 eq "l") ? "<th align=left>" |
| 607 | : ($a2 eq "r" ? "<th align=right>" : "<th>")); |
| 608 | $th3 = (($a3 eq "l") ? "<th align=left>" |
| 609 | : ($a3 eq "r" ? "<th align=right>" : "<th>")); |
| 610 | ($th1, $th2, $th3); |
| 611 | } |
| 612 | |
| 613 | sub do_env_tableii{ |
| 614 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 615 | my($font,$h1,$h2) = ('', '', ''); |
| 616 | my $tableiii_rx = |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 617 | "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"; |
| 618 | if (/$tableiii_rx/o) { |
| 619 | $font = $4; |
| 620 | $h1 = $6; |
| 621 | $h2 = $8; |
| 622 | } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 623 | my($th1,$th2,$th3) = &setup_column_alignments($2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 624 | $globals{"lineifont"} = $font; |
| 625 | "<table border align=center>" |
| 626 | . "\n <tr>$th1<b>$h1</b></th>" |
| 627 | . "\n $th2<b>$h2</b></th>$'" |
| 628 | . "\n</table>"; |
| 629 | } |
| 630 | |
| 631 | sub do_cmd_lineii{ |
| 632 | local($_) = @_; |
| 633 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 634 | my $c1 = $2; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 635 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 636 | my $c2 = $2; |
| 637 | my $font = $globals{"lineifont"}; |
| 638 | my($c1align,$c2align) = @col_aligns[0,1]; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 639 | "<tr>$c1align<$font>$c1</$font></td>\n" |
| 640 | . " $c2align$c2</td>$'"; |
| 641 | } |
| 642 | |
| 643 | sub do_env_tableiii{ |
| 644 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 645 | my($font,$h1,$h2,$h3) = ('', '', '', ''); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 646 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 647 | my $tableiii_rx = |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 648 | "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7" |
| 649 | . "$any_next_pair_rx9"; |
| 650 | if (/$tableiii_rx/o) { |
| 651 | $font = $4; |
| 652 | $h1 = $6; |
| 653 | $h2 = $8; |
| 654 | $h3 = $10; |
| 655 | } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 656 | my($th1,$th2,$th3) = &setup_column_alignments($2); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 657 | $globals{"lineifont"} = $font; |
| 658 | "<table border align=center>" |
| 659 | . "\n <tr>$th1<b>$h1</b></th>" |
| 660 | . "\n $th2<b>$h2</b></th>" |
| 661 | . "\n $th3<b>$h3</b></th>$'" |
| 662 | . "\n</table>"; |
| 663 | } |
| 664 | |
| 665 | sub do_cmd_lineiii{ |
| 666 | local($_) = @_; |
| 667 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 668 | my $c1 = $2; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 669 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 670 | my $c2 = $2; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 671 | s/$next_pair_pr_rx//o; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 672 | my $c3 = $2; |
| 673 | my $font = $globals{"lineifont"}; |
| 674 | my($c1align, $c2align, $c3align) = @col_aligns; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 675 | "<tr>$c1align<$font>$c1</$font></td>\n" |
| 676 | . " $c2align$c2</td>\n" |
| 677 | . " $c3align$c3</td>$'"; |
| 678 | } |
| 679 | |
| 680 | sub do_env_seealso{ |
| 681 | "<p><b>See Also:</b></p>\n" . @_[0]; |
| 682 | } |
| 683 | |
| 684 | sub do_cmd_seemodule{ |
| 685 | # Insert the right magic to jump to the module definition. This should |
| 686 | # work most of the time, at least for repeat builds.... |
| 687 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 688 | my $any_next_pair_pr_rx3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
| 689 | my $any_next_pair_pr_rx5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP"; |
| 690 | # Predefined $opt_arg_rx & $optional_arg_rx don't work because they |
| 691 | # require the argument to be there. |
| 692 | my $opt_arg_rx = "^\\s*(\\[([^]]*)\\])?"; |
| 693 | s/$opt_arg_rx$any_next_pair_pr_rx3$any_next_pair_pr_rx5//; |
| 694 | my($key,$module,$text) = ($2, $4, $6); |
| 695 | $key = $module unless $key; |
Fred Drake | b3c9bca | 1998-03-06 21:20:08 +0000 | [diff] [blame] | 696 | "<p>Module <tt><b><a href=\"module-$key.html\">$module</a></b></tt>" |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 697 | . " ($text)</p>" |
| 698 | . $_; |
| 699 | } |
| 700 | |
| 701 | sub do_cmd_seetext{ |
| 702 | "<p>" . @_[0]; |
| 703 | } |
| 704 | |
| 705 | |
| 706 | sub do_cmd_maketitle { |
| 707 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 708 | my $the_title = ''; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 709 | if ($t_title) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 710 | $the_title .= "<h1 align=center>$t_title</h1>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 711 | } else { &write_warnings("\nThis document has no title."); } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 712 | $the_title .= "\n<center>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 713 | if ($t_author) { |
| 714 | if ($t_authorURL) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 715 | my $href = &translate_commands($t_authorURL); |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 716 | $href = &make_named_href('author', $href, "<strong>${t_author}</strong>"); |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 717 | $the_title .= "\n<p>$href</p>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 718 | } else { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 719 | $the_title .= "\n<p><strong>$t_author</strong></p>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 720 | } |
| 721 | } else { &write_warnings("\nThere is no author for this document."); } |
| 722 | if ($t_institute) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 723 | $the_title .= "\n<p>$t_institute</p>";} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 724 | if ($AUTHOR_ADDRESS) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 725 | $the_title .= "\n<p>$AUTHOR_ADDRESS</p>";} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 726 | if ($t_affil) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 727 | $the_title .= "\n<p><i>$t_affil</i></p>";} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 728 | if ($t_date) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 729 | $the_title .= "\n<p><strong>$t_date</strong>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 730 | if ($PYTHON_VERSION) { |
| 731 | $the_title .= "<br><strong>Release $PYTHON_VERSION</strong>";} |
| 732 | $the_title .= "</p>" |
| 733 | } |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 734 | $the_title .= "\n</center>"; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 735 | if ($t_address) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 736 | $the_title .= "\n<p>$t_address</p>"; |
| 737 | } else { $the_title .= "\n<p>"} |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 738 | if ($t_email) { |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 739 | $the_title .= "\n<p>$t_email</p>"; |
| 740 | }# else { $the_title .= "</p>" } |
| 741 | $the_title . "<hr>\n" . $_ ; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 745 | sub do_cmd_inputindex{ |
| 746 | local($_) = @_; |
| 747 | s/$next_pair_pr_rx//; |
| 748 | &do_cmd_input($2); |
| 749 | } |
| 750 | |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 751 | sub do_cmd_indexlabel{ |
| 752 | "genindex" . @_[0]; |
| 753 | } |
| 754 | |
Fred Drake | fc16e78 | 1998-03-12 21:03:26 +0000 | [diff] [blame] | 755 | |
| 756 | # These are located down here since they screw up fontlock. -- used to. |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 757 | |
| 758 | sub do_cmd_file{ |
| 759 | # This uses a weird HTML construct to adjust the font to be |
| 760 | # reasonable match that used in the printed form as much as |
| 761 | # possible. The expected behavior is that a browser that doesn't |
| 762 | # understand "<font face=...>" markup will use courier (or whatever |
| 763 | # the font is for <tt>). |
| 764 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 765 | s|$next_pair_pr_rx|\"<tt>\2</tt>\"|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 766 | $_; |
| 767 | } |
| 768 | |
| 769 | sub do_cmd_samp{ |
| 770 | local($_) = @_; |
Fred Drake | c9a4438 | 1998-03-17 06:29:13 +0000 | [diff] [blame] | 771 | s|$next_pair_pr_rx|\"<tt>\2</tt>\"|; |
Fred Drake | 6659c30 | 1998-03-03 22:02:19 +0000 | [diff] [blame] | 772 | $_; |
| 773 | } |
| 774 | |
| 775 | 1; # This must be the last line |