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