Chris@10
|
1 ## POST output
|
Chris@10
|
2 # Copyright (C) 1993-1995 Ian Jackson.
|
Chris@10
|
3
|
Chris@10
|
4 # This file is free software; you can redistribute it and/or modify
|
Chris@10
|
5 # it under the terms of the GNU General Public License as published by
|
Chris@10
|
6 # the Free Software Foundation; either version 2, or (at your option)
|
Chris@10
|
7 # any later version.
|
Chris@10
|
8
|
Chris@10
|
9 # It is distributed in the hope that it will be useful,
|
Chris@10
|
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@10
|
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@10
|
12 # GNU General Public License for more details.
|
Chris@10
|
13
|
Chris@10
|
14 # You should have received a copy of the GNU General Public License
|
Chris@10
|
15 # along with GNU Emacs; see the file COPYING. If not, write to
|
Chris@10
|
16 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Chris@10
|
17 # Boston, MA 02111-1307, USA.
|
Chris@10
|
18
|
Chris@10
|
19 # (Note: I do not consider works produced using these BFNN processing
|
Chris@10
|
20 # tools to be derivative works of the tools, so they are NOT covered
|
Chris@10
|
21 # by the GPL. However, I would appreciate it if you credited me if
|
Chris@10
|
22 # appropriate in any documents you format using BFNN.)
|
Chris@10
|
23
|
Chris@10
|
24 sub post_init {
|
Chris@10
|
25 open(POST,">$prefix.post");
|
Chris@10
|
26 }
|
Chris@10
|
27
|
Chris@10
|
28 sub post_startmajorheading {
|
Chris@10
|
29 print POST '='x79,"\n\n";
|
Chris@10
|
30 $post_status= 'h';
|
Chris@10
|
31 &post_text($_[0] ? "Section $_[0]. " : '');
|
Chris@10
|
32 }
|
Chris@10
|
33
|
Chris@10
|
34 sub post_startminorheading {
|
Chris@10
|
35 print POST '-'x77,"\n\n";
|
Chris@10
|
36 $post_status= 'h';
|
Chris@10
|
37 }
|
Chris@10
|
38
|
Chris@10
|
39 sub post_italic { &post_text('*'); }
|
Chris@10
|
40 sub post_enditalic { $post_para .= '*'; }
|
Chris@10
|
41
|
Chris@10
|
42 sub post_email { &post_text('<'); } sub post_endemail { &post_text('>'); }
|
Chris@10
|
43
|
Chris@10
|
44 sub post_ftpon { } sub post_endftpon { }
|
Chris@10
|
45 sub post_ftpin { } sub post_endftpin { }
|
Chris@10
|
46 sub post_docref { } sub post_enddocref { }
|
Chris@10
|
47 sub post_courier { } sub post_endcourier { }
|
Chris@10
|
48 sub post_newsgroup { } sub post_endnewsgroup { }
|
Chris@10
|
49 sub post_ftpsilent { $post_ignore++; }
|
Chris@10
|
50 sub post_endftpsilent { $post_ignore--; }
|
Chris@10
|
51
|
Chris@10
|
52 sub post_text {
|
Chris@10
|
53 return if $post_ignore;
|
Chris@10
|
54 if ($post_status eq '') {
|
Chris@10
|
55 $post_status= 'p';
|
Chris@10
|
56 }
|
Chris@10
|
57 $post_para .= $_[0];
|
Chris@10
|
58 }
|
Chris@10
|
59
|
Chris@10
|
60 sub post_tab {
|
Chris@10
|
61 local ($n) = $_[0]-length($post_para);
|
Chris@10
|
62 $post_para .= ' 'x$n if $n>0;
|
Chris@10
|
63 }
|
Chris@10
|
64
|
Chris@10
|
65 sub post_newline {
|
Chris@10
|
66 return unless $post_status eq 'p';
|
Chris@10
|
67 &post_writepara;
|
Chris@10
|
68 }
|
Chris@10
|
69
|
Chris@10
|
70 sub post_writepara {
|
Chris@10
|
71 local ($thisline, $thisword, $rest);
|
Chris@10
|
72 for (;;) {
|
Chris@10
|
73 last unless $post_para =~ m/\S/;
|
Chris@10
|
74 $thisline= $post_indentstring;
|
Chris@10
|
75 for (;;) {
|
Chris@10
|
76 last unless $post_para =~ m/^(\s*\S+)/;
|
Chris@10
|
77 unless (length($1) + length($thisline) < 75 ||
|
Chris@10
|
78 length($thisline) == length($post_indentstring)) {
|
Chris@10
|
79 last;
|
Chris@10
|
80 }
|
Chris@10
|
81 $thisline .= $1;
|
Chris@10
|
82 $post_para= $';
|
Chris@10
|
83 }
|
Chris@10
|
84 $post_para =~ s/^\s*//;
|
Chris@10
|
85 print POST $thisline,"\n";
|
Chris@10
|
86 $post_indentstring= $post_nextindent;
|
Chris@10
|
87 last unless length($post_para);
|
Chris@10
|
88 }
|
Chris@10
|
89 $post_status= ''; $post_para= '';
|
Chris@10
|
90 }
|
Chris@10
|
91
|
Chris@10
|
92 sub post_endpara {
|
Chris@10
|
93 return unless $post_status eq 'p';
|
Chris@10
|
94 &post_writepara;
|
Chris@10
|
95 print POST "\n";
|
Chris@10
|
96 }
|
Chris@10
|
97
|
Chris@10
|
98 sub post_endheading {
|
Chris@10
|
99 $post_para =~ s/\s*$//;
|
Chris@10
|
100 print POST "$post_para\n\n";
|
Chris@10
|
101 $post_status= '';
|
Chris@10
|
102 $post_para= '';
|
Chris@10
|
103 }
|
Chris@10
|
104
|
Chris@10
|
105 sub post_endmajorheading { &post_endheading(@_); }
|
Chris@10
|
106 sub post_endminorheading { &post_endheading(@_); }
|
Chris@10
|
107
|
Chris@10
|
108 sub post_startverbatim {
|
Chris@10
|
109 $post_vstatus= $post_status;
|
Chris@10
|
110 &post_writepara;
|
Chris@10
|
111 }
|
Chris@10
|
112
|
Chris@10
|
113 sub post_verbatim {
|
Chris@10
|
114 print POST $_[0],"\n";
|
Chris@10
|
115 }
|
Chris@10
|
116
|
Chris@10
|
117 sub post_endverbatim {
|
Chris@10
|
118 $post_status= $post_vstatus;
|
Chris@10
|
119 }
|
Chris@10
|
120
|
Chris@10
|
121 sub post_finish {
|
Chris@10
|
122 close(POST);
|
Chris@10
|
123 }
|
Chris@10
|
124
|
Chris@10
|
125 sub post_startindex { $post_status= ''; }
|
Chris@10
|
126 sub post_endindex { $post_status= 'p'; }
|
Chris@10
|
127
|
Chris@10
|
128 sub post_endindexitem {
|
Chris@10
|
129 printf POST " %-11s %-.66s\n",$post_left,$post_para;
|
Chris@10
|
130 $post_status= 'p';
|
Chris@10
|
131 $post_para= '';
|
Chris@10
|
132 }
|
Chris@10
|
133
|
Chris@10
|
134 sub post_startindexitem {
|
Chris@10
|
135 $post_left= $_[1];
|
Chris@10
|
136 }
|
Chris@10
|
137
|
Chris@10
|
138 sub post_startindexmainitem {
|
Chris@10
|
139 $post_left= $_[1];
|
Chris@10
|
140 print POST "\n" if $post_status eq 'p';
|
Chris@10
|
141 }
|
Chris@10
|
142
|
Chris@10
|
143 sub post_startindent {
|
Chris@10
|
144 $post_istatus= $post_status;
|
Chris@10
|
145 &post_writepara;
|
Chris@10
|
146 $post_indentstring= " $post_indentstring";
|
Chris@10
|
147 $post_nextindent= " $post_nextindent";
|
Chris@10
|
148 }
|
Chris@10
|
149
|
Chris@10
|
150 sub post_endindent {
|
Chris@10
|
151 $post_indentstring =~ s/^ //;
|
Chris@10
|
152 $post_nextindent =~ s/^ //;
|
Chris@10
|
153 $post_status= $post_istatus;
|
Chris@10
|
154 }
|
Chris@10
|
155
|
Chris@10
|
156 sub post_startpackedlist { $post_plc=0; }
|
Chris@10
|
157 sub post_endpackedlist { &post_newline if !$post_plc; }
|
Chris@10
|
158 sub post_packeditem {
|
Chris@10
|
159 &post_newline if !$post_plc;
|
Chris@10
|
160 &post_tab($post_plc*40+5);
|
Chris@10
|
161 $post_plc= !$post_plc;
|
Chris@10
|
162 }
|
Chris@10
|
163
|
Chris@10
|
164 sub post_startlist {
|
Chris@10
|
165 &post_endpara;
|
Chris@10
|
166 $post_indentstring= " $post_indentstring";
|
Chris@10
|
167 $post_nextindent= " $post_nextindent";
|
Chris@10
|
168 }
|
Chris@10
|
169
|
Chris@10
|
170 sub post_endlist {
|
Chris@10
|
171 &post_endpara;
|
Chris@10
|
172 $post_indentstring =~ s/^ //;
|
Chris@10
|
173 $post_nextindent =~ s/^ //;
|
Chris@10
|
174 }
|
Chris@10
|
175
|
Chris@10
|
176 sub post_item {
|
Chris@10
|
177 &post_newline;
|
Chris@10
|
178 $post_indentstring =~ s/ $/* /;
|
Chris@10
|
179 }
|
Chris@10
|
180
|
Chris@10
|
181 sub post_pageref {
|
Chris@10
|
182 &post_text("Q$_[1] \`");
|
Chris@10
|
183 }
|
Chris@10
|
184
|
Chris@10
|
185 sub post_endpageref {
|
Chris@10
|
186 &post_text("'");
|
Chris@10
|
187 }
|
Chris@10
|
188
|
Chris@10
|
189 1;
|