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

Chris@19: $user_title Chris@19:

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

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

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

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

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

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

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

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

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

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

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