Chris@10: ## HTML output Chris@10: # Copyright (C) 1993-1995 Ian Jackson. Chris@10: Chris@10: # This file is free software; you can redistribute it and/or modify Chris@10: # it under the terms of the GNU General Public License as published by Chris@10: # the Free Software Foundation; either version 2, or (at your option) Chris@10: # any later version. Chris@10: Chris@10: # It is distributed in the hope that it will be useful, Chris@10: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@10: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@10: # GNU General Public License for more details. Chris@10: Chris@10: # You should have received a copy of the GNU General Public License Chris@10: # along with GNU Emacs; see the file COPYING. If not, write to Chris@10: # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Chris@10: # Boston, MA 02111-1307, USA. Chris@10: Chris@10: # (Note: I do not consider works produced using these BFNN processing Chris@10: # tools to be derivative works of the tools, so they are NOT covered Chris@10: # by the GPL. However, I would appreciate it if you credited me if Chris@10: # appropriate in any documents you format using BFNN.) Chris@10: Chris@10: %saniarray= ('<','lt', '>','gt', '&','amp', '"','quot'); Chris@10: Chris@10: sub html_init { Chris@10: $html_prefix = './'.$prefix; Chris@10: $html_prefix =~ s:^\.//:/:; Chris@10: system('rm','-r',"$html_prefix.html"); Chris@10: system('mkdir',"$html_prefix.html"); Chris@10: open(HTML,">$html_prefix.html/index.html"); Chris@10: print HTML "\n"; Chris@10: print HTML "\n"; Chris@10: $html_needpara= -1; Chris@10: $html_end=''; Chris@10: chop($html_date=`date '+%d %B %Y'`); Chris@10: chop($html_year=`date '+%Y'`); Chris@10: } Chris@10: Chris@10: sub html_startup { Chris@10: print HTML < Chris@10: $user_title Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: Chris@10:

Chris@10: $user_title Chris@10:

