cannam@167: ## POST output cannam@167: # Copyright (C) 1993-1995 Ian Jackson. cannam@167: cannam@167: # This file is free software; you can redistribute it and/or modify cannam@167: # it under the terms of the GNU General Public License as published by cannam@167: # the Free Software Foundation; either version 2, or (at your option) cannam@167: # any later version. cannam@167: cannam@167: # It is distributed in the hope that it will be useful, cannam@167: # but WITHOUT ANY WARRANTY; without even the implied warranty of cannam@167: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the cannam@167: # GNU General Public License for more details. cannam@167: cannam@167: # You should have received a copy of the GNU General Public License cannam@167: # along with GNU Emacs; see the file COPYING. If not, write to cannam@167: # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, cannam@167: # Boston, MA 02111-1307, USA. cannam@167: cannam@167: # (Note: I do not consider works produced using these BFNN processing cannam@167: # tools to be derivative works of the tools, so they are NOT covered cannam@167: # by the GPL. However, I would appreciate it if you credited me if cannam@167: # appropriate in any documents you format using BFNN.) cannam@167: cannam@167: sub post_init { cannam@167: open(POST,">$prefix.post"); cannam@167: } cannam@167: cannam@167: sub post_startmajorheading { cannam@167: print POST '='x79,"\n\n"; cannam@167: $post_status= 'h'; cannam@167: &post_text($_[0] ? "Section $_[0]. " : ''); cannam@167: } cannam@167: cannam@167: sub post_startminorheading { cannam@167: print POST '-'x77,"\n\n"; cannam@167: $post_status= 'h'; cannam@167: } cannam@167: cannam@167: sub post_italic { &post_text('*'); } cannam@167: sub post_enditalic { $post_para .= '*'; } cannam@167: cannam@167: sub post_email { &post_text('<'); } sub post_endemail { &post_text('>'); } cannam@167: cannam@167: sub post_ftpon { } sub post_endftpon { } cannam@167: sub post_ftpin { } sub post_endftpin { } cannam@167: sub post_docref { } sub post_enddocref { } cannam@167: sub post_courier { } sub post_endcourier { } cannam@167: sub post_newsgroup { } sub post_endnewsgroup { } cannam@167: sub post_ftpsilent { $post_ignore++; } cannam@167: sub post_endftpsilent { $post_ignore--; } cannam@167: cannam@167: sub post_text { cannam@167: return if $post_ignore; cannam@167: if ($post_status eq '') { cannam@167: $post_status= 'p'; cannam@167: } cannam@167: $post_para .= $_[0]; cannam@167: } cannam@167: cannam@167: sub post_tab { cannam@167: local ($n) = $_[0]-length($post_para); cannam@167: $post_para .= ' 'x$n if $n>0; cannam@167: } cannam@167: cannam@167: sub post_newline { cannam@167: return unless $post_status eq 'p'; cannam@167: &post_writepara; cannam@167: } cannam@167: cannam@167: sub post_writepara { cannam@167: local ($thisline, $thisword, $rest); cannam@167: for (;;) { cannam@167: last unless $post_para =~ m/\S/; cannam@167: $thisline= $post_indentstring; cannam@167: for (;;) { cannam@167: last unless $post_para =~ m/^(\s*\S+)/; cannam@167: unless (length($1) + length($thisline) < 75 || cannam@167: length($thisline) == length($post_indentstring)) { cannam@167: last; cannam@167: } cannam@167: $thisline .= $1; cannam@167: $post_para= $'; cannam@167: } cannam@167: $post_para =~ s/^\s*//; cannam@167: print POST $thisline,"\n"; cannam@167: $post_indentstring= $post_nextindent; cannam@167: last unless length($post_para); cannam@167: } cannam@167: $post_status= ''; $post_para= ''; cannam@167: } cannam@167: cannam@167: sub post_endpara { cannam@167: return unless $post_status eq 'p'; cannam@167: &post_writepara; cannam@167: print POST "\n"; cannam@167: } cannam@167: cannam@167: sub post_endheading { cannam@167: $post_para =~ s/\s*$//; cannam@167: print POST "$post_para\n\n"; cannam@167: $post_status= ''; cannam@167: $post_para= ''; cannam@167: } cannam@167: cannam@167: sub post_endmajorheading { &post_endheading(@_); } cannam@167: sub post_endminorheading { &post_endheading(@_); } cannam@167: cannam@167: sub post_startverbatim { cannam@167: $post_vstatus= $post_status; cannam@167: &post_writepara; cannam@167: } cannam@167: cannam@167: sub post_verbatim { cannam@167: print POST $_[0],"\n"; cannam@167: } cannam@167: cannam@167: sub post_endverbatim { cannam@167: $post_status= $post_vstatus; cannam@167: } cannam@167: cannam@167: sub post_finish { cannam@167: close(POST); cannam@167: } cannam@167: cannam@167: sub post_startindex { $post_status= ''; } cannam@167: sub post_endindex { $post_status= 'p'; } cannam@167: cannam@167: sub post_endindexitem { cannam@167: printf POST " %-11s %-.66s\n",$post_left,$post_para; cannam@167: $post_status= 'p'; cannam@167: $post_para= ''; cannam@167: } cannam@167: cannam@167: sub post_startindexitem { cannam@167: $post_left= $_[1]; cannam@167: } cannam@167: cannam@167: sub post_startindexmainitem { cannam@167: $post_left= $_[1]; cannam@167: print POST "\n" if $post_status eq 'p'; cannam@167: } cannam@167: cannam@167: sub post_startindent { cannam@167: $post_istatus= $post_status; cannam@167: &post_writepara; cannam@167: $post_indentstring= " $post_indentstring"; cannam@167: $post_nextindent= " $post_nextindent"; cannam@167: } cannam@167: cannam@167: sub post_endindent { cannam@167: $post_indentstring =~ s/^ //; cannam@167: $post_nextindent =~ s/^ //; cannam@167: $post_status= $post_istatus; cannam@167: } cannam@167: cannam@167: sub post_startpackedlist { $post_plc=0; } cannam@167: sub post_endpackedlist { &post_newline if !$post_plc; } cannam@167: sub post_packeditem { cannam@167: &post_newline if !$post_plc; cannam@167: &post_tab($post_plc*40+5); cannam@167: $post_plc= !$post_plc; cannam@167: } cannam@167: cannam@167: sub post_startlist { cannam@167: &post_endpara; cannam@167: $post_indentstring= " $post_indentstring"; cannam@167: $post_nextindent= " $post_nextindent"; cannam@167: } cannam@167: cannam@167: sub post_endlist { cannam@167: &post_endpara; cannam@167: $post_indentstring =~ s/^ //; cannam@167: $post_nextindent =~ s/^ //; cannam@167: } cannam@167: cannam@167: sub post_item { cannam@167: &post_newline; cannam@167: $post_indentstring =~ s/ $/* /; cannam@167: } cannam@167: cannam@167: sub post_pageref { cannam@167: &post_text("Q$_[1] \`"); cannam@167: } cannam@167: cannam@167: sub post_endpageref { cannam@167: &post_text("'"); cannam@167: } cannam@167: cannam@167: 1;