blob: 07d64284857403cc67990d53ad146f3a90c89fd4 [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 Drake0d58d441996-12-06 15:09:14 +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($_) = @_;
36 s/$any_next_pair_pr_rx/<VAR>\2<\/VAR>/;
37 $_;
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($_) = @_;
44 s/$any_next_pair_pr_rx/<CODE>\2<\/CODE>/;
45 $_;
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 Drakec384d751996-11-11 16:04:35 +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 Drakec384d751996-11-11 16:04:35 +000058 s/$any_next_pair_pr_rx/<TT>\2<\/TT>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000059 $_;
60}
61
62sub do_cmd_samp{
63 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000064 s/$any_next_pair_pr_rx/`<SAMP>\2<\/SAMP>'/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000065 $_;
66}
67
68sub do_cmd_var{
69 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000070 s/$any_next_pair_pr_rx/<VAR>\2<\/VAR>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000071 $_;
72}
73
74sub do_cmd_file{
75 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000076 s/$any_next_pair_pr_rx/`<CODE>\2<\/CODE>'/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000077 $_;
78}
79
80sub do_cmd_dfn{
81 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000082 s/$any_next_pair_pr_rx/<I><DFN>\2<\/DFN><\/I>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000083 $_;
84}
85
86sub do_cmd_emph{
87 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000088 s/$any_next_pair_pr_rx/<EM>\2<\/EM>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000089 $_;
90}
91
92sub do_cmd_strong{
93 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000094 s/$any_next_pair_pr_rx/<STRONG>\2<\/STRONG>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000095 $_;
96}
97
98# index commands
99
100sub do_cmd_indexii{
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 join('', &make_index_entry($br_id1, "$str1 $str2"),
107 &make_index_entry($br_id2, "$str2, $str1"), $_);
108}
109
110sub do_cmd_indexiii{
111 local($_) = @_;
112 s/$next_pair_pr_rx//o;
113 local($br_id1, $str1) = ($1, $2);
114 s/$next_pair_pr_rx//o;
115 local($br_id2, $str2) = ($1, $2);
116 s/$next_pair_pr_rx//o;
117 local($br_id3, $str3) = ($1, $2);
118 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
119 &make_index_entry($br_id2, "$str2 $str3, $str1"),
120 &make_index_entry($br_id3, "$str3, $str1 $str2"),
121 $_);
122}
123
124sub do_cmd_indexiv{
125 local($_) = @_;
126 s/$next_pair_pr_rx//o;
127 local($br_id1, $str1) = ($1, $2);
128 s/$next_pair_pr_rx//o;
129 local($br_id2, $str2) = ($1, $2);
130 s/$next_pair_pr_rx//o;
131 local($br_id3, $str3) = ($1, $2);
132 s/$next_pair_pr_rx//o;
133 local($br_id4, $str4) = ($1, $2);
134 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
135 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
136 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
137 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
138 $_);
139}
140
141sub do_cmd_ttindex{
142 &do_cmd_index(@_);
143}
144
145sub my_typed_index_helper{
146 local($word, $_) = @_;
147 s/$next_pair_pr_rx//o;
148 local($br_id, $str) = ($1, $2);
149 join('', &make_index_entry($br_id, "$str $word"),
150 &make_index_entry($br_id, "$word, $str"), $_);
151}
152
153sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
154sub do_cmd_kwindex{ &my_typed_index_helper('keyword', @_); }
155sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
156sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
157sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
158
159sub my_parword_index_helper{
160 local($word, $_) = @_;
161 s/$next_pair_pr_rx//o;
162 local($br_id, $str) = ($1, $2);
Fred Drakec384d751996-11-11 16:04:35 +0000163 &make_index_entry($br_id, "$str ($word)");
164 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000165}
166
167sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
168sub do_cmd_bimodindex{ &my_parword_index_helper('built-in module', @_); }
Fred Drakec384d751996-11-11 16:04:35 +0000169sub do_cmd_stmodindex{ &my_parword_index_helper('standard module', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000170sub do_cmd_bifuncindex{ &my_parword_index_helper('standard module', @_); }
171
Fred Drakec384d751996-11-11 16:04:35 +0000172sub do_cmd_nodename{ &do_cmd_label(@_); }
173
174$any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
175$new_command{"indexsubitem"} = "";
176
177sub get_indexsubitem{
178 local($result) = $new_command{"indexsubitem"};
179 #print "\nget_indexsubitem ==> $result\n";
180 $result;
181}
182
Fred Drake7a7480d1996-10-29 15:56:57 +0000183sub do_env_cfuncdesc{
184 local($_) = @_;
185 local($return_type,$function_name,$arg_list) = ('', '', '');
Fred Drake7a7480d1996-10-29 15:56:57 +0000186 local($cfuncdesc_rx) =
Fred Drakec384d751996-11-11 16:04:35 +0000187 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
Fred Drake7a7480d1996-10-29 15:56:57 +0000188 $* = 1;
189 if (/$cfuncdesc_rx/o) {
190 $return_type = "$2";
191 $function_name = "$4";
192 $arg_list = "$6";
Fred Drakec384d751996-11-11 16:04:35 +0000193 &make_index_entry($3,"<TT>$function_name</TT> " . &get_indexsubitem);
Fred Drake7a7480d1996-10-29 15:56:57 +0000194 }
195 $* = 0;
196 "<DL><DT>$return_type <STRONG><A NAME=\"$3\">$function_name</A></STRONG>" .
197 "(<VAR>$arg_list</VAR>)\n<DD>$'\n</DL>"
198}
199
Fred Drake9dcc5a91997-10-13 22:04:17 +0000200sub do_env_ctypedesc{
201 local($_) = @_;
202 local($type_name) = ('');
203 local($cfuncdesc_rx) =
204 "$next_pair_rx";
205 $* = 1;
206 if (/$cfuncdesc_rx/o) {
207 $type_name = "$2";
208 &make_index_entry($1,"<TT>$var_name</TT> " . &get_indexsubitem);
209 }
210 $* = 0;
211 "<DL><DT><STRONG><A NAME=\"$1\">$type_name</A></STRONG>\n<DD>$'\n</DL>"
212}
213
214sub do_env_cvardesc{
215 local($_) = @_;
216 local($var_type,$var_name) = ('', '');
217 local($cfuncdesc_rx) =
218 "$next_pair_rx$any_next_pair_rx3";
219 $* = 1;
220 if (/$cfuncdesc_rx/o) {
221 $var_type = "$2";
222 $var_name = "$4";
223 &make_index_entry($3,"<TT>$var_name</TT> " . &get_indexsubitem);
224 }
225 $* = 0;
226 "<DL><DT>$var_type <STRONG><A NAME=\"$3\">$var_name</A></STRONG>\n" .
227 "<DD>$'\n</DL>"
228}
229
Fred Drakec384d751996-11-11 16:04:35 +0000230sub do_env_funcdesc{
231 local($_) = @_;
232 local($function_name,$arg_list) = ('', '');
233 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
234 $* = 1;
235 if (/$funcdesc_rx/o) {
236 $function_name = "$2";
237 $arg_list = "$4";
238 &make_index_entry($1,"<TT>$function_name</TT> " . &get_indexsubitem);
239 }
240 $* = 0;
241 "<DL><DT><STRONG><A NAME=\"$3\">$function_name</A></STRONG>" .
242 "(<VAR>$arg_list</VAR>)\n<DD>$'\n</DL>"
243}
244
245sub do_env_datadesc{
246 local($_) = @_;
247 local($data_name) = ('', '');
248 local($datadesc_rx) = "$next_pair_rx";
249 $* = 1;
250 if (/$datadesc_rx/o) {
251 $data_name = "$2";
252 &make_index_entry($1,"<TT>$data_name</TT> " . &get_indexsubitem);
253 }
254 $* = 0;
255 "<DL><DT><STRONG><A NAME=\"$3\">$data_name</A></STRONG>" .
256 "\n<DD>$'\n</DL>"
257}
258
259sub do_env_excdesc{ &do_env_datadesc(@_); }
260
Fred Drake9dcc5a91997-10-13 22:04:17 +0000261sub do_env_seealso{
262 local($_) = @_;
263 "<P><B>See Also:</B></P>\n" . $_;
264}
265
266sub do_cmd_seemodule{
267 local($_) = @_;
268 local($any_next_pair_pr_rx3) = "$OP(\\d+)$CP([\\s\\S]*)$OP\\3$CP";
269 s/$next_pair_pr_rx$any_next_pair_pr_rx3/<P><CODE><B>\2<\/B><\/CODE> (\4)<\/P>/;
270 $_;
271}
272
273sub do_cmd_seetext{
274 local($_) = @_;
275 "<p>" . $_;
276}
277
Guido van Rossum9e93fb61994-01-25 20:06:09 +00002781; # This must be the last line