Fred Drake | 8ca7006 | 1997-12-08 20:59:54 +0000 | [diff] [blame] | 1 | # myformat.perl by Guido van Rossum <guido@cwi.nl> 25 Jan 1994 -*- perl -*- |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 2 | # |
| 3 | # Extension to LaTeX2HTML for documents using myformat.sty. |
| 4 | # Subroutines of the form do_cmd_<name> here define translations |
| 5 | # for LaTeX commands \<name> defined in the corresponding .sty file. |
| 6 | # |
| 7 | # XXX Not complete: \indexii etc.; \funcitem etc. |
| 8 | |
Fred Drake | 4464022 | 1996-11-11 20:51:09 +0000 | [diff] [blame] | 9 | package main; |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 10 | |
| 11 | # \bcode and \ecode brackets around verbatim |
| 12 | |
| 13 | sub do_cmd_bcode{ @_[0]; } |
| 14 | sub do_cmd_ecode{ @_[0]; } |
| 15 | |
| 16 | # words typeset in a special way (not in HTML though) |
| 17 | |
| 18 | sub do_cmd_ABC{ join('', 'ABC', @_[0]); } |
| 19 | sub do_cmd_UNIX{ join('', 'Unix', @_[0]); } |
| 20 | sub do_cmd_ASCII{ join('', 'ASCII', @_[0]); } |
Fred Drake | bceaf35 | 1998-01-22 16:13:44 +0000 | [diff] [blame] | 21 | sub do_cmd_POSIX{ join('', 'POSIX', @_[0]); } |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 22 | sub do_cmd_C{ join('', 'C', @_[0]); } |
Guido van Rossum | b8b264b | 1994-08-12 13:13:50 +0000 | [diff] [blame] | 23 | sub do_cmd_Cpp{ join('', 'C++', @_[0]); } |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 24 | sub do_cmd_EOF{ join('', 'EOF', @_[0]); } |
Guido van Rossum | d9a26ff | 1997-11-18 15:31:16 +0000 | [diff] [blame] | 25 | sub do_cmd_NULL{ join('', 'NULL', @_[0]); } |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 26 | |
Fred Drake | 3e1fe89 | 1996-11-11 23:03:36 +0000 | [diff] [blame] | 27 | sub do_cmd_e{ local($_) = @_; '\' . $_; } |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 28 | |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 29 | sub do_cmd_optional{ |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 30 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 31 | s/$any_next_pair_pr_rx/<\/var><big>\[<\/big><var>\2<\/var><big>\]<\/big><var>/; |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 32 | $_; |
| 33 | } |
| 34 | |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 35 | sub do_cmd_varvars{ |
| 36 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 37 | s/$any_next_pair_pr_rx/<var>\2<\/var>/; |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 38 | $_; |
| 39 | } |
| 40 | |
Fred Drake | 3e1fe89 | 1996-11-11 23:03:36 +0000 | [diff] [blame] | 41 | # texinfo-like formatting commands: \code{...} etc. |
| 42 | |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 43 | sub do_cmd_code{ |
| 44 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 45 | s/$any_next_pair_pr_rx/<code>\2<\/code>/; |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 46 | $_; |
| 47 | } |
| 48 | |
| 49 | sub do_cmd_sectcode{ &do_cmd_code(@_); } |
Fred Drake | bceaf35 | 1998-01-22 16:13:44 +0000 | [diff] [blame] | 50 | sub do_cmd_module{ &do_cmd_code(@_); } |
| 51 | sub do_cmd_keyword{ &do_cmd_code(@_); } |
| 52 | sub do_cmd_exception{ &do_cmd_code(@_); } |
| 53 | sub do_cmd_class{ &do_cmd_code(@_); } |
| 54 | sub do_cmd_function{ &do_cmd_code(@_); } |
| 55 | sub do_cmd_cfunction{ &do_cmd_code(@_); } |
| 56 | sub do_cmd_constant{ &do_cmd_code(@_); } |
| 57 | sub do_cmd_method{ &do_cmd_code(@_); } |
| 58 | sub do_cmd_email{ &do_cmd_code(@_); } |
| 59 | |
| 60 | sub do_cmd_url{ |
| 61 | # use the URL as both text and hyperlink |
| 62 | local($_) = @_; |
| 63 | s/$any_next_pair_pr_rx/<code><a href="\2">\2<\/a><\/code>/; |
| 64 | $_; |
| 65 | } |
| 66 | |
| 67 | sub do_cmd_manpage{ |
| 68 | # two parameters: \manpage{name}{section} |
| 69 | local($_) = @_; |
| 70 | local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
| 71 | s/$next_pair_pr_rx$any_next_pair_pr_rx3/<em>\2<\/em>(\4)/; |
| 72 | $_; |
| 73 | } |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 74 | |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 75 | sub do_cmd_kbd{ |
| 76 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 77 | s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/; |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 78 | $_; |
| 79 | } |
| 80 | |
| 81 | sub do_cmd_key{ |
| 82 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 83 | s/$any_next_pair_pr_rx/<tt>\2<\/tt>/; |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 84 | $_; |
| 85 | } |
| 86 | |
| 87 | sub do_cmd_var{ |
| 88 | local($_) = @_; |
Fred Drake | bceaf35 | 1998-01-22 16:13:44 +0000 | [diff] [blame] | 89 | s/$any_next_pair_pr_rx/<em>\2<\/em>/; |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 90 | $_; |
| 91 | } |
| 92 | |
| 93 | sub do_cmd_dfn{ |
| 94 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 95 | s/$any_next_pair_pr_rx/<i><dfn>\2<\/dfn><\/i>/; |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 96 | $_; |
| 97 | } |
| 98 | |
| 99 | sub do_cmd_emph{ |
| 100 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 101 | s/$any_next_pair_pr_rx/<em>\2<\/em>/; |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 102 | $_; |
| 103 | } |
| 104 | |
| 105 | sub do_cmd_strong{ |
| 106 | local($_) = @_; |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 107 | s/$any_next_pair_pr_rx/<b>\2<\/b>/; |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 108 | $_; |
| 109 | } |
| 110 | |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 111 | # file and samp are at the end of this file since they screw up fontlock. |
| 112 | |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 113 | # index commands |
| 114 | |
| 115 | sub do_cmd_indexii{ |
| 116 | local($_) = @_; |
| 117 | s/$next_pair_pr_rx//o; |
| 118 | local($br_id1, $str1) = ($1, $2); |
| 119 | s/$next_pair_pr_rx//o; |
| 120 | local($br_id2, $str2) = ($1, $2); |
| 121 | join('', &make_index_entry($br_id1, "$str1 $str2"), |
| 122 | &make_index_entry($br_id2, "$str2, $str1"), $_); |
| 123 | } |
| 124 | |
| 125 | sub do_cmd_indexiii{ |
| 126 | local($_) = @_; |
| 127 | s/$next_pair_pr_rx//o; |
| 128 | local($br_id1, $str1) = ($1, $2); |
| 129 | s/$next_pair_pr_rx//o; |
| 130 | local($br_id2, $str2) = ($1, $2); |
| 131 | s/$next_pair_pr_rx//o; |
| 132 | local($br_id3, $str3) = ($1, $2); |
| 133 | join('', &make_index_entry($br_id1, "$str1 $str2 $str3"), |
| 134 | &make_index_entry($br_id2, "$str2 $str3, $str1"), |
| 135 | &make_index_entry($br_id3, "$str3, $str1 $str2"), |
Fred Drake | 72df9bc | 1997-12-16 21:13:20 +0000 | [diff] [blame] | 136 | $_); |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | sub do_cmd_indexiv{ |
| 140 | local($_) = @_; |
| 141 | s/$next_pair_pr_rx//o; |
| 142 | local($br_id1, $str1) = ($1, $2); |
| 143 | s/$next_pair_pr_rx//o; |
| 144 | local($br_id2, $str2) = ($1, $2); |
| 145 | s/$next_pair_pr_rx//o; |
| 146 | local($br_id3, $str3) = ($1, $2); |
| 147 | s/$next_pair_pr_rx//o; |
| 148 | local($br_id4, $str4) = ($1, $2); |
| 149 | join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"), |
| 150 | &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"), |
| 151 | &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"), |
| 152 | &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"), |
Fred Drake | 72df9bc | 1997-12-16 21:13:20 +0000 | [diff] [blame] | 153 | $_); |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | sub do_cmd_ttindex{ |
| 157 | &do_cmd_index(@_); |
| 158 | } |
| 159 | |
| 160 | sub my_typed_index_helper{ |
| 161 | local($word, $_) = @_; |
| 162 | s/$next_pair_pr_rx//o; |
| 163 | local($br_id, $str) = ($1, $2); |
| 164 | join('', &make_index_entry($br_id, "$str $word"), |
| 165 | &make_index_entry($br_id, "$word, $str"), $_); |
| 166 | } |
| 167 | |
| 168 | sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); } |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 169 | sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); } |
| 170 | sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); } |
| 171 | sub do_cmd_obindex{ &my_typed_index_helper('object', @_); } |
| 172 | |
| 173 | sub my_parword_index_helper{ |
| 174 | local($word, $_) = @_; |
| 175 | s/$next_pair_pr_rx//o; |
| 176 | local($br_id, $str) = ($1, $2); |
Fred Drake | 72df9bc | 1997-12-16 21:13:20 +0000 | [diff] [blame] | 177 | &make_index_entry($br_id, "$str ($word)") . $_; |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Fred Drake | 84818d7 | 1997-12-17 02:59:39 +0000 | [diff] [blame] | 180 | sub make_mod_index_entry { |
| 181 | local($br_id,$str,$define) = @_; |
Fred Drake | ab0b65d | 1998-01-13 04:05:11 +0000 | [diff] [blame] | 182 | local($halfref) = &make_half_href("$CURRENT_FILE#$br_id"); |
| 183 | # If TITLE is not yet available (i.e the \index command is in the title |
| 184 | # of the current section), use $ref_before. |
Fred Drake | 84818d7 | 1997-12-17 02:59:39 +0000 | [diff] [blame] | 185 | $TITLE = $ref_before unless $TITLE; |
| 186 | # Save the reference |
Fred Drake | ab0b65d | 1998-01-13 04:05:11 +0000 | [diff] [blame] | 187 | if ($define eq "DEF") { |
| 188 | local($nstr,$garbage) = split / /, $str, 2; |
| 189 | $Modules{$nstr} .= $halfref; |
| 190 | } |
Fred Drake | 84818d7 | 1997-12-17 02:59:39 +0000 | [diff] [blame] | 191 | $str = &gen_index_id($str, $define); |
Fred Drake | ab0b65d | 1998-01-13 04:05:11 +0000 | [diff] [blame] | 192 | $index{$str} .= $halfref; |
Fred Drake | 8da9e6a | 1997-12-18 14:14:16 +0000 | [diff] [blame] | 193 | "<a name=\"$br_id\">$anchor_invisible_mark<\/a>"; |
Fred Drake | 84818d7 | 1997-12-17 02:59:39 +0000 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | sub my_module_index_helper{ |
| 197 | local($word, $_, $define) = @_; |
| 198 | s/$next_pair_pr_rx//o; |
| 199 | local($br_id, $str) = ($1, $2); |
| 200 | &make_mod_index_entry($br_id, "<tt>$str</tt> ($word module)", |
| 201 | $define) . $_; |
| 202 | } |
| 203 | |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 204 | sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); } |
Fred Drake | 84818d7 | 1997-12-17 02:59:39 +0000 | [diff] [blame] | 205 | sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_, 'DEF'); } |
| 206 | sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_, 'DEF'); } |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 207 | sub do_cmd_bifuncindex{ &my_parword_index_helper('standard module', @_); } |
| 208 | |
Fred Drake | 84818d7 | 1997-12-17 02:59:39 +0000 | [diff] [blame] | 209 | sub do_cmd_refbimodindex{ &my_module_index_helper('built-in', @_, 'REF'); } |
| 210 | sub do_cmd_refstmodindex{ &my_module_index_helper('standard', @_, 'REF'); } |
Fred Drake | 72df9bc | 1997-12-16 21:13:20 +0000 | [diff] [blame] | 211 | |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 212 | sub do_cmd_nodename{ &do_cmd_label(@_); } |
| 213 | |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 214 | sub init_myformat{ |
| 215 | # XXX need some way for this to be called after &initialise; |
| 216 | # <<2>>...<<2>> |
| 217 | $any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C"; |
| 218 | $any_next_pair_rx5 = "$O(\\d+)$C([\\s\\S]*)$O\\5$C"; |
| 219 | $any_next_pair_rx7 = "$O(\\d+)$C([\\s\\S]*)$O\\7$C"; |
| 220 | $any_next_pair_rx9 = "$O(\\d+)$C([\\s\\S]*)$O\\9$C"; |
| 221 | # <#2#>...<#2#> |
| 222 | $any_next_pair_pr_rx_3 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
| 223 | $any_next_pair_pr_rx_5 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\5$CP"; |
| 224 | $any_next_pair_pr_rx_7 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\7$CP"; |
| 225 | $any_next_pair_pr_rx_9 = "$OP(\\d+)$CP([\\s\\S]*)$OP\\9$CP"; |
| 226 | $new_command{"indexsubitem"} = ""; |
| 227 | } |
| 228 | |
| 229 | &init_myformat; |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 230 | |
| 231 | sub get_indexsubitem{ |
| 232 | local($result) = $new_command{"indexsubitem"}; |
| 233 | #print "\nget_indexsubitem ==> $result\n"; |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 234 | $result ? " $result" : ''; |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 235 | } |
| 236 | |
Fred Drake | 84818d7 | 1997-12-17 02:59:39 +0000 | [diff] [blame] | 237 | # similar to make_index_entry(), but includes the string in the result |
| 238 | # instead of the dummy filler. |
| 239 | # |
| 240 | sub make_str_index_entry { |
| 241 | local($br_id,$str) = @_; |
| 242 | # If TITLE is not yet available (i.e the \index command is in the title |
| 243 | # of the current section), use $ref_before. |
| 244 | $TITLE = $ref_before unless $TITLE; |
| 245 | # Save the reference |
| 246 | local($nstr) = &gen_index_id($str, ''); |
| 247 | $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id"); |
| 248 | "<a name=\"$br_id\">$str<\/a>"; |
| 249 | } |
| 250 | |
Fred Drake | 7a7480d | 1996-10-29 15:56:57 +0000 | [diff] [blame] | 251 | sub do_env_cfuncdesc{ |
| 252 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 253 | local($return_type,$function_name,$arg_list,$idx) = ('', '', '', ''); |
Fred Drake | 7a7480d | 1996-10-29 15:56:57 +0000 | [diff] [blame] | 254 | local($cfuncdesc_rx) = |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 255 | "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5"; |
Fred Drake | 7a7480d | 1996-10-29 15:56:57 +0000 | [diff] [blame] | 256 | if (/$cfuncdesc_rx/o) { |
| 257 | $return_type = "$2"; |
| 258 | $function_name = "$4"; |
| 259 | $arg_list = "$6"; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 260 | $idx = &make_str_index_entry($3, |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 261 | "<tt>$function_name</tt>" . &get_indexsubitem); |
Fred Drake | 7a7480d | 1996-10-29 15:56:57 +0000 | [diff] [blame] | 262 | } |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 263 | "<dl><dt>$return_type <b>$idx</b>" . |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 264 | "(<var>$arg_list</var>)\n<dd>$'\n</dl>" |
Fred Drake | 7a7480d | 1996-10-29 15:56:57 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 267 | sub do_env_ctypedesc{ |
| 268 | local($_) = @_; |
| 269 | local($type_name) = (''); |
| 270 | local($cfuncdesc_rx) = |
| 271 | "$next_pair_rx"; |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 272 | if (/$cfuncdesc_rx/o) { |
| 273 | $type_name = "$2"; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 274 | $idx = &make_str_index_entry($1, |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 275 | "<tt>$type_name</tt>" . &get_indexsubitem); |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 276 | } |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 277 | "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>" |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | sub do_env_cvardesc{ |
| 281 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 282 | local($var_type,$var_name,$idx) = ('', '', ''); |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 283 | local($cfuncdesc_rx) = "$next_pair_rx$any_next_pair_rx3"; |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 284 | if (/$cfuncdesc_rx/o) { |
| 285 | $var_type = "$2"; |
| 286 | $var_name = "$4"; |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 287 | $idx = &make_str_index_entry($3,"<tt>$var_name</tt>" . &get_indexsubitem); |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 288 | } |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 289 | "<dl><dt>$var_type <b>$idx</b>\n" . |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 290 | "<dd>$'\n</dl>"; |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 291 | } |
| 292 | |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 293 | sub do_env_funcdesc{ |
| 294 | local($_) = @_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 295 | local($function_name,$arg_list,$idx) = ('', '', ''); |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 296 | local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3"; |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 297 | if (/$funcdesc_rx/o) { |
| 298 | $function_name = "$2"; |
| 299 | $arg_list = "$4"; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 300 | $idx = &make_str_index_entry($3, |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 301 | "<tt>$function_name</tt>" . &get_indexsubitem); |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 302 | } |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 303 | "<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>"; |
| 304 | } |
| 305 | |
| 306 | sub do_cmd_funcline{ |
| 307 | local($_) = @_; |
| 308 | local($funcdesc_rx) = "$next_pair_pr_rx$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
| 309 | |
| 310 | s/$funcdesc_rx//o; |
| 311 | local($br_id, $function_name, $arg_list) = ($3, $2, $4); |
| 312 | local($idx) = &make_str_index_entry($br_id, "<tt>$function_name</tt>"); |
| 313 | |
| 314 | "<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | sub do_env_opcodedesc{ |
| 318 | local($_) = @_; |
| 319 | local($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', ''); |
| 320 | local($opcodedesc_rx) = "$next_pair_rx$any_next_pair_rx3"; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 321 | if (/$opcodedesc_rx/o) { |
| 322 | $opcode_name = "$2"; |
| 323 | $arg_list = "$4"; |
| 324 | $idx = &make_str_index_entry($3, |
| 325 | "<tt>$opcode_name</tt> (byte code instruction)"); |
Fred Drake | 301ad2e | 1998-01-22 18:14:39 +0000 | [diff] [blame] | 326 | $idx =~ s/ \(byte code instruction\)//; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 327 | } |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 328 | $stuff = "<dl><dt><b>$idx</b>"; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 329 | if ($arg_list) { |
Fred Drake | 301ad2e | 1998-01-22 18:14:39 +0000 | [diff] [blame] | 330 | $stuff .= " <var>$arg_list</var>"; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 331 | } |
| 332 | $stuff . "\n<dd>$'\n</dl>"; |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | sub do_env_datadesc{ |
| 336 | local($_) = @_; |
Fred Drake | 301ad2e | 1998-01-22 18:14:39 +0000 | [diff] [blame] | 337 | local($idx) = ''; |
| 338 | if (/$next_pair_rx/o) { |
| 339 | $idx = &make_str_index_entry($1, "<tt>$2</tt>" . &get_indexsubitem); |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 340 | } |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 341 | "<dl><dt><b>$idx</b>\n<dd>$'\n</dl>" |
| 342 | } |
| 343 | |
| 344 | sub do_cmd_dataline{ |
| 345 | local($_) = @_; |
| 346 | |
| 347 | s/$next_pair_pr_rx//o; |
| 348 | local($br_id, $data_name) = ($1, $2); |
| 349 | local($idx) = &make_str_index_entry($br_id, "<tt>$data_name</tt>"); |
| 350 | |
| 351 | "<dt><b>$idx</b>\n<dd>" . $_; |
Fred Drake | c384d75 | 1996-11-11 16:04:35 +0000 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | sub do_env_excdesc{ &do_env_datadesc(@_); } |
| 355 | |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 356 | @col_aligns = ("<td>", "<td>", "<td>"); |
| 357 | |
| 358 | sub setup_column_alignments{ |
| 359 | local($_) = @_; |
| 360 | local($j1,$a1,$a2,$a3,$j4) = split(/[|]/,$_); |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 361 | local($th1,$th2,$th3) = ('<th>', '<th>', '<th>'); |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 362 | $col_aligns[0] = (($a1 eq "c") ? "<td align=center>" : "<td>"); |
| 363 | $col_aligns[1] = (($a2 eq "c") ? "<td align=center>" : "<td>"); |
| 364 | $col_aligns[2] = (($a3 eq "c") ? "<td align=center>" : "<td>"); |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 365 | # return the aligned header start tags; only used for \begin{tableiii?} |
| 366 | $th1 = (($a1 eq "l") ? "<th align=left>" |
| 367 | : ($a1 eq "r" ? "<th align=right>" : "<th>")); |
| 368 | $th2 = (($a2 eq "l") ? "<th align=left>" |
| 369 | : ($a2 eq "r" ? "<th align=right>" : "<th>")); |
| 370 | $th3 = (($a3 eq "l") ? "<th align=left>" |
| 371 | : ($a3 eq "r" ? "<th align=right>" : "<th>")); |
| 372 | ($th1, $th2, $th3); |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | sub do_env_tableii{ |
| 376 | local($_) = @_; |
| 377 | local($font,$h1,$h2) = ('', '', ''); |
| 378 | local($tableiii_rx) = |
| 379 | "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7"; |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 380 | if (/$tableiii_rx/o) { |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 381 | $font = $4; |
| 382 | $h1 = $6; |
| 383 | $h2 = $8; |
| 384 | } |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 385 | local($th1,$th2,$th3) = &setup_column_alignments($2); |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 386 | $globals{"lineifont"} = $font; |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 387 | "<table border align=center>\n <tr>$th1$h1</th>\n $th2$h2</th>$'\n" |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 388 | . "</table>"; |
| 389 | } |
| 390 | |
| 391 | sub do_cmd_lineii{ |
| 392 | local($_) = @_; |
| 393 | s/$next_pair_pr_rx//o; |
| 394 | local($c1) = $2; |
| 395 | s/$next_pair_pr_rx//o; |
| 396 | local($c2) = $2; |
| 397 | local($font) = $globals{"lineifont"}; |
| 398 | local($c1align, $c2align) = @col_aligns[0,1]; |
| 399 | "<tr>$c1align<$font>$c1</$font></td>\n" |
| 400 | . " $c2align$c2</td>$'"; |
| 401 | } |
| 402 | |
| 403 | sub do_env_tableiii{ |
| 404 | local($_) = @_; |
| 405 | local($font,$h1,$h2,$h3) = ('', '', '', ''); |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 406 | |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 407 | local($tableiii_rx) = |
| 408 | "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5$any_next_pair_rx7" |
| 409 | . "$any_next_pair_rx9"; |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 410 | if (/$tableiii_rx/o) { |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 411 | $font = $4; |
| 412 | $h1 = $6; |
| 413 | $h2 = $8; |
| 414 | $h3 = $10; |
| 415 | } |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 416 | local($th1,$th2,$th3) = &setup_column_alignments($2); |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 417 | $globals{"lineifont"} = $font; |
Fred Drake | 1af9e79 | 1998-01-12 23:15:29 +0000 | [diff] [blame] | 418 | "<table border align=center>\n <tr>$th1$h1</th>\n $th2$h2</th>" |
| 419 | . "\n $th3$h3</th>$'\n" |
Fred Drake | 9597daf | 1997-12-22 22:37:34 +0000 | [diff] [blame] | 420 | . "</table>"; |
| 421 | } |
| 422 | |
| 423 | sub do_cmd_lineiii{ |
| 424 | local($_) = @_; |
| 425 | s/$next_pair_pr_rx//o; |
| 426 | local($c1) = $2; |
| 427 | s/$next_pair_pr_rx//o; |
| 428 | local($c2) = $2; |
| 429 | s/$next_pair_pr_rx//o; |
| 430 | local($c3) = $2; |
| 431 | local($font) = $globals{"lineifont"}; |
| 432 | local($c1align, $c2align, $c3align) = @col_aligns; |
| 433 | "<tr>$c1align<$font>$c1</$font></td>\n" |
| 434 | . " $c2align$c2</td>\n" |
| 435 | . " $c3align$c3</td>$'"; |
| 436 | } |
| 437 | |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 438 | sub do_env_seealso{ |
Fred Drake | bceaf35 | 1998-01-22 16:13:44 +0000 | [diff] [blame] | 439 | "<p><b>See Also:</b></p>\n" . @_[0]; |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | sub do_cmd_seemodule{ |
| 443 | local($_) = @_; |
| 444 | local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP"; |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 445 | s/$next_pair_pr_rx$any_next_pair_pr_rx3/<p><code><b>\2<\/b><\/code> (\4)<\/p>/; |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 446 | $_; |
| 447 | } |
| 448 | |
| 449 | sub do_cmd_seetext{ |
Fred Drake | bceaf35 | 1998-01-22 16:13:44 +0000 | [diff] [blame] | 450 | "<p>" . @_[0]; |
Fred Drake | 9dcc5a9 | 1997-10-13 22:04:17 +0000 | [diff] [blame] | 451 | } |
| 452 | |
Fred Drake | 7c4cba8 | 1997-12-03 19:45:08 +0000 | [diff] [blame] | 453 | # These are located down here since they screw up fontlock. |
| 454 | |
| 455 | sub do_cmd_file{ |
| 456 | local($_) = @_; |
| 457 | s/$any_next_pair_pr_rx/`<code>\2<\/code>'/; |
| 458 | $_; |
| 459 | } |
| 460 | |
| 461 | sub do_cmd_samp{ |
| 462 | local($_) = @_; |
| 463 | s/$any_next_pair_pr_rx/`<samp>\2<\/samp>'/; |
| 464 | $_; |
| 465 | } |
| 466 | |
Guido van Rossum | 9e93fb6 | 1994-01-25 20:06:09 +0000 | [diff] [blame] | 467 | 1; # This must be the last line |