blob: c6cf327588489b7deef93506613fe8b120fd0027 [file] [log] [blame]
Guido van Rossum9e93fb61994-01-25 20:06:09 +00001# myformat.perl by Guido van Rossum <guido@cwi.nl> 25 Jan 1994
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 Drake44640221996-11-11 20:51:09 +00009package main;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000010
11# \bcode and \ecode brackets around verbatim
12
13sub do_cmd_bcode{ @_[0]; }
14sub do_cmd_ecode{ @_[0]; }
15
16# words typeset in a special way (not in HTML though)
17
18sub do_cmd_ABC{ join('', 'ABC', @_[0]); }
19sub do_cmd_UNIX{ join('', 'Unix', @_[0]); }
20sub do_cmd_ASCII{ join('', 'ASCII', @_[0]); }
21sub do_cmd_C{ join('', 'C', @_[0]); }
Guido van Rossumb8b264b1994-08-12 13:13:50 +000022sub do_cmd_Cpp{ join('', 'C++', @_[0]); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000023sub do_cmd_EOF{ join('', 'EOF', @_[0]); }
Guido van Rossumd9a26ff1997-11-18 15:31:16 +000024sub do_cmd_NULL{ join('', 'NULL', @_[0]); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000025
Fred Drake3e1fe891996-11-11 23:03:36 +000026sub do_cmd_e{ local($_) = @_; '&#92;' . $_; }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000027
Fred Drakec384d751996-11-11 16:04:35 +000028sub do_cmd_optional{
Guido van Rossum9e93fb61994-01-25 20:06:09 +000029 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +000030 s/$any_next_pair_pr_rx/<\/var><big>\[<\/big><var>\2<\/var><big>\]<\/big><var>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000031 $_;
32}
33
Fred Drakec384d751996-11-11 16:04:35 +000034sub do_cmd_varvars{
35 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +000036 s/$any_next_pair_pr_rx/<var>\2<\/var>/;
Fred Drakec384d751996-11-11 16:04:35 +000037 $_;
38}
39
Fred Drake3e1fe891996-11-11 23:03:36 +000040# texinfo-like formatting commands: \code{...} etc.
41
Fred Drakec384d751996-11-11 16:04:35 +000042sub do_cmd_code{
43 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +000044 s/$any_next_pair_pr_rx/<code>\2<\/code>/;
Fred Drakec384d751996-11-11 16:04:35 +000045 $_;
46}
47
48sub do_cmd_sectcode{ &do_cmd_code(@_); }
49
Guido van Rossum9e93fb61994-01-25 20:06:09 +000050sub do_cmd_kbd{
51 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +000052 s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000053 $_;
54}
55
56sub do_cmd_key{
57 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +000058 s/$any_next_pair_pr_rx/<tt>\2<\/tt>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000059 $_;
60}
61
62sub do_cmd_var{
63 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +000064 s/$any_next_pair_pr_rx/<var>\2<\/var>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000065 $_;
66}
67
68sub do_cmd_dfn{
69 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +000070 s/$any_next_pair_pr_rx/<i><dfn>\2<\/dfn><\/i>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000071 $_;
72}
73
74sub do_cmd_emph{
75 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +000076 s/$any_next_pair_pr_rx/<em>\2<\/em>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000077 $_;
78}
79
80sub do_cmd_strong{
81 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +000082 s/$any_next_pair_pr_rx/<strong>\2<\/strong>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000083 $_;
84}
85
Fred Drake7c4cba81997-12-03 19:45:08 +000086# file and samp are at the end of this file since they screw up fontlock.
87
Guido van Rossum9e93fb61994-01-25 20:06:09 +000088# index commands
89
90sub 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
100sub 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"),
111 $_);
112}
113
114sub 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"),
128 $_);
129}
130
131sub do_cmd_ttindex{
132 &do_cmd_index(@_);
133}
134
135sub 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
143sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
144sub do_cmd_kwindex{ &my_typed_index_helper('keyword', @_); }
145sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
146sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
147sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
148
149sub my_parword_index_helper{
150 local($word, $_) = @_;
151 s/$next_pair_pr_rx//o;
152 local($br_id, $str) = ($1, $2);
Fred Drakec384d751996-11-11 16:04:35 +0000153 &make_index_entry($br_id, "$str ($word)");
154 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000155}
156
157sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
158sub do_cmd_bimodindex{ &my_parword_index_helper('built-in module', @_); }
Fred Drakec384d751996-11-11 16:04:35 +0000159sub do_cmd_stmodindex{ &my_parword_index_helper('standard module', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000160sub do_cmd_bifuncindex{ &my_parword_index_helper('standard module', @_); }
161
Fred Drakec384d751996-11-11 16:04:35 +0000162sub do_cmd_nodename{ &do_cmd_label(@_); }
163
164$any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
165$new_command{"indexsubitem"} = "";
166
167sub get_indexsubitem{
168 local($result) = $new_command{"indexsubitem"};
169 #print "\nget_indexsubitem ==> $result\n";
170 $result;
171}
172
Fred Drake7a7480d1996-10-29 15:56:57 +0000173sub do_env_cfuncdesc{
174 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000175 local($return_type,$function_name,$arg_list,$idx) = ('', '', '', '');
Fred Drake7a7480d1996-10-29 15:56:57 +0000176 local($cfuncdesc_rx) =
Fred Drakec384d751996-11-11 16:04:35 +0000177 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
Fred Drake7a7480d1996-10-29 15:56:57 +0000178 $* = 1;
179 if (/$cfuncdesc_rx/o) {
180 $return_type = "$2";
181 $function_name = "$4";
182 $arg_list = "$6";
Fred Drake7c4cba81997-12-03 19:45:08 +0000183 $idx = &make_str_index_entry($3,
184 "<tt>$function_name</tt> " . &get_indexsubitem);
Fred Drake7a7480d1996-10-29 15:56:57 +0000185 }
186 $* = 0;
Fred Drake7c4cba81997-12-03 19:45:08 +0000187 "<dl><dt>$return_type <strong>$idx</strong>" .
188 "(<var>$arg_list</var>)\n<dd>$'\n</dl>"
Fred Drake7a7480d1996-10-29 15:56:57 +0000189}
190
Fred Drake9dcc5a91997-10-13 22:04:17 +0000191sub do_env_ctypedesc{
192 local($_) = @_;
193 local($type_name) = ('');
194 local($cfuncdesc_rx) =
195 "$next_pair_rx";
196 $* = 1;
197 if (/$cfuncdesc_rx/o) {
198 $type_name = "$2";
Fred Drake7c4cba81997-12-03 19:45:08 +0000199 $idx = &make_str_index_entry($1,
200 "<tt>$type_name</tt> " . &get_indexsubitem);
Fred Drake9dcc5a91997-10-13 22:04:17 +0000201 }
202 $* = 0;
Fred Drake7c4cba81997-12-03 19:45:08 +0000203 "<dl><dt><strong>$idx</strong>\n<dd>$'\n</dl>"
Fred Drake9dcc5a91997-10-13 22:04:17 +0000204}
205
206sub do_env_cvardesc{
207 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000208 local($var_type,$var_name,$idx) = ('', '', '');
Fred Drake9dcc5a91997-10-13 22:04:17 +0000209 local($cfuncdesc_rx) =
210 "$next_pair_rx$any_next_pair_rx3";
211 $* = 1;
212 if (/$cfuncdesc_rx/o) {
213 $var_type = "$2";
214 $var_name = "$4";
Fred Drake7c4cba81997-12-03 19:45:08 +0000215 $idx = &make_str_index_entry($3,"<tt>$var_name</tt> " . &get_indexsubitem);
Fred Drake9dcc5a91997-10-13 22:04:17 +0000216 }
217 $* = 0;
Fred Drake7c4cba81997-12-03 19:45:08 +0000218 "<dl><dt>$var_type <strong>$idx</strong>\n" .
219 "<dd>$'\n</dl>";
Fred Drake9dcc5a91997-10-13 22:04:17 +0000220}
221
Fred Drakec384d751996-11-11 16:04:35 +0000222sub do_env_funcdesc{
223 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000224 local($function_name,$arg_list,$idx) = ('', '', '');
Fred Drakec384d751996-11-11 16:04:35 +0000225 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
226 $* = 1;
227 if (/$funcdesc_rx/o) {
228 $function_name = "$2";
229 $arg_list = "$4";
Fred Drake7c4cba81997-12-03 19:45:08 +0000230 $idx = &make_str_index_entry($3,
231 "<tt>$function_name</tt> " . &get_indexsubitem);
Fred Drakec384d751996-11-11 16:04:35 +0000232 }
233 $* = 0;
Fred Drake7c4cba81997-12-03 19:45:08 +0000234 "<dl><dt><strong>$idx</strong> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
235}
236
237sub do_env_opcodedesc{
238 local($_) = @_;
239 local($opcode_name,$arg_list,$stuff,$idx) = ('', '', '', '');
240 local($opcodedesc_rx) = "$next_pair_rx$any_next_pair_rx3";
241 $* = 1;
242 if (/$opcodedesc_rx/o) {
243 $opcode_name = "$2";
244 $arg_list = "$4";
245 $idx = &make_str_index_entry($3,
246 "<tt>$opcode_name</tt> (byte code instruction)");
247 }
248 $* = 0;
249 $stuff = "<dl><dt><strong>$idx</strong>";
250 if ($arg_list) {
251 $stuff = "$stuff&nbsp;&nbsp;&nbsp;&nbsp;<var>$arg_list</var>";
252 }
253 $stuff . "\n<dd>$'\n</dl>";
Fred Drakec384d751996-11-11 16:04:35 +0000254}
255
256sub do_env_datadesc{
257 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000258 local($data_name,$idx) = ('', '');
Fred Drakec384d751996-11-11 16:04:35 +0000259 local($datadesc_rx) = "$next_pair_rx";
260 $* = 1;
261 if (/$datadesc_rx/o) {
262 $data_name = "$2";
Fred Drake7c4cba81997-12-03 19:45:08 +0000263 $idx = &make_str_index_entry($3,
264 "<tt>$data_name</tt> " . &get_indexsubitem);
Fred Drakec384d751996-11-11 16:04:35 +0000265 }
266 $* = 0;
Fred Drake7c4cba81997-12-03 19:45:08 +0000267 "<dl><dt><strong>$idx</strong>" .
268 "\n<dd>$'\n</dl>"
Fred Drakec384d751996-11-11 16:04:35 +0000269}
270
271sub do_env_excdesc{ &do_env_datadesc(@_); }
272
Fred Drake9dcc5a91997-10-13 22:04:17 +0000273sub do_env_seealso{
274 local($_) = @_;
Fred Drake7c4cba81997-12-03 19:45:08 +0000275 "<p><b>See Also:</b></p>\n" . $_;
Fred Drake9dcc5a91997-10-13 22:04:17 +0000276}
277
278sub do_cmd_seemodule{
279 local($_) = @_;
280 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
Fred Drake7c4cba81997-12-03 19:45:08 +0000281 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<p><code><b>\2<\/b><\/code> (\4)<\/p>/;
Fred Drake9dcc5a91997-10-13 22:04:17 +0000282 $_;
283}
284
285sub do_cmd_seetext{
286 local($_) = @_;
287 "<p>" . $_;
288}
289
Fred Drake7c4cba81997-12-03 19:45:08 +0000290# These are located down here since they screw up fontlock.
291
292sub do_cmd_file{
293 local($_) = @_;
294 s/$any_next_pair_pr_rx/`<code>\2<\/code>'/;
295 $_;
296}
297
298sub do_cmd_samp{
299 local($_) = @_;
300 s/$any_next_pair_pr_rx/`<samp>\2<\/samp>'/;
301 $_;
302}
303
Guido van Rossum9e93fb61994-01-25 20:06:09 +00003041; # This must be the last line