Chris@10: END Chris@10: &html_readrefs($_[0]); Chris@10: if (length($user_copyrightref)) { Chris@10: local ($refn) = $qrefn{$user_copyrightref}; Chris@10: if (!length($refn)) { Chris@10: warn "unknown question (copyright) `$user_copyrightref'"; Chris@10: } Chris@10: $refn =~ m/(\d+)\.(\d+)/; Chris@10: local ($s,$n) = ($1,$2); Chris@10: $html_copyrighthref= ($s == $html_sectionn)?'':"section$s.html"; Chris@10: $html_copyrighthref.= "#$qn2ref{$s,$n}"; Chris@10: } Chris@10: } Chris@10: Chris@10: sub html_close { Chris@10: print HTML $html_end,"
\n$user_author\n"; Chris@10: print HTML "- $html_date\n

\n"; Chris@10: print HTML "Extracted from $user_title,\n"; Chris@10: print HTML "" if length($html_copyrighthref); Chris@10: print HTML "Copyright © $html_year $user_copyholder."; Chris@10: print HTML "" if length($html_copyrighthref); Chris@10: print HTML "\n\n"; Chris@10: close(HTML); Chris@10: } Chris@10: Chris@10: sub html_startmajorheading { Chris@10: local ($ref, $this,$next,$back) = @_; Chris@10: local ($nextt,$backt); Chris@10: $this =~ s/^Section /section/; $html_sectionn= $ref; Chris@10: $next =~ s/^Section /section/ && ($nextt= $sn2title{$'}); Chris@10: $back =~ s/^Section /section/ ? ($backt= $sn2title{$'}) : ($back=''); Chris@10: if ($html_sectionn) { Chris@10: &html_close; Chris@10: open(HTML,">$html_prefix.html/$this.html"); Chris@10: print HTML "\n"; Chris@10: print HTML "\n"; Chris@10: $html_end= "
\n"; Chris@10: $html_end.= "Next: $nextt.
\n" Chris@10: if $next; Chris@10: $html_end.= "Back: $backt.
\n" Chris@10: if $back; Chris@10: $html_end.= ""; Chris@10: $html_end.= "Return to contents.

\n"; Chris@10: print HTML < Chris@10: $user_brieftitle - Section $html_sectionn Chris@10: Chris@10: Chris@10: Chris@10: Chris@10: END Chris@10: print HTML "" if $next; Chris@10: print HTML "" if $back; Chris@10: print HTML < Chris@10:

Chris@10: $user_brieftitle - Section $html_sectionn
Chris@10: END Chris@10: $html_needpara= -1; Chris@10: } Chris@10: else { Chris@10: print HTML "\n

\n"; Chris@10: $html_needpara=-1; Chris@10: } Chris@10: } Chris@10: Chris@10: sub html_endmajorheading { Chris@10: print HTML "\n

\n\n"; Chris@10: $html_needpara=-1; Chris@10: } Chris@10: Chris@10: sub html_startminorheading { Chris@10: local ($ref, $this) = @_; Chris@10: $html_needpara=0; Chris@10: $this =~ m/^Question (\d+)\.(\d+)/; Chris@10: local ($s,$n) = ($1,$2); Chris@10: print HTML "\n

\n"; Chris@10: } Chris@10: Chris@10: sub html_endminorheading { Chris@10: print HTML "\n

\n\n"; Chris@10: $html_needpara=-1; Chris@10: } Chris@10: Chris@10: sub html_newsgroup { &arg('newsgroup'); } Chris@10: sub html_endnewsgroup { &endarg('newsgroup'); } Chris@10: sub html_do_newsgroup { Chris@10: print HTML "$_[0]"; Chris@10: } Chris@10: Chris@10: sub html_email { &arg('email'); } Chris@10: sub html_endemail { &endarg('email'); } Chris@10: sub html_do_email { Chris@10: print HTML "$_[0]"; Chris@10: } Chris@10: Chris@10: sub html_courier { print HTML "" ; } Chris@10: sub html_endcourier { print HTML ""; } Chris@10: sub html_italic { print HTML "" ; } Chris@10: sub html_enditalic { print HTML "" ; } Chris@10: Chris@10: sub html_docref { &arg('docref'); } Chris@10: sub html_enddocref { &endarg('docref'); } Chris@10: sub html_do_docref { Chris@10: if (!defined($html_refval{$_[0]})) { Chris@10: warn "undefined HTML reference $_[0]"; Chris@10: $html_refval{$n}='UNDEFINED'; Chris@10: } Chris@10: print HTML ""; Chris@10: &recurse($_[0]); Chris@10: print HTML ""; Chris@10: } Chris@10: Chris@10: sub html_readrefs { Chris@10: local ($p); Chris@10: open(HTMLREFS,"<$_[0]") || (warn("failed to open HTML refs $_[0]: $!"),return); Chris@10: while() { Chris@10: next if m/^\\\s/; Chris@10: s/\s*\n$//; Chris@10: if (s/^\\prefix\s*//) { Chris@10: $p= $'; next; Chris@10: } elsif (s/^\s*(\S.*\S)\s*\\\s*//) { Chris@10: $_=$1; $v=$'; Chris@10: s/\\\\/\\/g; Chris@10: $html_refval{$_}= $p.$v; Chris@10: } else { Chris@10: warn("ununderstood line in HTML refs >$_<"); Chris@10: } Chris@10: } Chris@10: close(HTMLREFS); Chris@10: } Chris@10: Chris@10: sub html_ftpsilent { &arg('ftpsilent'); } Chris@10: sub html_endftpsilent { &endarg('ftpsilent'); } Chris@10: sub html_do_ftpsilent { Chris@10: if ($_[0] =~ m/:/) { Chris@10: $html_ftpsite= $`; Chris@10: $html_ftpdir= $'.'/'; Chris@10: } else { Chris@10: $html_ftpsite= $_[0]; Chris@10: $html_ftpdir= ''; Chris@10: } Chris@10: } Chris@10: Chris@10: sub html_ftpon { &arg('ftpon'); } Chris@10: sub html_endftpon { &endarg('ftpon'); } Chris@10: sub html_do_ftpon { Chris@10: #print STDERR "ftpon($_[0])\n"; Chris@10: $html_ftpsite= $_[0]; $html_ftpdir= ''; Chris@10: print HTML ""; Chris@10: &recurse($_[0]); Chris@10: print HTML ""; Chris@10: } Chris@10: Chris@10: sub html_ftpin { &arg('ftpin'); } Chris@10: sub html_endftpin { &endarg('ftpin'); } Chris@10: sub html_do_ftpin { Chris@10: #print STDERR "ftpin($_[0])\n"; Chris@10: print HTML ""; Chris@10: &recurse($_[0]); Chris@10: print HTML ""; Chris@10: } Chris@10: Chris@10: sub html_text { Chris@10: print HTML "\n

\n" if $html_needpara > 0; Chris@10: $html_needpara=0; Chris@10: $html_stuff= &html_sanitise($_[0]); Chris@10: while ($html_stuff =~ s/^(.{40,70}) //) { Chris@10: print HTML "$1\n"; Chris@10: } Chris@10: print HTML $html_stuff; Chris@10: } Chris@10: Chris@10: sub html_tab { Chris@10: $htmltabignore++ || warn "html tab ignored"; Chris@10: } Chris@10: Chris@10: sub html_newline { print HTML "
\n" ; } Chris@10: sub html_startverbatim { print HTML "

\n"   ;                       }
Chris@10: sub html_verbatim      { print HTML &html_sanitise($_[0]),"\n";         }
Chris@10: sub html_endverbatim   { print HTML "
\n" ; $html_needpara= -1; } Chris@10: Chris@10: sub html_endpara { Chris@10: $html_needpara || $html_needpara++; Chris@10: } Chris@10: Chris@10: sub html_finish { Chris@10: &html_close; Chris@10: } Chris@10: Chris@10: sub html_startindex { Chris@10: print HTML "
\n"; Chris@10: } Chris@10: Chris@10: sub html_startindexitem { Chris@10: local ($ref,$qval) = @_; Chris@10: $qval =~ m/Q(\d+)\.(\d+)/; Chris@10: local ($s,$n) = ($1,$2); Chris@10: print HTML "
  • Q$s.$n. "; Chris@10: $html_indexunhead=''; Chris@10: } Chris@10: Chris@10: sub html_startindexmainitem { Chris@10: local ($ref,$s) = @_; Chris@10: $s =~ m/\d+/; $s= $&; Chris@10: print HTML "

    " if ($s > 1); Chris@10: print HTML "
  • Section $s. "; Chris@10: $html_indexunhead=''; Chris@10: } Chris@10: Chris@10: sub html_endindexitem { Chris@10: print HTML "$html_indexunhead\n"; Chris@10: } Chris@10: Chris@10: sub html_startlist { Chris@10: print HTML "\n"; Chris@10: $html_itemend="
      "; Chris@10: } Chris@10: Chris@10: sub html_endlist { Chris@10: print HTML "$html_itemend\n
    \n"; Chris@10: $html_needpara=-1 Chris@10: } Chris@10: Chris@10: sub html_item { Chris@10: print HTML "$html_itemend\n
  • "; Chris@10: $html_itemend=""; Chris@10: $html_needpara=-1; Chris@10: } Chris@10: Chris@10: sub html_startpackedlist { Chris@10: print HTML "\n"; Chris@10: $html_itemend=""; Chris@10: } Chris@10: Chris@10: sub html_endpackedlist { Chris@10: print HTML "$html_itemend\n\n"; Chris@10: $html_needpara=-1; Chris@10: } Chris@10: Chris@10: sub html_packeditem { Chris@10: print HTML "$html_itemend\n
  • "; Chris@10: $html_itemend=""; Chris@10: $html_needpara=-1; Chris@10: } Chris@10: Chris@10: sub html_startindent { print HTML "
    \n"; } Chris@10: sub html_endindent { print HTML "
    \n"; } Chris@10: Chris@10: sub html_pageref { Chris@10: local ($ref,$sq) = @_; Chris@10: $sq =~ m/(\d+)\.(\d+)/; Chris@10: local ($s,$n) = ($1,$2); Chris@10: print HTML "Q$sq \`"; Chris@10: } Chris@10: Chris@10: sub html_endpageref { Chris@10: print HTML "'"; Chris@10: } Chris@10: Chris@10: sub html_sanitise { Chris@10: local ($in) = @_; Chris@10: local ($out); Chris@10: while ($in =~ m/[<>&"]/) { Chris@10: $out.= $`. '&'. $saniarray{$&}. ';'; Chris@10: $in=$'; Chris@10: } Chris@10: $out.= $in; Chris@10: $out; Chris@10: } Chris@10: Chris@10: 1;