home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / docs / linux.faq / linux-fa.sou / linux-fa / m-post.pl < prev    next >
Encoding:
Text File  |  1995-07-05  |  4.5 KB  |  190 lines

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