improve treatment of multi-line replies, ignore empty lines
[python/dscho.git] / Doc / myformat.perl
blobbfb482144ff43ad3dc41f901462a378f6aea8b02
1 # myformat.perl by Guido van Rossum <guido@cwi.nl> 25 Jan 1994
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.
7 # XXX Not complete: \indexii etc.; \funcitem etc.
9 package main;
11 # \bcode and \ecode brackets around verbatim
13 sub do_cmd_bcode{ @_[0]; }
14 sub do_cmd_ecode{ @_[0]; }
16 # words typeset in a special way (not in HTML though)
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]); }
22 sub do_cmd_Cpp{ join('', 'C++', @_[0]); }
23 sub do_cmd_EOF{ join('', 'EOF', @_[0]); }
25 # texinfo-like formatting commands: \code{...} etc.
27 sub do_cmd_code{
28 local($_) = @_;
29 s/(<#[0-9]+#>)(.*)(\1)/<CODE>\2<\/CODE>/;
30 $_;
33 sub do_cmd_kbd{
34 local($_) = @_;
35 s/(<#[0-9]+#>)(.*)(\1)/<KBD>\2<\/KBD>/;
36 $_;
39 sub do_cmd_key{
40 local($_) = @_;
41 s/(<#[0-9]+#>)(.*)(\1)/<TT>\2<\/TT>/;
42 $_;
45 sub do_cmd_samp{
46 local($_) = @_;
47 s/(<#[0-9]+#>)(.*)(\1)/`<SAMP>\2<\/SAMP>'/;
48 $_;
51 sub do_cmd_var{
52 local($_) = @_;
53 s/(<#[0-9]+#>)(.*)(\1)/<VAR>\2<\/VAR>/;
54 $_;
57 sub do_cmd_file{
58 local($_) = @_;
59 s/(<#[0-9]+#>)(.*)(\1)/`<CODE>\2<\/CODE>'/;
60 $_;
63 sub do_cmd_dfn{
64 local($_) = @_;
65 s/(<#[0-9]+#>)(.*)(\1)/<I><DFN>\2<\/DFN><\/I>/;
66 $_;
69 sub do_cmd_emph{
70 local($_) = @_;
71 s/(<#[0-9]+#>)(.*)(\1)/<EM>\2<\/EM>/;
72 $_;
75 sub do_cmd_strong{
76 local($_) = @_;
77 s/(<#[0-9]+#>)(.*)(\1)/<STRONG>\2<\/STRONG>/;
78 $_;
81 # index commands
83 sub do_cmd_indexii{
84 local($_) = @_;
85 s/$next_pair_pr_rx//o;
86 local($br_id1, $str1) = ($1, $2);
87 s/$next_pair_pr_rx//o;
88 local($br_id2, $str2) = ($1, $2);
89 join('', &make_index_entry($br_id1, "$str1 $str2"),
90 &make_index_entry($br_id2, "$str2, $str1"), $_);
93 sub do_cmd_indexiii{
94 local($_) = @_;
95 s/$next_pair_pr_rx//o;
96 local($br_id1, $str1) = ($1, $2);
97 s/$next_pair_pr_rx//o;
98 local($br_id2, $str2) = ($1, $2);
99 s/$next_pair_pr_rx//o;
100 local($br_id3, $str3) = ($1, $2);
101 join('', &make_index_entry($br_id1, "$str1 $str2 $str3"),
102 &make_index_entry($br_id2, "$str2 $str3, $str1"),
103 &make_index_entry($br_id3, "$str3, $str1 $str2"),
104 $_);
107 sub do_cmd_indexiv{
108 local($_) = @_;
109 s/$next_pair_pr_rx//o;
110 local($br_id1, $str1) = ($1, $2);
111 s/$next_pair_pr_rx//o;
112 local($br_id2, $str2) = ($1, $2);
113 s/$next_pair_pr_rx//o;
114 local($br_id3, $str3) = ($1, $2);
115 s/$next_pair_pr_rx//o;
116 local($br_id4, $str4) = ($1, $2);
117 join('', &make_index_entry($br_id1, "$str1 $str2 $str3 $str4"),
118 &make_index_entry($br_id2, "$str2 $str3 $str4, $str1"),
119 &make_index_entry($br_id3, "$str3 $str4, $str1 $str2"),
120 &make_index_entry($br_id4, "$str4, $str1 $str2 $str3"),
121 $_);
124 sub do_cmd_ttindex{
125 &do_cmd_index(@_);
128 sub my_typed_index_helper{
129 local($word, $_) = @_;
130 s/$next_pair_pr_rx//o;
131 local($br_id, $str) = ($1, $2);
132 join('', &make_index_entry($br_id, "$str $word"),
133 &make_index_entry($br_id, "$word, $str"), $_);
136 sub do_cmd_stindex{ &my_typed_index_helper('statement', @_); }
137 sub do_cmd_kwindex{ &my_typed_index_helper('keyword', @_); }
138 sub do_cmd_opindex{ &my_typed_index_helper('operator', @_); }
139 sub do_cmd_exindex{ &my_typed_index_helper('exception', @_); }
140 sub do_cmd_obindex{ &my_typed_index_helper('object', @_); }
142 sub my_parword_index_helper{
143 local($word, $_) = @_;
144 s/$next_pair_pr_rx//o;
145 local($br_id, $str) = ($1, $2);
146 join('', &make_index_entry($br_id, "$str ($word)"), $_);
149 sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
150 sub do_cmd_bimodindex{ &my_parword_index_helper('built-in module', @_); }
151 sub do_cmd_bifuncindex{ &my_parword_index_helper('standard module', @_); }
153 1; # This must be the last line