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

Chris@42: $user_title Chris@42:

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

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

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

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

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

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

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

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

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

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

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