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