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