blob: 768cb21fe88028bdcba09308a8e85973bc9a20d9 [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]); }
24
Fred Drake3e1fe891996-11-11 23:03:36 +000025sub do_cmd_e{ local($_) = @_; '&#92;' . $_; }
Guido van Rossum9e93fb61994-01-25 20:06:09 +000026
Fred Drakec384d751996-11-11 16:04:35 +000027sub do_cmd_optional{
Guido van Rossum9e93fb61994-01-25 20:06:09 +000028 local($_) = @_;
Fred Drake0d58d441996-12-06 15:09:14 +000029 s/$any_next_pair_pr_rx/<\/VAR><BIG>\[<\/BIG><VAR>\2<\/VAR><BIG>\]<\/BIG><VAR>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000030 $_;
31}
32
Fred Drakec384d751996-11-11 16:04:35 +000033sub do_cmd_varvars{
34 local($_) = @_;
35 s/$any_next_pair_pr_rx/<VAR>\2<\/VAR>/;
36 $_;
37}
38
Fred Drake3e1fe891996-11-11 23:03:36 +000039# texinfo-like formatting commands: \code{...} etc.
40
Fred Drakec384d751996-11-11 16:04:35 +000041sub do_cmd_code{
42 local($_) = @_;
43 s/$any_next_pair_pr_rx/<CODE>\2<\/CODE>/;
44 $_;
45}
46
47sub do_cmd_sectcode{ &do_cmd_code(@_); }
48
Guido van Rossum9e93fb61994-01-25 20:06:09 +000049sub do_cmd_kbd{
50 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000051 s/$any_next_pair_pr_rx/<KBD>\2<\/KBD>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000052 $_;
53}
54
55sub do_cmd_key{
56 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000057 s/$any_next_pair_pr_rx/<TT>\2<\/TT>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000058 $_;
59}
60
61sub do_cmd_samp{
62 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000063 s/$any_next_pair_pr_rx/`<SAMP>\2<\/SAMP>'/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000064 $_;
65}
66
67sub do_cmd_var{
68 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000069 s/$any_next_pair_pr_rx/<VAR>\2<\/VAR>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000070 $_;
71}
72
73sub do_cmd_file{
74 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000075 s/$any_next_pair_pr_rx/`<CODE>\2<\/CODE>'/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000076 $_;
77}
78
79sub do_cmd_dfn{
80 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000081 s/$any_next_pair_pr_rx/<I><DFN>\2<\/DFN><\/I>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000082 $_;
83}
84
85sub do_cmd_emph{
86 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000087 s/$any_next_pair_pr_rx/<EM>\2<\/EM>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000088 $_;
89}
90
91sub do_cmd_strong{
92 local($_) = @_;
Fred Drakec384d751996-11-11 16:04:35 +000093 s/$any_next_pair_pr_rx/<STRONG>\2<\/STRONG>/;
Guido van Rossum9e93fb61994-01-25 20:06:09 +000094 $_;
95}
96
97# index commands
98
99sub do_cmd_indexii{
100 local($_) = @_;
101 s/$next_pair_pr_rx//o;
102 local($br_id1, $str1) = ($1, $2);
103 s/$next_pair_pr_rx//o;
104 local($br_id2, $str2) = ($1, $2);
105 join('', &make_index_entry($br_id1, "$str1 $str2"),
106 &make_index_entry($br_id2, "$str2, $str1"), $_);
107}
108
109sub do_cmd_indexiii{
110 local($_) = @_;
111 s/$next_pair_pr_rx//o;
112 local($br_id1, $str1) = ($1, $2);
113 s/$next_pair_pr_rx//o;
114 local($br_id2, $str2) = ($1, $2);
115 s/$next_pair_pr_rx//o;
116 local($br_id3, $str3) = ($1, $2);
117 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
118 &make_index_entry($br_id2, "$str2 $str3, $str1"),
119 &make_index_entry($br_id3, "$str3, $str1 $str2"),
120 $_);
121}
122
123sub do_cmd_indexiv{
124 local($_) = @_;
125 s/$next_pair_pr_rx//o;
126 local($br_id1, $str1) = ($1, $2);
127 s/$next_pair_pr_rx//o;
128 local($br_id2, $str2) = ($1, $2);
129 s/$next_pair_pr_rx//o;
130 local($br_id3, $str3) = ($1, $2);
131 s/$next_pair_pr_rx//o;
132 local($br_id4, $str4) = ($1, $2);
133 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
134 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
135 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
136 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
137 $_);
138}
139
140sub do_cmd_ttindex{
141 &do_cmd_index(@_);
142}
143
144sub my_typed_index_helper{
145 local($word, $_) = @_;
146 s/$next_pair_pr_rx//o;
147 local($br_id, $str) = ($1, $2);
148 join('', &make_index_entry($br_id, "$str $word"),
149 &make_index_entry($br_id, "$word, $str"), $_);
150}
151
152sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
153sub do_cmd_kwindex{ &my_typed_index_helper('keyword', @_); }
154sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
155sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
156sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
157
158sub my_parword_index_helper{
159 local($word, $_) = @_;
160 s/$next_pair_pr_rx//o;
161 local($br_id, $str) = ($1, $2);
Fred Drakec384d751996-11-11 16:04:35 +0000162 &make_index_entry($br_id, "$str ($word)");
163 $_;
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000164}
165
166sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
167sub do_cmd_bimodindex{ &my_parword_index_helper('built-in module', @_); }
Fred Drakec384d751996-11-11 16:04:35 +0000168sub do_cmd_stmodindex{ &my_parword_index_helper('standard module', @_); }
Guido van Rossum9e93fb61994-01-25 20:06:09 +0000169sub do_cmd_bifuncindex{ &my_parword_index_helper('standard module', @_); }
170
Fred Drakec384d751996-11-11 16:04:35 +0000171sub do_cmd_nodename{ &do_cmd_label(@_); }
172
173$any_next_pair_rx3 = "$O(\\d+)$C([\\s\\S]*)$O\\3$C";
174$new_command{"indexsubitem"} = "";
175
176sub get_indexsubitem{
177 local($result) = $new_command{"indexsubitem"};
178 #print "\nget_indexsubitem ==> $result\n";
179 $result;
180}
181
Fred Drake7a7480d1996-10-29 15:56:57 +0000182sub do_env_cfuncdesc{
183 local($_) = @_;
184 local($return_type,$function_name,$arg_list) = ('', '', '');
Fred Drake7a7480d1996-10-29 15:56:57 +0000185 local($cfuncdesc_rx) =
Fred Drakec384d751996-11-11 16:04:35 +0000186 "$next_pair_rx$any_next_pair_rx3$any_next_pair_rx5";
Fred Drake7a7480d1996-10-29 15:56:57 +0000187 $* = 1;
188 if (/$cfuncdesc_rx/o) {
189 $return_type = "$2";
190 $function_name = "$4";
191 $arg_list = "$6";
Fred Drakec384d751996-11-11 16:04:35 +0000192 &make_index_entry($3,"<TT>$function_name</TT> " . &get_indexsubitem);
Fred Drake7a7480d1996-10-29 15:56:57 +0000193 }
194 $* = 0;
195 "<DL><DT>$return_type <STRONG><A NAME=\"$3\">$function_name</A></STRONG>" .
196 "(<VAR>$arg_list</VAR>)\n<DD>$'\n</DL>"
197}
198
Fred Drakec384d751996-11-11 16:04:35 +0000199sub do_env_funcdesc{
200 local($_) = @_;
201 local($function_name,$arg_list) = ('', '');
202 local($funcdesc_rx) = "$next_pair_rx$any_next_pair_rx3";
203 $* = 1;
204 if (/$funcdesc_rx/o) {
205 $function_name = "$2";
206 $arg_list = "$4";
207 &make_index_entry($1,"<TT>$function_name</TT> " . &get_indexsubitem);
208 }
209 $* = 0;
210 "<DL><DT><STRONG><A NAME=\"$3\">$function_name</A></STRONG>" .
211 "(<VAR>$arg_list</VAR>)\n<DD>$'\n</DL>"
212}
213
214sub do_env_datadesc{
215 local($_) = @_;
216 local($data_name) = ('', '');
217 local($datadesc_rx) = "$next_pair_rx";
218 $* = 1;
219 if (/$datadesc_rx/o) {
220 $data_name = "$2";
221 &make_index_entry($1,"<TT>$data_name</TT> " . &get_indexsubitem);
222 }
223 $* = 0;
224 "<DL><DT><STRONG><A NAME=\"$3\">$data_name</A></STRONG>" .
225 "\n<DD>$'\n</DL>"
226}
227
228sub do_env_excdesc{ &do_env_datadesc(@_); }
229
Guido van Rossum9e93fb61994-01-25 20:06:09 +00002301; # This must be the last line