233N/A#!/usr/perl5/bin/perl
233N/A'di ';
233N/A'ig 00 ';
233N/A#+##############################################################################
233N/A# #
233N/A# File: texi2html #
233N/A# #
233N/A# Description: Program to transform most Texinfo documents to HTML #
233N/A# #
233N/A#-##############################################################################
233N/A
233N/A# From @(#)texi2html 1.52 01/05/98 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch
233N/A# $Id: texi2html,v 1.5 1999/02/20 20:27:00 karl Exp $
233N/A# This version of texi2html is currently maintained at
233N/A# ftp://ftp.cs.umb.edu/pub/tex/texi2html by kb@cs.umb.edu.
233N/A
233N/A# The man page for this program is included at the end of this file and can be
233N/A# viewed using the command 'nroff -man texi2html'.
233N/A# Please read the copyright at the end of the man page.
233N/A
233N/A#+++############################################################################
233N/A# #
233N/A# Constants #
233N/A# #
233N/A#---############################################################################
233N/A
233N/A$DEBUG_TOC = 1;
233N/A$DEBUG_INDEX = 2;
233N/A$DEBUG_BIB = 4;
233N/A$DEBUG_GLOSS = 8;
233N/A$DEBUG_DEF = 16;
233N/A$DEBUG_HTML = 32;
233N/A$DEBUG_USER = 64;
233N/A
233N/A$BIBRE = '\[[\w\/-]+\]'; # RE for a bibliography reference
233N/A$FILERE = '[\/\w.+-]+'; # RE for a file name
233N/A$VARRE = '[^\s\{\}]+'; # RE for a variable name
233N/A$NODERE = '[^@{}:\'`",]+'; # RE for a node name
233N/A$NODESRE = '[^@{}:\'`"]+'; # RE for a list of node names
233N/A$XREFRE = '[^@{}]+'; # RE for a xref (should use NODERE)
233N/A
233N/A$ERROR = "***"; # prefix for errors and warnings
233N/A$THISVERSION = "1.56k";
233N/A$THISPROG = "texi2html $THISVERSION"; # program name and version
233N/A$HOMEPAGE = "http://wwwinfo.cern.ch/dis/texi2html/"; # program home page
233N/A$TODAY = &pretty_date; # like "20 September 1993"
233N/A$SPLITTAG = "<!-- SPLIT HERE -->\n"; # tag to know where to split
233N/A$PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections
233N/A$html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//EN">';
233N/A
233N/A#
233N/A# language dependent constants
233N/A#
233N/A#$LDC_SEE = 'see';
233N/A#$LDC_SECTION = 'section';
233N/A#$LDC_IN = 'in';
233N/A#$LDC_TOC = 'Table of Contents';
233N/A#$LDC_GOTO = 'Go to the';
233N/A#$LDC_FOOT = 'Footnotes';
233N/A# TODO: @def* shortcuts
233N/A
233N/A#
233N/A# pre-defined indices
233N/A#
233N/A%predefined_index = (
233N/A 'cp', 'c',
233N/A 'fn', 'f',
233N/A 'vr', 'v',
233N/A 'ky', 'k',
233N/A 'pg', 'p',
233N/A 'tp', 't',
233N/A );
233N/A
233N/A#
233N/A# valid indices
233N/A#
233N/A%valid_index = (
233N/A 'c', 1,
233N/A 'f', 1,
233N/A 'v', 1,
233N/A 'k', 1,
233N/A 'p', 1,
233N/A 't', 1,
233N/A );
233N/A
233N/A#
233N/A# texinfo section names to level
233N/A#
233N/A%sec2level = (
233N/A 'top', 0,
233N/A 'chapter', 1,
233N/A 'unnumbered', 1,
233N/A 'majorheading', 1,
233N/A 'chapheading', 1,
233N/A 'appendix', 1,
233N/A 'section', 2,
233N/A 'unnumberedsec', 2,
233N/A 'heading', 2,
233N/A 'appendixsec', 2,
233N/A 'appendixsection', 2,
233N/A 'subsection', 3,
233N/A 'unnumberedsubsec', 3,
233N/A 'subheading', 3,
233N/A 'appendixsubsec', 3,
233N/A 'subsubsection', 4,
233N/A 'unnumberedsubsubsec', 4,
233N/A 'subsubheading', 4,
233N/A 'appendixsubsubsec', 4,
233N/A );
233N/A
233N/A#
233N/A# accent map, TeX command to ISO name
233N/A#
233N/A%accent_map = (
233N/A '"', 'uml',
233N/A '~', 'tilde',
233N/A '^', 'circ',
233N/A '`', 'grave',
233N/A '\'', 'acute',
233N/A );
233N/A
233N/A#
233N/A# texinfo "simple things" (@foo) to HTML ones
233N/A#
233N/A%simple_map = (
233N/A # cf. makeinfo.c
233N/A "*", "<BR>", # HTML+
233N/A " ", " ",
233N/A "\t", " ",
233N/A "-", "&#173;", # soft hyphen
233N/A "\n", "\n",
233N/A "|", "",
233N/A 'tab', '<\/TD><TD>',
233N/A # spacing commands
233N/A ":", "",
233N/A "!", "!",
233N/A "?", "?",
233N/A ".", ".",
233N/A "-", "",
233N/A );
233N/A
233N/A#
233N/A# texinfo "things" (@foo{}) to HTML ones
233N/A#
233N/A%things_map = (
233N/A 'TeX', 'TeX',
233N/A 'br', '<P>', # paragraph break
233N/A 'bullet', '*',
233N/A 'copyright', '(C)',
233N/A 'dots', '...',
233N/A 'equiv', '==',
233N/A 'error', 'error-->',
233N/A 'expansion', '==>',
233N/A 'minus', '-',
233N/A 'point', '-!-',
233N/A 'print', '-|',
233N/A 'result', '=>',
233N/A 'today', $TODAY,
233N/A );
233N/A
233N/A#
233N/A# texinfo styles (@foo{bar}) to HTML ones
233N/A#
233N/A%style_map = (
233N/A 'asis', '',
233N/A 'b', 'B',
233N/A 'cite', 'CITE',
233N/A 'code', 'CODE',
233N/A 'ctrl', '&do_ctrl', # special case
233N/A 'dfn', 'EM', # DFN tag is illegal in the standard
233N/A 'dmn', '', # useless
233N/A 'email', '&do_email', # insert a clickable email address
233N/A 'emph', 'EM',
233N/A 'file', '"TT', # will put quotes, cf. &apply_style
233N/A 'i', 'I',
233N/A 'kbd', 'KBD',
233N/A 'key', 'KBD',
233N/A 'math', 'EM',
233N/A 'r', '', # unsupported
233N/A 'samp', '"SAMP', # will put quotes, cf. &apply_style
233N/A 'sc', '&do_sc', # special case
233N/A 'strong', 'STRONG',
233N/A 't', 'TT',
233N/A 'titlefont', '', # useless
233N/A 'uref', '&do_uref', # insert a clickable URL
233N/A 'url', '&do_url', # insert a clickable URL
233N/A 'var', 'VAR',
233N/A 'w', '', # unsupported
233N/A );
233N/A
233N/A#
233N/A# texinfo format (@foo/@end foo) to HTML ones
233N/A#
233N/A%format_map = (
233N/A 'display', 'PRE',
233N/A 'example', 'PRE',
233N/A 'format', 'PRE',
233N/A 'lisp', 'PRE',
233N/A 'quotation', 'BLOCKQUOTE',
233N/A 'smallexample', 'PRE',
233N/A 'smalllisp', 'PRE',
233N/A # lists
233N/A 'itemize', 'UL',
233N/A 'enumerate', 'OL',
233N/A # poorly supported
233N/A 'flushleft', 'PRE',
233N/A 'flushright', 'PRE',
233N/A );
233N/A
233N/A#
233N/A# texinfo definition shortcuts to real ones
233N/A#
233N/A%def_map = (
233N/A # basic commands
233N/A 'deffn', 0,
233N/A 'defvr', 0,
233N/A 'deftypefn', 0,
233N/A 'deftypevr', 0,
233N/A 'defcv', 0,
233N/A 'defop', 0,
233N/A 'deftp', 0,
233N/A # basic x commands
233N/A 'deffnx', 0,
233N/A 'defvrx', 0,
233N/A 'deftypefnx', 0,
233N/A 'deftypevrx', 0,
233N/A 'defcvx', 0,
233N/A 'defopx', 0,
233N/A 'deftpx', 0,
233N/A # shortcuts
233N/A 'defun', 'deffn Function',
233N/A 'defmac', 'deffn Macro',
233N/A 'defspec', 'deffn {Special Form}',
233N/A 'defvar', 'defvr Variable',
233N/A 'defopt', 'defvr {User Option}',
233N/A 'deftypefun', 'deftypefn Function',
233N/A 'deftypevar', 'deftypevr Variable',
233N/A 'defivar', 'defcv {Instance Variable}',
233N/A 'defmethod', 'defop Method',
233N/A # x shortcuts
233N/A 'defunx', 'deffnx Function',
233N/A 'defmacx', 'deffnx Macro',
233N/A 'defspecx', 'deffnx {Special Form}',
233N/A 'defvarx', 'defvrx Variable',
233N/A 'defoptx', 'defvrx {User Option}',
233N/A 'deftypefunx', 'deftypefnx Function',
233N/A 'deftypevarx', 'deftypevrx Variable',
233N/A 'defivarx', 'defcvx {Instance Variable}',
233N/A 'defmethodx', 'defopx Method',
233N/A );
233N/A
233N/A#
233N/A# things to skip
233N/A#
233N/A%to_skip = (
233N/A # comments
233N/A 'c', 1,
233N/A 'comment', 1,
233N/A 'ifnothtml', 1,
233N/A # useless
233N/A 'detailmenu', 1,
233N/A 'direntry', 1,
233N/A 'contents', 1,
233N/A 'shortcontents', 1,
233N/A 'summarycontents', 1,
233N/A 'footnotestyle', 1,
233N/A 'end ifclear', 1,
233N/A 'end ifset', 1,
233N/A 'titlepage', 1,
233N/A 'end titlepage', 1,
233N/A # unsupported commands (formatting)
233N/A 'afourpaper', 1,
233N/A 'cropmarks', 1,
233N/A 'finalout', 1,
233N/A 'headings', 1,
233N/A 'sp', 1,
233N/A 'need', 1,
233N/A 'page', 1,
233N/A 'setchapternewpage', 1,
233N/A 'everyheading', 1,
233N/A 'everyfooting', 1,
233N/A 'evenheading', 1,
233N/A 'evenfooting', 1,
233N/A 'oddheading', 1,
233N/A 'oddfooting', 1,
233N/A 'smallbook', 1,
233N/A 'vskip', 1,
233N/A 'filbreak', 1,
233N/A 'paragraphindent', 1,
233N/A # unsupported formats
233N/A 'cartouche', 1,
233N/A 'end cartouche', 1,
233N/A 'group', 1,
233N/A 'end group', 1,
233N/A );
233N/A
233N/A#+++############################################################################
233N/A# #
233N/A# Argument parsing, initialisation #
233N/A# #
233N/A#---############################################################################
233N/A
233N/A%value = (); # hold texinfo variables, see also -D
233N/A
233N/A$use_bibliography = 1;
233N/A$use_acc = 0;
233N/A$debug = 0;
233N/A$doctype = '';
233N/A$check = 0;
233N/A$expandinfo = 0;
233N/A$use_glossary = 0;
233N/A$invisible_mark = '';
233N/A$use_iso = 0;
233N/A@include_dirs = ();
233N/A$show_menu = 0;
233N/A$number_sections = 0;
233N/A$split_node = 0;
233N/A$split_chapter = 0;
233N/A$monolithic = 0;
233N/A$verbose = 0;
233N/A$usage = <<EOT;
233N/AThis is $THISPROG
233N/ATo convert a Texinfo file to HMTL: $0 [options] file
233N/A where options can be:
233N/A -expandinfo : use \@ifinfo sections, not \@iftex
233N/A -glossary : handle a glossary
233N/A -invisible name: use 'name' as an invisible anchor
233N/A -Dname : define name like with \@set
233N/A -I dir : search also for files in 'dir'
233N/A -menu : handle menus
233N/A -monolithic : output only one file including ToC
233N/A -number : number sections
233N/A -split_chapter : split on main sections
233N/A -split_node : split on nodes
233N/A -usage : print usage instructions
233N/A -verbose : verbose output
233N/ATo check converted files: $0 -check [-verbose] files
233N/AEOT
233N/A
233N/Awhile (@ARGV && $ARGV[0] =~ /^-/) {
233N/A $_ = shift(@ARGV);
233N/A if (/^-acc$/) { $use_acc = 1; next; }
233N/A if (/^-d(ebug)?(\d+)?$/) { $debug = $2 || shift(@ARGV); next; }
233N/A if (/^-doctype$/) { $doctype = shift(@ARGV); next; }
233N/A if (/^-c(heck)?$/) { $check = 1; next; }
233N/A if (/^-e(xpandinfo)?$/) { $expandinfo = 1; next; }
233N/A if (/^-g(lossary)?$/) { $use_glossary = 1; next; }
233N/A if (/^-i(nvisible)?$/) { $invisible_mark = shift(@ARGV); next; }
233N/A if (/^-iso$/) { $use_iso = 1; next; }
233N/A if (/^-D(.+)?$/) { $value{$1 || shift(@ARGV)} = 1; next; }
233N/A if (/^-I(.+)?$/) { push(@include_dirs, $1 || shift(@ARGV)); next; }
233N/A if (/^-m(enu)?$/) { $show_menu = 1; next; }
233N/A if (/^-mono(lithic)?$/) { $monolithic = 1; next; }
233N/A if (/^-n(umber)?$/) { $number_sections = 1; next; }
233N/A if (/^-s(plit)?_?(n(ode)?|c(hapter)?)?$/) {
233N/A if ($2 =~ /^n/) {
233N/A $split_node = 1;
233N/A } else {
233N/A $split_chapter = 1;
233N/A }
233N/A next;
233N/A }
233N/A if (/^-v(erbose)?$/) { $verbose = 1; next; }
233N/A die $usage;
233N/A}
233N/Aif ($check) {
233N/A die $usage unless @ARGV > 0;
233N/A &check;
233N/A exit;
233N/A}
233N/A
233N/Aif (($split_node || $split_chapter) && $monolithic) {
233N/A warn "Can't use -monolithic with -split, -monolithic ignored.\n";
233N/A $monolithic = 0;
233N/A}
233N/Aif ($expandinfo) {
233N/A $to_skip{'ifinfo'}++;
233N/A $to_skip{'end ifinfo'}++;
233N/A $to_skip{'ifnottex'}++;
233N/A $to_skip{'end ifnottex'}++;
233N/A} else {
233N/A $to_skip{'iftex'}++;
233N/A $to_skip{'end iftex'}++;
233N/A}
233N/A$invisible_mark = '<IMG SRC="invisible.xbm">' if $invisible_mark eq 'xbm';
233N/Adie $usage unless @ARGV == 1;
233N/A$docu = shift(@ARGV);
233N/Aif ($docu =~ /.*\//) {
233N/A chop($docu_dir = $&);
233N/A $docu_name = $';
233N/A} else {
233N/A $docu_dir = '.';
233N/A $docu_name = $docu;
233N/A}
233N/Aunshift(@include_dirs, $docu_dir);
233N/A$docu_name =~ s/\.te?x(i|info)?$//; # basename of the document
233N/A
233N/A$docu_doc = "$docu_name.html"; # document's contents
233N/Aif ($monolithic) {
233N/A $docu_toc = $docu_foot = $docu_doc;
233N/A} else {
233N/A $docu_toc = "${docu_name}_toc.html"; # document's table of contents
233N/A $docu_foot = "${docu_name}_foot.html"; # document's footnotes
233N/A}
233N/A
233N/A#
233N/A# variables
233N/A#
233N/A$value{'html'} = 1; # predefine html (the output format)
233N/A$value{'texi2html'} = $THISVERSION; # predefine texi2html (the translator)
233N/A# _foo: internal to track @foo
233N/Aforeach ('_author', '_title', '_subtitle',
233N/A '_settitle', '_setfilename') {
233N/A $value{$_} = ''; # prevent -w warnings
233N/A}
233N/A%node2sec = (); # node to section name
233N/A%node2href = (); # node to HREF
233N/A%bib2href = (); # bibliography reference to HREF
233N/A%gloss2href = (); # glossary term to HREF
233N/A@sections = (); # list of sections
233N/A%tag2pro = (); # protected sections
233N/A
233N/A#
233N/A# initial indexes
233N/A#
233N/A$bib_num = 0;
233N/A$foot_num = 0;
233N/A$gloss_num = 0;
233N/A$idx_num = 0;
233N/A$sec_num = 0;
233N/A$doc_num = 0;
233N/A$html_num = 0;
233N/A
233N/A#
233N/A# can I use ISO8879 characters? (HTML+)
233N/A#
233N/Aif ($use_iso) {
233N/A $things_map{'bullet'} = "&bull;";
233N/A $things_map{'copyright'} = "&copy;";
233N/A $things_map{'dots'} = "&hellip;";
233N/A $things_map{'equiv'} = "&equiv;";
233N/A $things_map{'expansion'} = "&rarr;";
233N/A $things_map{'point'} = "&lowast;";
233N/A $things_map{'result'} = "&rArr;";
233N/A}
233N/A
233N/A#
233N/A# read texi2html extensions (if any)
233N/A#
233N/A$extensions = 'texi2html.ext'; # extensions in working directory
233N/Aif (-f $extensions) {
233N/A print "# reading extensions from $extensions\n" if $verbose;
233N/A require($extensions);
233N/A}
233N/A($progdir = $0) =~ s/[^\/]+$//;
233N/Aif ($progdir && ($progdir ne './')) {
233N/A $extensions = "${progdir}texi2html.ext"; # extensions in texi2html directory
233N/A if (-f $extensions) {
233N/A print "# reading extensions from $extensions\n" if $verbose;
233N/A require($extensions);
233N/A }
233N/A}
233N/A
233N/Aprint "# reading from $docu\n" if $verbose;
233N/A
233N/A#+++############################################################################
233N/A# #
233N/A# Pass 1: read source, handle command, variable, simple substitution #
233N/A# #
233N/A#---############################################################################
233N/A
233N/A@lines = (); # whole document
233N/A@toc_lines = (); # table of contents
233N/A$toplevel = 0; # top level seen in hierarchy
233N/A$curlevel = 0; # current level in TOC
233N/A$node = ''; # current node name
233N/A$in_table = 0; # am I inside a table
233N/A$table_type = ''; # type of table ('', 'f', 'v', 'multi')
233N/A@tables = (); # nested table support
233N/A$in_bibliography = 0; # am I inside a bibliography
233N/A$in_glossary = 0; # am I inside a glossary
233N/A$in_top = 0; # am I inside the top node
233N/A$in_pre = 0; # am I inside a preformatted section
233N/A$in_list = 0; # am I inside a list
233N/A$in_html = 0; # am I inside an HTML section
233N/A$first_line = 1; # is it the first line
233N/A$dont_html = 0; # don't protect HTML on this line
233N/A$split_num = 0; # split index
233N/A$deferred_ref = ''; # deferred reference for indexes
233N/A@html_stack = (); # HTML elements stack
233N/A$html_element = ''; # current HTML element
233N/A&html_reset;
233N/A
233N/A# build code for simple substitutions
233N/A# the maps used (%simple_map and %things_map) MUST be aware of this
233N/A# watch out for regexps, / and escaped characters!
233N/A$subst_code = '';
233N/Aforeach (keys(%simple_map)) {
233N/A ($re = $_) =~ s/(\W)/\\$1/g; # protect regexp chars
233N/A $subst_code .= "s/\\\@$re/$simple_map{$_}/g;\n";
233N/A}
233N/Aforeach (keys(%things_map)) {
233N/A $subst_code .= "s/\\\@$_\\{\\}/$things_map{$_}/g;\n";
233N/A}
233N/Aif ($use_acc) {
233N/A # accentuated characters
233N/A foreach (keys(%accent_map)) {
233N/A if ($_ eq "`") {
233N/A $subst_code .= "s/$;3";
233N/A } elsif ($_ eq "'") {
233N/A $subst_code .= "s/$;4";
233N/A } else {
233N/A $subst_code .= "s/\\\@\\$_";
233N/A }
233N/A $subst_code .= "([aeiou])/&\${1}$accent_map{$_};/gi;\n";
233N/A }
233N/A}
233N/Aeval("sub simple_substitutions { $subst_code }");
233N/A
233N/A&init_input;
233N/Awhile ($_ = &next_line) {
233N/A #
233N/A # remove \input on the first lines only
233N/A #
233N/A if ($first_line) {
233N/A next if /^\\input/;
233N/A $first_line = 0;
233N/A }
233N/A #
233N/A # parse texinfo tags
233N/A #
233N/A $tag = '';
233N/A $end_tag = '';
233N/A if (/^\s*\@end\s+(\w+)\b/) {
233N/A $end_tag = $1;
233N/A } elsif (/^\s*\@(\w+)\b/) {
233N/A $tag = $1;
233N/A }
233N/A #
233N/A # handle @ifhtml / @end ifhtml
233N/A #
233N/A if ($in_html) {
233N/A if ($end_tag eq 'ifhtml') {
233N/A $in_html = 0;
233N/A } else {
233N/A $tag2pro{$in_html} .= $_;
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'ifhtml') {
233N/A $in_html = $PROTECTTAG . ++$html_num;
233N/A push(@lines, $in_html);
233N/A next;
233N/A }
233N/A #
233N/A # try to skip the line
233N/A #
233N/A if ($end_tag) {
233N/A next if $to_skip{"end $end_tag"};
233N/A } elsif ($tag) {
233N/A next if $to_skip{$tag};
233N/A last if $tag eq 'bye';
233N/A }
233N/A if ($in_top) {
233N/A # parsing the top node
233N/A if ($tag eq 'node' || $tag eq 'include' || $sec2level{$tag}) {
233N/A # no more in top
233N/A $in_top = 0;
233N/A } else {
233N/A # skip it
233N/A next;
233N/A }
233N/A }
233N/A #
233N/A # try to remove inlined comments
233N/A # syntax from tex-mode.el comment-start-skip
233N/A #
233N/A s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/;
233N/A # non-@ substitutions cf. texinfmt.el
233N/A unless ($in_pre) {
233N/A s/``/\"/g;
233N/A s/''/\"/g;
233N/A s/([\w ])---([\w ])/$1--$2/g;
233N/A }
233N/A #
233N/A # analyze the tag
233N/A #
233N/A if ($tag) {
233N/A # skip lines
233N/A &skip_until($tag), next if $tag eq 'ignore';
233N/A if ($expandinfo) {
233N/A &skip_until($tag), next if $tag eq 'iftex';
233N/A } else {
233N/A &skip_until($tag), next if $tag eq 'ifinfo';
233N/A }
233N/A &skip_until($tag), next if $tag eq 'tex';
233N/A # handle special tables
233N/A if ($tag =~ /^(|f|v|multi)table$/) {
233N/A $table_type = $1;
233N/A $tag = 'table';
233N/A }
233N/A # special cases
233N/A if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+top\s*,/i)) {
233N/A $in_top = 1;
233N/A @lines = (); # ignore all lines before top (title page garbage)
233N/A next;
233N/A } elsif ($tag eq 'node') {
233N/A $in_top = 0;
233N/A warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o;
233N/A $_ = &protect_html($_); # if node contains '&' for instance
233N/A s/^\@node\s+//;
233N/A ($node) = split(/,/);
233N/A &normalise_node($node);
233N/A if ($split_node) {
233N/A &next_doc;
233N/A push(@lines, $SPLITTAG) if $split_num++;
233N/A push(@sections, $node);
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'include') {
233N/A if (/^\@include\s+($FILERE)\s*$/o) {
233N/A $file = $1;
233N/A unless (-e $file) {
233N/A foreach $dir (@include_dirs) {
233N/A $file = "$dir/$1";
233N/A last if -e $file;
233N/A }
233N/A }
233N/A if (-e $file) {
233N/A &open($file);
233N/A print "# including $file\n" if $verbose;
233N/A } else {
233N/A warn "$ERROR Can't find $file, skipping";
233N/A }
233N/A } else {
233N/A warn "$ERROR Bad include line: $_";
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'ifclear') {
233N/A if (/^\@ifclear\s+($VARRE)\s*$/o) {
233N/A next unless defined($value{$1});
233N/A &skip_until($tag);
233N/A } else {
233N/A warn "$ERROR Bad ifclear line: $_";
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'ifset') {
233N/A if (/^\@ifset\s+($VARRE)\s*$/o) {
233N/A next if defined($value{$1});
233N/A &skip_until($tag);
233N/A } else {
233N/A warn "$ERROR Bad ifset line: $_";
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'menu') {
233N/A unless ($show_menu) {
233N/A &skip_until($tag);
233N/A next;
233N/A }
233N/A &html_push_if($tag);
233N/A push(@lines, &html_debug("\n", __LINE__));
233N/A } elsif ($format_map{$tag}) {
233N/A $in_pre = 1 if $format_map{$tag} eq 'PRE';
233N/A &html_push_if($format_map{$tag});
233N/A push(@lines, &html_debug("\n", __LINE__));
233N/A $in_list++ if $format_map{$tag} eq 'UL' || $format_map{$tag} eq 'OL' ;
233N/A push(@lines, &debug("<$format_map{$tag}>\n", __LINE__));
233N/A next;
233N/A } elsif ($tag eq 'table') {
233N/A if (/^\s*\@(|f|v|multi)table\s+\@(\w+)/) {
233N/A $in_table = $2;
233N/A unshift(@tables, join($;, $table_type, $in_table));
233N/A if ($table_type eq "multi") {
233N/A push(@lines, &debug("<TABLE BORDER>\n", __LINE__));
233N/A &html_push_if('TABLE');
233N/A } else {
233N/A push(@lines, &debug("<DL COMPACT>\n", __LINE__));
233N/A &html_push_if('DL');
233N/A }
233N/A push(@lines, &html_debug("\n", __LINE__));
233N/A } else {
233N/A warn "$ERROR Bad table line: $_";
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'synindex' || $tag eq 'syncodeindex') {
233N/A if (/^\@$tag\s+(\w)\w\s+(\w)\w\s*$/) {
233N/A eval("*${1}index = *${2}index");
233N/A } else {
233N/A warn "$ERROR Bad syn*index line: $_";
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'sp') {
233N/A push(@lines, &debug("<P>\n", __LINE__));
233N/A next;
233N/A } elsif ($tag eq 'setref') {
233N/A &protect_html; # if setref contains '&' for instance
233N/A if (/^\@$tag\s*{($NODERE)}\s*$/) {
233N/A $setref = $1;
233N/A $setref =~ s/\s+/ /g; # normalize
233N/A $setref =~ s/ $//;
233N/A $node2sec{$setref} = $name;
233N/A $node2href{$setref} = "$docu_doc#$docid";
233N/A } else {
233N/A warn "$ERROR Bad setref line: $_";
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'defindex' || $tag eq 'defcodeindex') {
233N/A if (/^\@$tag\s+(\w\w)\s*$/) {
233N/A $valid_index{$1} = 1;
233N/A } else {
233N/A warn "$ERROR Bad defindex line: $_";
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'lowersections') {
233N/A local ($sec, $level);
233N/A while (($sec, $level) = each %sec2level) {
233N/A $sec2level{$sec} = $level + 1;
233N/A }
233N/A next;
233N/A } elsif ($tag eq 'raisesections') {
233N/A local ($sec, $level);
233N/A while (($sec, $level) = each %sec2level) {
233N/A $sec2level{$sec} = $level - 1;
233N/A }
233N/A next;
233N/A } elsif (defined($def_map{$tag})) {
233N/A if ($def_map{$tag}) {
233N/A s/^\@$tag\s+//;
233N/A $tag = $def_map{$tag};
233N/A $_ = "\@$tag $_";
233N/A $tag =~ s/\s.*//;
233N/A }
233N/A } elsif (defined($user_sub{$tag})) {
233N/A s/^\@$tag\s+//;
233N/A $sub = $user_sub{$tag};
233N/A print "# user $tag = $sub, arg: $_" if $debug & $DEBUG_USER;
233N/A if (defined(&$sub)) {
233N/A chop($_);
233N/A &$sub($_);
233N/A } else {
233N/A warn "$ERROR Bad user sub for $tag: $sub\n";
233N/A }
233N/A next;
233N/A }
233N/A if (defined($def_map{$tag})) {
233N/A s/^\@$tag\s+//;
233N/A if ($tag =~ /x$/) {
233N/A # extra definition line
233N/A $tag = $`;
233N/A $is_extra = 1;
233N/A } else {
233N/A $is_extra = 0;
233N/A }
233N/A while (/\{([^\{\}]*)\}/) {
233N/A # this is a {} construct
233N/A ($before, $contents, $after) = ($`, $1, $');
233N/A # protect spaces
233N/A $contents =~ s/\s+/$;9/g;
233N/A # restore $_ protecting {}
233N/A $_ = "$before$;7$contents$;8$after";
233N/A }
233N/A @args = split(/\s+/, &protect_html($_));
233N/A foreach (@args) {
233N/A s/$;9/ /g; # unprotect spaces
233N/A s/$;7/\{/g; # ... {
233N/A s/$;8/\}/g; # ... }
233N/A }
233N/A $type = shift(@args);
233N/A $type =~ s/^\{(.*)\}$/$1/;
233N/A print "# def ($tag): {$type} ", join(', ', @args), "\n"
233N/A if $debug & $DEBUG_DEF;
233N/A $type .= ':'; # it's nicer like this
233N/A $name = shift(@args);
233N/A $name =~ s/^\{(.*)\}$/$1/;
233N/A if ($is_extra) {
233N/A $_ = &debug("<DT>", __LINE__);
233N/A } else {
233N/A $_ = &debug("<DL>\n<DT>", __LINE__);
233N/A }
233N/A if ($tag eq 'deffn' || $tag eq 'defvr' || $tag eq 'deftp') {
233N/A $_ .= "<U>$type</U> <B>$name</B>";
233N/A $_ .= " <I>@args</I>" if @args;
233N/A } elsif ($tag eq 'deftypefn' || $tag eq 'deftypevr'
233N/A || $tag eq 'defcv' || $tag eq 'defop') {
233N/A $ftype = $name;
233N/A $name = shift(@args);
233N/A $name =~ s/^\{(.*)\}$/$1/;
233N/A $_ .= "<U>$type</U> $ftype <B>$name</B>";
233N/A $_ .= " <I>@args</I>" if @args;
233N/A } else {
233N/A warn "$ERROR Unknown definition type: $tag\n";
233N/A $_ .= "<U>$type</U> <B>$name</B>";
233N/A $_ .= " <I>@args</I>" if @args;
233N/A }
233N/A $_ .= &debug("\n<DD>", __LINE__);
233N/A $name = &unprotect_html($name);
233N/A if ($tag eq 'deffn' || $tag eq 'deftypefn') {
233N/A unshift(@input_spool, "\@findex $name\n");
233N/A } elsif ($tag eq 'defop') {
233N/A unshift(@input_spool, "\@findex $name on $ftype\n");
233N/A } elsif ($tag eq 'defvr' || $tag eq 'deftypevr' || $tag eq 'defcv') {
233N/A unshift(@input_spool, "\@vindex $name\n");
233N/A } else {
233N/A unshift(@input_spool, "\@tindex $name\n");
233N/A }
233N/A $dont_html = 1;
233N/A }
233N/A } elsif ($end_tag) {
233N/A if ($format_map{$end_tag}) {
233N/A $in_pre = 0 if $format_map{$end_tag} eq 'PRE';
233N/A $in_list-- if $format_map{$end_tag} eq 'UL' || $format_map{$end_tag} eq 'OL' ;
233N/A &html_pop_if('LI', 'P');
233N/A &html_pop_if();
233N/A push(@lines, &debug("</$format_map{$end_tag}>\n", __LINE__));
233N/A push(@lines, &html_debug("\n", __LINE__));
233N/A } elsif ($end_tag =~ /^(|f|v|multi)table$/) {
233N/A unless (@tables) {
233N/A warn "$ERROR \@end $end_tag without \@*table\n";
233N/A next;
233N/A }
233N/A ($table_type, $in_table) = split($;, shift(@tables));
233N/A unless ($1 eq $table_type) {
233N/A warn "$ERROR \@end $end_tag without matching \@$end_tag\n";
233N/A next;
233N/A }
233N/A if ($table_type eq "multi") {
233N/A push(@lines, "</TR></TABLE>\n");
233N/A &html_pop_if('TR');
233N/A } else {
233N/A push(@lines, "</DL>\n");
233N/A &html_pop_if('DD');
233N/A }
233N/A &html_pop_if();
233N/A if (@tables) {
233N/A ($table_type, $in_table) = split($;, $tables[0]);
233N/A } else {
233N/A $in_table = 0;
233N/A }
233N/A } elsif (defined($def_map{$end_tag})) {
233N/A push(@lines, &debug("</DL>\n", __LINE__));
233N/A } elsif ($end_tag eq 'menu') {
233N/A &html_pop_if();
233N/A push(@lines, $_); # must keep it for pass 2
233N/A }
233N/A next;
233N/A }
233N/A #
233N/A # misc things
233N/A #
233N/A # protect texi and HTML things
233N/A &protect_texi;
233N/A $_ = &protect_html($_) unless $dont_html;
233N/A $dont_html = 0;
233N/A # substitution (unsupported things)
233N/A s/^\@center\s+//g;
233N/A s/^\@exdent\s+//g;
233N/A s/\@noindent\s+//g;
233N/A s/\@refill\s+//g;
233N/A # other substitutions
233N/A &simple_substitutions;
233N/A s/\@value{($VARRE)}/$value{$1}/eg;
233N/A s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4
233N/A #
233N/A # analyze the tag again
233N/A #
233N/A if ($tag) {
233N/A if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) {
233N/A if (/^\@$tag\s+(.+)$/) {
233N/A $name = $1;
233N/A $name =~ s/\s+$//;
233N/A $level = $sec2level{$tag};
233N/A $name = &update_sec_num($tag, $level) . " $name"
233N/A if $number_sections && $tag !~ /^unnumbered/;
233N/A if ($tag =~ /heading$/) {
233N/A push(@lines, &html_debug("\n", __LINE__));
233N/A if ($html_element ne 'body') {
233N/A # We are in a nice pickle here. We are trying to get a H? heading
233N/A # even though we are not in the body level. So, we convert it to a
233N/A # nice, bold, line by itself.
233N/A $_ = &debug("\n\n<P><STRONG>$name</STRONG>\n\n", __LINE__);
233N/A } else {
233N/A $_ = &debug("<H$level>$name</H$level>\n", __LINE__);
233N/A &html_push_if('body');
233N/A }
233N/A print "# heading, section $name, level $level\n"
233N/A if $debug & $DEBUG_TOC;
233N/A } else {
233N/A if ($split_chapter) {
233N/A unless ($toplevel) {
233N/A # first time we see a "section"
233N/A unless ($level == 1) {
233N/A warn "$ERROR The first section found is not of level 1: $_";
233N/A warn "$ERROR I'll split on sections of level $level...\n";
233N/A }
233N/A $toplevel = $level;
233N/A }
233N/A if ($level == $toplevel) {
233N/A &next_doc;
233N/A push(@lines, $SPLITTAG) if $split_num++;
233N/A push(@sections, $name);
233N/A }
233N/A }
233N/A $sec_num++;
233N/A $docid = "SEC$sec_num";
233N/A $tocid = "TOC$sec_num";
233N/A # check biblio and glossary
233N/A $in_bibliography = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i);
233N/A $in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i);
233N/A # check node
233N/A if ($node) {
233N/A if ($node2sec{$node}) {
233N/A warn "$ERROR Duplicate node found: $node\n";
233N/A } else {
233N/A $node2sec{$node} = $name;
233N/A $node2href{$node} = "$docu_doc#$docid";
233N/A print "# node $node, section $name, level $level\n"
233N/A if $debug & $DEBUG_TOC;
233N/A }
233N/A $node = '';
233N/A } else {
233N/A print "# no node, section $name, level $level\n"
233N/A if $debug & $DEBUG_TOC;
233N/A }
233N/A # update TOC
233N/A while ($level > $curlevel) {
233N/A $curlevel++;
233N/A push(@toc_lines, "<UL>\n");
233N/A }
233N/A while ($level < $curlevel) {
233N/A $curlevel--;
233N/A push(@toc_lines, "</UL>\n");
233N/A }
233N/A $_ = "<LI>" . &anchor($tocid, "$docu_doc#$docid", $name, 1);
233N/A push(@toc_lines, &substitute_style($_));
233N/A # update DOC
233N/A push(@lines, &html_debug("\n", __LINE__));
233N/A &html_reset;
233N/A $_ = "<H$level>".&anchor($docid, "$docu_toc#$tocid", $name)."</H$level>\n";
233N/A $_ = &debug($_, __LINE__);
233N/A push(@lines, &html_debug("\n", __LINE__));
233N/A }
233N/A # update DOC
233N/A foreach $line (split(/\n+/, $_)) {
233N/A push(@lines, "$line\n");
233N/A }
233N/A next;
233N/A } else {
233N/A warn "$ERROR Bad section line: $_";
233N/A }
233N/A } else {
233N/A # track variables
233N/A $value{$1} = $2, next if /^\@set\s+($VARRE)\s+(.*)$/o;
233N/A delete $value{$1}, next if /^\@clear\s+($VARRE)\s*$/o;
233N/A # store things
233N/A $value{'_setfilename'} = $1, next if /^\@setfilename\s+(.*)$/;
233N/A $value{'_settitle'} = $1, next if /^\@settitle\s+(.*)$/;
233N/A $value{'_author'} .= "$1\n", next if /^\@author\s+(.*)$/;
233N/A $value{'_subtitle'} .= "$1\n", next if /^\@subtitle\s+(.*)$/;
233N/A $value{'_title'} .= "$1\n", next if /^\@title\s+(.*)$/;
233N/A # index
233N/A if (/^\@(..?)index\s+/) {
233N/A unless ($valid_index{$1}) {
233N/A warn "$ERROR Undefined index command: $_";
233N/A next;
233N/A }
233N/A $id = 'IDX' . ++$idx_num;
233N/A $index = $1 . 'index';
233N/A $what = &substitute_style($');
233N/A $what =~ s/\s+$//;
233N/A print "# found $index for '$what' id $id\n"
233N/A if $debug & $DEBUG_INDEX;
233N/A eval(<<EOC);
233N/A if (defined(\$$index\{\$what\})) {
233N/A \$$index\{\$what\} .= "$;$docu_doc#$id";
233N/A } else {
233N/A \$$index\{\$what\} = "$docu_doc#$id";
233N/A }
233N/AEOC
233N/A #
233N/A # dirty hack to see if I can put an invisible anchor...
233N/A #
233N/A if ($html_element eq 'P' ||
233N/A $html_element eq 'LI' ||
233N/A $html_element eq 'DT' ||
233N/A $html_element eq 'DD' ||
233N/A $html_element eq 'ADDRESS' ||
233N/A $html_element eq 'B' ||
233N/A $html_element eq 'BLOCKQUOTE' ||
233N/A $html_element eq 'PRE' ||
233N/A $html_element eq 'SAMP') {
233N/A push(@lines, &anchor($id, '', $invisible_mark, !$in_pre));
233N/A } elsif ($html_element eq 'body') {
233N/A push(@lines, &debug("<P>\n", __LINE__));
233N/A push(@lines, &anchor($id, '', $invisible_mark, !$in_pre));
233N/A &html_push('P');
233N/A } elsif ($html_element eq 'DL' ||
233N/A $html_element eq 'UL' ||
233N/A $html_element eq 'OL' ) {
233N/A $deferred_ref .= &anchor($id, '', $invisible_mark, !$in_pre) . " ";
233N/A }
233N/A next;
233N/A }
233N/A # list item
233N/A if (/^\s*\@itemx?\s+/) {
233N/A $what = $';
233N/A $what =~ s/\s+$//;
233N/A if ($in_bibliography && $use_bibliography) {
233N/A if ($what =~ /^$BIBRE$/o) {
233N/A $id = 'BIB' . ++$bib_num;
233N/A $bib2href{$what} = "$docu_doc#$id";
233N/A print "# found bibliography for '$what' id $id\n"
233N/A if $debug & $DEBUG_BIB;
233N/A $what = &anchor($id, '', $what);
233N/A }
233N/A } elsif ($in_glossary && $use_glossary) {
233N/A $id = 'GLOSS' . ++$gloss_num;
233N/A $entry = $what;
233N/A $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/;
233N/A $gloss2href{$entry} = "$docu_doc#$id";
233N/A print "# found glossary for '$entry' id $id\n"
233N/A if $debug & $DEBUG_GLOSS;
233N/A $what = &anchor($id, '', $what);
233N/A }
233N/A &html_pop_if('P');
233N/A if ($html_element eq 'DL' || $html_element eq 'DD') {
233N/A if ($things_map{$in_table} && !$what) {
233N/A # special case to allow @table @bullet for instance
233N/A push(@lines, &debug("<DT>$things_map{$in_table}\n", __LINE__));
233N/A } else {
233N/A push(@lines, &debug("<DT>\@$in_table\{$what\}\n", __LINE__));
233N/A }
233N/A push(@lines, "<DD>");
233N/A &html_push('DD') unless $html_element eq 'DD';
233N/A if ($table_type) { # add also an index
233N/A unshift(@input_spool, "\@${table_type}index $what\n");
233N/A }
233N/A } elsif ($html_element eq 'TABLE') {
233N/A push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__));
233N/A &html_push('TR');
233N/A } elsif ($html_element eq 'TR') {
233N/A push(@lines, &debug("</TR>\n", __LINE__));
233N/A push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__));
233N/A } else {
233N/A push(@lines, &debug("<LI>$what\n", __LINE__));
233N/A &html_push('LI') unless $html_element eq 'LI';
233N/A }
233N/A push(@lines, &html_debug("\n", __LINE__));
233N/A if ($deferred_ref) {
233N/A push(@lines, &debug("$deferred_ref\n", __LINE__));
233N/A $deferred_ref = '';
233N/A }
233N/A next;
233N/A } elsif (/^\@tab\s+(.*)$/) {
233N/A push(@lines, "<TD>$1</TD>\n");
233N/A next;
233N/A }
233N/A }
233N/A }
233N/A # paragraph separator
233N/A if ($_ eq "\n") {
233N/A next if $#lines >= 0 && $lines[$#lines] eq "\n";
233N/A if ($html_element eq 'P') {
233N/A push(@lines, "\n");
233N/A $_ = &debug("\n", __LINE__);
233N/A &html_pop;
233N/A }
233N/A } elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE') {
233N/A push(@lines, "<P>\n");
233N/A &html_push('P');
233N/A $_ = &debug($_, __LINE__);
233N/A }
233N/A # otherwise
233N/A push(@lines, $_);
233N/A}
233N/A
233N/A# finish TOC
233N/A$level = 0;
233N/Awhile ($level < $curlevel) {
233N/A $curlevel--;
233N/A push(@toc_lines, "</UL>\n");
233N/A}
233N/A
233N/Aprint "# end of pass 1\n" if $verbose;
233N/A
233N/A#+++############################################################################
233N/A# #
233N/A# Pass 2/3: handle style, menu, index, cross-reference #
233N/A# #
233N/A#---############################################################################
233N/A
233N/A@lines2 = (); # whole document (2nd pass)
233N/A@lines3 = (); # whole document (3rd pass)
233N/A$in_menu = 0; # am I inside a menu
233N/A
233N/Awhile (@lines) {
233N/A $_ = shift(@lines);
233N/A #
233N/A # special case (protected sections)
233N/A #
233N/A if (/^$PROTECTTAG/o) {
233N/A push(@lines2, $_);
233N/A next;
233N/A }
233N/A #
233N/A # menu
233N/A #
233N/A $in_menu = 1, push(@lines2, &debug("<UL>\n", __LINE__)), next if /^\@menu\b/;
233N/A $in_menu = 0, push(@lines2, &debug("</UL>\n", __LINE__)), next if /^\@end\s+menu\b/;
233N/A if ($in_menu) {
233N/A if (/^\*\s+($NODERE)::/o) {
233N/A $descr = $';
233N/A chop($descr);
233N/A &menu_entry($1, $1, $descr);
233N/A } elsif (/^\*\s+(.+):\s+([^\t,\.\n]+)[\t,\.\n]/) {
233N/A $descr = $';
233N/A chop($descr);
233N/A &menu_entry($1, $2, $descr);
233N/A } elsif (/^\*/) {
233N/A warn "$ERROR Bad menu line: $_";
233N/A } else { # description continued?
233N/A push(@lines2, $_);
233N/A }
233N/A next;
233N/A }
233N/A #
233N/A # printindex
233N/A #
233N/A if (/^\@printindex\s+(\w\w)\b/) {
233N/A local($index, *ary, @keys, $key, $letter, $last_letter, @refs);
233N/A if ($predefined_index{$1}) {
233N/A $index = $predefined_index{$1} . 'index';
233N/A } else {
233N/A $index = $1 . 'index';
233N/A }
233N/A eval("*ary = *$index");
233N/A @keys = keys(%ary);
233N/A foreach $key (@keys) {
233N/A $_ = $key;
233N/A 1 while s/<(\w+)>\`(.*)\'<\/\1>/$2/; # remove HTML tags with quotes
233N/A 1 while s/<(\w+)>(.*)<\/\1>/$2/; # remove HTML tags
233N/A $_ = &unprotect_html($_);
233N/A &unprotect_texi;
233N/A tr/A-Z/a-z/; # lowercase
233N/A $key2alpha{$key} = $_;
233N/A print "# index $key sorted as $_\n"
233N/A if $key ne $_ && $debug & $DEBUG_INDEX;
233N/A }
233N/A push(@lines2, "Jump to:\n");
233N/A $last_letter = undef;
233N/A foreach $key (sort byalpha @keys) {
233N/A $letter = substr($key2alpha{$key}, 0, 1);
233N/A $letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;;
233N/A if (!defined($last_letter) || $letter ne $last_letter) {
233N/A push(@lines2, "-\n") if defined($last_letter);
233N/A push(@lines2, "<A HREF=\"#$index\_$letter\">" . &protect_html($letter) . "</A>\n");
233N/A $last_letter = $letter;
233N/A }
233N/A }
233N/A push(@lines2, "<P>\n");
233N/A $last_letter = undef;
233N/A foreach $key (sort byalpha @keys) {
233N/A $letter = substr($key2alpha{$key}, 0, 1);
233N/A $letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;;
233N/A if (!defined($last_letter) || $letter ne $last_letter) {
233N/A push(@lines2, "</DIR>\n") if defined($last_letter);
233N/A push(@lines2, "<H2><A NAME=\"$index\_$letter\">" . &protect_html($letter) . "</A></H2>\n");
233N/A push(@lines2, "<DIR>\n");
233N/A $last_letter = $letter;
233N/A }
233N/A @refs = ();
233N/A foreach (split(/$;/, $ary{$key})) {
233N/A push(@refs, &anchor('', $_, $key, 0));
233N/A }
233N/A push(@lines2, "<LI>" . join(", ", @refs) . "\n");
233N/A }
233N/A push(@lines2, "</DIR>\n") if defined($last_letter);
233N/A next;
233N/A }
233N/A #
233N/A # simple style substitutions
233N/A #
233N/A $_ = &substitute_style($_);
233N/A #
233N/A # xref
233N/A #
233N/A while (/\@(x|px|info|)ref{($XREFRE)(}?)/o) {
233N/A # note: Texinfo may accept other characters
233N/A ($type, $nodes, $full) = ($1, $2, $3);
233N/A ($before, $after) = ($`, $');
233N/A if (! $full && $after) {
233N/A warn "$ERROR Bad xref (no ending } on line): $_";
233N/A $_ = "$before$;0${type}ref\{$nodes$after";
233N/A next; # while xref
233N/A }
233N/A if ($type eq 'x') {
233N/A $type = 'See ';
233N/A } elsif ($type eq 'px') {
233N/A $type = 'see ';
233N/A } elsif ($type eq 'info') {
233N/A $type = 'See Info';
233N/A } else {
233N/A $type = '';
233N/A }
233N/A unless ($full) {
233N/A $next = shift(@lines);
233N/A $next = &substitute_style($next);
233N/A chop($nodes); # remove final newline
233N/A if ($next =~ /\}/) { # split on 2 lines
233N/A $nodes .= " $`";
233N/A $after = $';
233N/A } else {
233N/A $nodes .= " $next";
233N/A $next = shift(@lines);
233N/A $next = &substitute_style($next);
233N/A chop($nodes);
233N/A if ($next =~ /\}/) { # split on 3 lines
233N/A $nodes .= " $`";
233N/A $after = $';
233N/A } else {
233N/A warn "$ERROR Bad xref (no ending }): $_";
233N/A $_ = "$before$;0xref\{$nodes$after";
233N/A unshift(@lines, $next);
233N/A next; # while xref
233N/A }
233N/A }
233N/A }
233N/A $nodes =~ s/\s+/ /g; # remove useless spaces
233N/A @args = split(/\s*,\s*/, $nodes);
233N/A $node = $args[0]; # the node is always the first arg
233N/A &normalise_node($node);
233N/A $sec = $node2sec{$node};
233N/A if (@args == 5) { # reference to another manual
233N/A $sec = $args[2] || $node;
233N/A $man = $args[4] || $args[3];
233N/A $_ = "${before}${type}section `$sec' in \@cite{$man}$after";
233N/A } elsif ($type =~ /Info/) { # inforef
233N/A warn "$ERROR Wrong number of arguments: $_" unless @args == 3;
233N/A ($nn, $_, $in) = @args;
233N/A $_ = "${before}${type} file `$in', node `$nn'$after";
233N/A } elsif ($sec) {
233N/A $href = $node2href{$node};
233N/A $_ = "${before}${type}section " . &anchor('', $href, $sec) . $after;
233N/A } else {
233N/A warn "$ERROR Undefined node ($node): $_";
233N/A $_ = "$before$;0xref{$nodes}$after";
233N/A }
233N/A }
233N/A
233N/A if (/^\@image\s*{/) {
233N/A s/\@image\s*{//;
233N/A my (@args) = split (/,/);
233N/A my $base = $args[0];
233N/A my $image;
233N/A if (-r "$base.jpg") {
233N/A $image = "$base.jpg";
233N/A } elsif (-r "$base.png") {
233N/A $image = "$base.png";
233N/A } elsif (-r "$base.gif") {
233N/A $image = "$base.gif";
233N/A } else {
233N/A warn "$ERROR no image file for $base: $_";
233N/A }
233N/A $_ = "<IMG SRC=\"$image\" ALT=\"$base\">";
233N/A }
233N/A
233N/A #
233N/A # try to guess bibliography references or glossary terms
233N/A #
233N/A unless (/^<H\d><A NAME=\"SEC\d/) {
233N/A if ($use_bibliography) {
233N/A $done = '';
233N/A while (/$BIBRE/o) {
233N/A ($pre, $what, $post) = ($`, $&, $');
233N/A $href = $bib2href{$what};
233N/A if (defined($href) && $post !~ /^[^<]*<\/A>/) {
233N/A $done .= $pre . &anchor('', $href, $what);
233N/A } else {
233N/A $done .= "$pre$what";
233N/A }
233N/A $_ = $post;
233N/A }
233N/A $_ = $done . $_;
233N/A }
233N/A if ($use_glossary) {
233N/A $done = '';
233N/A while (/\b\w+\b/) {
233N/A ($pre, $what, $post) = ($`, $&, $');
233N/A $entry = $what;
233N/A $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/;
233N/A $href = $gloss2href{$entry};
233N/A if (defined($href) && $post !~ /^[^<]*<\/A>/) {
233N/A $done .= $pre . &anchor('', $href, $what);
233N/A } else {
233N/A $done .= "$pre$what";
233N/A }
233N/A $_ = $post;
233N/A }
233N/A $_ = $done . $_;
233N/A }
233N/A }
233N/A # otherwise
233N/A push(@lines2, $_);
233N/A}
233N/Aprint "# end of pass 2\n" if $verbose;
233N/A
233N/A#
233N/A# split style substitutions
233N/A#
233N/Awhile (@lines2) {
233N/A $_ = shift(@lines2);
233N/A #
233N/A # special case (protected sections)
233N/A #
233N/A if (/^$PROTECTTAG/o) {
233N/A push(@lines3, $_);
233N/A next;
233N/A }
233N/A #
233N/A # split style substitutions
233N/A #
233N/A $old = '';
233N/A while ($old ne $_) {
233N/A $old = $_;
233N/A if (/\@(\w+)\{/) {
233N/A ($before, $style, $after) = ($`, $1, $');
233N/A if (defined($style_map{$style})) {
233N/A $_ = $after;
233N/A $text = '';
233N/A $after = '';
233N/A $failed = 1;
233N/A while (@lines2) {
233N/A if (/\}/) {
233N/A $text .= $`;
233N/A $after = $';
233N/A $failed = 0;
233N/A last;
233N/A } else {
233N/A $text .= $_;
233N/A $_ = shift(@lines2);
233N/A }
233N/A }
233N/A if ($failed) {
233N/A die "* Bad syntax (\@$style) after: $before\n";
233N/A } else {
233N/A $text = &apply_style($style, $text);
233N/A $_ = "$before$text$after";
233N/A }
233N/A }
233N/A }
233N/A }
233N/A # otherwise
233N/A push(@lines3, $_);
233N/A}
233N/Aprint "# end of pass 3\n" if $verbose;
233N/A
233N/A#+++############################################################################
233N/A# #
233N/A# Pass 4: foot notes, final cleanup #
233N/A# #
233N/A#---############################################################################
233N/A
233N/A@foot_lines = (); # footnotes
233N/A@doc_lines = (); # final document
233N/A$end_of_para = 0; # true if last line is <P>
233N/A
233N/Awhile (@lines3) {
233N/A $_ = shift(@lines3);
233N/A #
233N/A # special case (protected sections)
233N/A #
233N/A if (/^$PROTECTTAG/o) {
233N/A push(@doc_lines, $_);
233N/A $end_of_para = 0;
233N/A next;
233N/A }
233N/A #
233N/A # footnotes
233N/A #
233N/A while (/\@footnote([^\{\s]+)\{/) {
233N/A ($before, $d, $after) = ($`, $1, $');
233N/A $_ = $after;
233N/A $text = '';
233N/A $after = '';
233N/A $failed = 1;
233N/A while (@lines3) {
233N/A if (/\}/) {
233N/A $text .= $`;
233N/A $after = $';
233N/A $failed = 0;
233N/A last;
233N/A } else {
233N/A $text .= $_;
233N/A $_ = shift(@lines3);
233N/A }
233N/A }
233N/A if ($failed) {
233N/A die "* Bad syntax (\@footnote) after: $before\n";
233N/A } else {
233N/A $foot_num++;
233N/A $docid = "DOCF$foot_num";
233N/A $footid = "FOOT$foot_num";
233N/A $foot = "($foot_num)";
233N/A push(@foot_lines, "<H3>" . &anchor($footid, "$d#$docid", $foot) . "</H3>\n");
233N/A $text = "<P>$text" unless $text =~ /^\s*<P>/;
233N/A push(@foot_lines, "$text\n");
233N/A $_ = $before . &anchor($docid, "$docu_foot#$footid", $foot) . $after;
233N/A }
233N/A }
233N/A #
233N/A # remove unnecessary <P>
233N/A #
233N/A if (/^\s*<P>\s*$/) {
233N/A next if $end_of_para++;
233N/A } else {
233N/A $end_of_para = 0;
233N/A }
233N/A # otherwise
233N/A push(@doc_lines, $_);
233N/A}
233N/Aprint "# end of pass 4\n" if $verbose;
233N/A
233N/A#+++############################################################################
233N/A# #
233N/A# Pass 5: print things #
233N/A# #
233N/A#---############################################################################
233N/A
233N/A$header = <<EOT;
233N/A<!-- Created by $THISPROG from $docu on $TODAY -->
233N/AEOT
233N/A
233N/A$full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document";
233N/A$title = $value{'_settitle'} || $full_title;
233N/A$_ = &substitute_style($full_title);
233N/A&unprotect_texi;
233N/As/\n$//; # rmv last \n (if any)
233N/A$full_title = "<H1>" . join("</H1>\n<H1>", split(/\n/, $_)) . "</H1>\n";
233N/A
233N/A#
233N/A# print ToC
233N/A#
233N/Aif (!$monolithic && @toc_lines) {
233N/A if (open(FILE, "> $docu_toc")) {
233N/A print "# creating $docu_toc...\n" if $verbose;
233N/A &print_toplevel_header("$title - Table of Contents");
233N/A &print_ruler;
233N/A &print(*toc_lines, FILE);
233N/A &print_toplevel_footer;
233N/A close(FILE);
233N/A } else {
233N/A warn "$ERROR Can't write to $docu_toc: $!\n";
233N/A }
233N/A}
233N/A
233N/A#
233N/A# print footnotes
233N/A#
233N/Aif (!$monolithic && @foot_lines) {
233N/A if (open(FILE, "> $docu_foot")) {
233N/A print "# creating $docu_foot...\n" if $verbose;
233N/A &print_toplevel_header("$title - Footnotes");
233N/A &print_ruler;
233N/A &print(*foot_lines, FILE);
233N/A &print_toplevel_footer;
233N/A close(FILE);
233N/A } else {
233N/A warn "$ERROR Can't write to $docu_foot: $!\n";
233N/A }
233N/A}
233N/A
233N/A#
233N/A# print document
233N/A#
233N/Aif ($split_chapter || $split_node) { # split
233N/A $doc_num = 0;
233N/A $last_num = scalar(@sections);
233N/A $first_doc = &doc_name(1);
233N/A $last_doc = &doc_name($last_num);
233N/A while (@sections) {
233N/A $section = shift(@sections);
233N/A &next_doc;
233N/A if (open(FILE, "> $docu_doc")) {
233N/A print "# creating $docu_doc...\n" if $verbose;
233N/A &print_header("$title - $section");
233N/A $prev_doc = ($doc_num == 1 ? undef : &doc_name($doc_num - 1));
233N/A $next_doc = ($doc_num == $last_num ? undef : &doc_name($doc_num + 1));
233N/A $navigation = "Go to the ";
233N/A $navigation .= ($prev_doc ? &anchor('', $first_doc, "first") : "first");
233N/A $navigation .= ", ";
233N/A $navigation .= ($prev_doc ? &anchor('', $prev_doc, "previous") : "previous");
233N/A $navigation .= ", ";
233N/A $navigation .= ($next_doc ? &anchor('', $next_doc, "next") : "next");
233N/A $navigation .= ", ";
233N/A $navigation .= ($next_doc ? &anchor('', $last_doc, "last") : "last");
233N/A $navigation .= " section, " . &anchor('', $docu_toc, "table of contents") . ".\n";
233N/A print FILE $navigation;
233N/A &print_ruler;
233N/A # find corresponding lines
233N/A @tmp_lines = ();
233N/A while (@doc_lines) {
233N/A $_ = shift(@doc_lines);
233N/A last if ($_ eq $SPLITTAG);
233N/A push(@tmp_lines, $_);
233N/A }
233N/A &print(*tmp_lines, FILE);
233N/A &print_ruler;
233N/A print FILE $navigation;
233N/A &print_footer;
233N/A close(FILE);
233N/A } else {
233N/A warn "$ERROR Can't write to $docu_doc: $!\n";
233N/A }
233N/A }
233N/A} else { # not split
233N/A if (open(FILE, "> $docu_doc")) {
233N/A print "# creating $docu_doc...\n" if $verbose;
233N/A if ($monolithic || !@toc_lines) {
233N/A &print_toplevel_header($title);
233N/A } else {
233N/A &print_header($title);
233N/A print FILE $full_title;
233N/A }
233N/A if ($monolithic && @toc_lines) {
233N/A &print_ruler;
233N/A print FILE "<H1>Table of Contents</H1>\n";
233N/A &print(*toc_lines, FILE);
233N/A }
233N/A &print_ruler;
233N/A &print(*doc_lines, FILE);
233N/A if ($monolithic && @foot_lines) {
233N/A &print_ruler;
233N/A print FILE "<H1>Footnotes</H1>\n";
233N/A &print(*foot_lines, FILE);
233N/A }
233N/A if ($monolithic || !@toc_lines) {
233N/A &print_toplevel_footer;
233N/A } else {
233N/A &print_footer;
233N/A }
233N/A close(FILE);
233N/A } else {
233N/A warn "$ERROR Can't write to $docu_doc: $!\n";
233N/A }
233N/A}
233N/A
233N/Aprint "# that's all folks\n" if $verbose;
233N/A
233N/A#+++############################################################################
233N/A# #
233N/A# Low level functions #
233N/A# #
233N/A#---############################################################################
233N/A
233N/Asub update_sec_num {
233N/A local($name, $level) = @_;
233N/A my $ret;
233N/A
233N/A $level--; # here we start at 0
233N/A if ($name =~ /^appendix/) {
233N/A # appendix style
233N/A if (defined(@appendix_sec_num)) {
233N/A &incr_sec_num($level, @appendix_sec_num);
233N/A } else {
233N/A @appendix_sec_num = ('A', 0, 0, 0);
233N/A }
233N/A $ret = join('.', @appendix_sec_num[0..$level]);
233N/A } else {
233N/A # normal style
233N/A if (defined(@normal_sec_num)) {
233N/A &incr_sec_num($level, @normal_sec_num);
233N/A } else {
233N/A @normal_sec_num = (1, 0, 0, 0);
233N/A }
233N/A $ret = join('.', @normal_sec_num[0..$level]);
233N/A }
233N/A
233N/A $ret .= "." if $level == 0;
233N/A return $ret;
233N/A}
233N/A
233N/Asub incr_sec_num {
233N/A local($level, $l);
233N/A $level = shift(@_);
233N/A $_[$level]++;
233N/A foreach $l ($level+1 .. 3) {
233N/A $_[$l] = 0;
233N/A }
233N/A}
233N/A
233N/Asub check {
233N/A local($_, %seen, %context, $before, $match, $after);
233N/A
233N/A while (<>) {
233N/A if (/\@(\*|\.|\:|\@|\{|\})/) {
233N/A $seen{$&}++;
233N/A $context{$&} .= "> $_" if $verbose;
233N/A $_ = "$`XX$'";
233N/A redo;
233N/A }
233N/A if (/\@(\w+)/) {
233N/A ($before, $match, $after) = ($`, $&, $');
233N/A if ($before =~ /\b[\w-]+$/ && $after =~ /^[\w-.]*\b/) { # e-mail address
233N/A $seen{'e-mail address'}++;
233N/A $context{'e-mail address'} .= "> $_" if $verbose;
233N/A } else {
233N/A $seen{$match}++;
233N/A $context{$match} .= "> $_" if $verbose;
233N/A }
233N/A $match =~ s/^\@/X/;
233N/A $_ = "$before$match$after";
233N/A redo;
233N/A }
233N/A }
233N/A
233N/A foreach (sort(keys(%seen))) {
233N/A if ($verbose) {
233N/A print "$_\n";
233N/A print $context{$_};
233N/A } else {
233N/A print "$_ ($seen{$_})\n";
233N/A }
233N/A }
233N/A}
233N/A
233N/Asub open {
233N/A local($name) = @_;
233N/A
233N/A ++$fh_name;
233N/A if (open($fh_name, $name)) {
233N/A unshift(@fhs, $fh_name);
233N/A } else {
233N/A warn "$ERROR Can't read file $name: $!\n";
233N/A }
233N/A}
233N/A
233N/Asub init_input {
233N/A @fhs = (); # hold the file handles to read
233N/A @input_spool = (); # spooled lines to read
233N/A $fh_name = 'FH000';
233N/A &open($docu);
233N/A}
233N/A
233N/Asub next_line {
233N/A local($fh, $line);
233N/A
233N/A if (@input_spool) {
233N/A $line = shift(@input_spool);
233N/A return($line);
233N/A }
233N/A while (@fhs) {
233N/A $fh = $fhs[0];
233N/A $line = <$fh>;
233N/A return($line) if $line;
233N/A close($fh);
233N/A shift(@fhs);
233N/A }
233N/A return(undef);
233N/A}
233N/A
233N/A# used in pass 1, use &next_line
233N/Asub skip_until {
233N/A local($tag) = @_;
233N/A local($_);
233N/A
233N/A while ($_ = &next_line) {
233N/A return if /^\@end\s+$tag\s*$/;
233N/A }
233N/A die "* Failed to find '$tag' after: " . $lines[$#lines];
233N/A}
233N/A
233N/A#
233N/A# HTML stacking to have a better HTML output
233N/A#
233N/A
233N/Asub html_reset {
233N/A @html_stack = ('html');
233N/A $html_element = 'body';
233N/A}
233N/A
233N/Asub html_push {
233N/A local($what) = @_;
233N/A push(@html_stack, $html_element);
233N/A $html_element = $what;
233N/A}
233N/A
233N/Asub html_push_if {
233N/A local($what) = @_;
233N/A push(@html_stack, $html_element)
233N/A if ($html_element && $html_element ne 'P');
233N/A $html_element = $what;
233N/A}
233N/A
233N/Asub html_pop {
233N/A $html_element = pop(@html_stack);
233N/A}
233N/A
233N/Asub html_pop_if {
233N/A local($elt);
233N/A
233N/A if (@_) {
233N/A foreach $elt (@_) {
233N/A if ($elt eq $html_element) {
233N/A $html_element = pop(@html_stack) if @html_stack;
233N/A last;
233N/A }
233N/A }
233N/A } else {
233N/A $html_element = pop(@html_stack) if @html_stack;
233N/A }
233N/A}
233N/A
233N/Asub html_debug {
233N/A local($what, $line) = @_;
233N/A return("<!-- $line @html_stack, $html_element -->$what")
233N/A if $debug & $DEBUG_HTML;
233N/A return($what);
233N/A}
233N/A
233N/A# to debug the output...
233N/Asub debug {
233N/A local($what, $line) = @_;
233N/A return("<!-- $line -->$what")
233N/A if $debug & $DEBUG_HTML;
233N/A return($what);
233N/A}
233N/A
233N/Asub normalise_node {
233N/A $_[0] =~ s/\s+/ /g;
233N/A $_[0] =~ s/ $//;
233N/A $_[0] =~ s/^ //;
233N/A}
233N/A
233N/Asub menu_entry {
233N/A local($entry, $node, $descr) = @_;
233N/A local($href);
233N/A
233N/A &normalise_node($node);
233N/A $href = $node2href{$node};
233N/A if ($href) {
233N/A $descr =~ s/^\s+//;
233N/A $descr = ": $descr" if $descr;
233N/A push(@lines2, "<LI>" . &anchor('', $href, $entry) . "$descr\n");
233N/A } else {
233N/A warn "$ERROR Undefined node ($node): $_";
233N/A }
233N/A}
233N/A
233N/Asub do_ctrl { "^$_[0]" }
233N/A
233N/Asub do_email {
233N/A local($addr, $text) = split(/,\s*/, $_[0]);
233N/A
233N/A $text = $addr unless $text;
233N/A &anchor('', "mailto:$addr", $text);
233N/A}
233N/A
233N/Asub do_sc { "\U$_[0]\E" }
233N/A
233N/Asub do_uref {
233N/A local($url, $text) = split(/,\s*/, $_[0]);
233N/A
233N/A $text = $url unless $text;
233N/A &anchor('', $url, $text);
233N/A}
233N/A
233N/Asub do_url { &anchor('', $_[0], $_[0]) }
233N/A
233N/Asub apply_style {
233N/A local($texi_style, $text) = @_;
233N/A local($style);
233N/A
233N/A $style = $style_map{$texi_style};
233N/A if (defined($style)) { # known style
233N/A if ($style =~ /^\"/) { # add quotes
233N/A $style = $';
233N/A $text = "\`$text\'";
233N/A }
233N/A if ($style =~ /^\&/) { # custom
233N/A $style = $';
233N/A $text = &$style($text);
233N/A } elsif ($style) { # good style
233N/A $text = "<$style>$text</$style>";
233N/A } else { # no style
233N/A }
233N/A } else { # unknown style
233N/A $text = undef;
233N/A }
233N/A return($text);
233N/A}
233N/A
233N/A# remove Texinfo styles
233N/Asub remove_style {
233N/A local($_) = @_;
233N/A s/\@\w+{([^\{\}]+)}/$1/g;
233N/A return($_);
233N/A}
233N/A
233N/Asub substitute_style {
233N/A local($_) = @_;
233N/A local($changed, $done, $style, $text);
233N/A
233N/A $changed = 1;
233N/A while ($changed) {
233N/A $changed = 0;
233N/A $done = '';
233N/A while (/\@(\w+){([^\{\}]+)}/) {
233N/A $text = &apply_style($1, $2);
233N/A if ($text) {
233N/A $_ = "$`$text$'";
233N/A $changed = 1;
233N/A } else {
233N/A $done .= "$`\@$1";
233N/A $_ = "{$2}$'";
233N/A }
233N/A }
233N/A $_ = $done . $_;
233N/A }
233N/A return($_);
233N/A}
233N/A
233N/Asub anchor {
233N/A local($name, $href, $text, $newline) = @_;
233N/A local($result);
233N/A
233N/A $result = "<A";
233N/A $result .= " NAME=\"$name\"" if $name;
233N/A $result .= " HREF=\"$href\"" if $href;
233N/A $result .= ">$text</A>";
233N/A $result .= "\n" if $newline;
233N/A return($result);
233N/A}
233N/A
233N/Asub pretty_date {
233N/A local(@MoY, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
233N/A
233N/A @MoY = ('January', 'February', 'March', 'April', 'May', 'June',
233N/A 'July', 'August', 'September', 'October', 'November', 'December');
233N/A ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
233N/A $year += ($year < 70) ? 2000 : 1900;
233N/A return("$mday $MoY[$mon] $year");
233N/A}
233N/A
233N/Asub doc_name {
233N/A local($num) = @_;
233N/A
233N/A return("${docu_name}_$num.html");
233N/A}
233N/A
233N/Asub next_doc {
233N/A $docu_doc = &doc_name(++$doc_num);
233N/A}
233N/A
233N/Asub print {
233N/A local(*lines, $fh) = @_;
233N/A local($_);
233N/A
233N/A while (@lines) {
233N/A $_ = shift(@lines);
233N/A if (/^$PROTECTTAG/o) {
233N/A $_ = $tag2pro{$_};
233N/A } else {
233N/A &unprotect_texi;
233N/A }
233N/A print $fh $_;
233N/A }
233N/A}
233N/A
233N/Asub print_ruler {
233N/A print FILE "<P><HR><P>\n";
233N/A}
233N/A
233N/Asub print_header {
233N/A local($_);
233N/A
233N/A # clean the title
233N/A $_ = &remove_style($_[0]);
233N/A &unprotect_texi;
233N/A # print the header
233N/A if ($doctype eq 'html2') {
233N/A print FILE $html2_doctype;
233N/A } elsif ($doctype) {
233N/A print FILE $doctype;
233N/A }
233N/A print FILE <<EOT;
233N/A<HTML>
233N/A<HEAD>
233N/A$header
233N/A<TITLE>$_</TITLE>
233N/A</HEAD>
233N/A<BODY>
233N/AEOT
233N/A}
233N/A
233N/Asub print_toplevel_header {
233N/A local($_);
233N/A
233N/A &print_header; # pass given arg...
233N/A print FILE $full_title;
233N/A if ($value{'_subtitle'}) {
233N/A $value{'_subtitle'} =~ s/\n+$//;
233N/A foreach (split(/\n/, $value{'_subtitle'})) {
233N/A $_ = &substitute_style($_);
233N/A &unprotect_texi;
233N/A print FILE "<H2>$_</H2>\n";
233N/A }
233N/A }
233N/A if ($value{'_author'}) {
233N/A $value{'_author'} =~ s/\n+$//;
233N/A foreach (split(/\n/, $value{'_author'})) {
233N/A $_ = &substitute_style($_);
233N/A &unprotect_texi;
233N/A s/[\w.-]+\@[\w.-]+/<A HREF="mailto:$&">$&<\/A>/g;
233N/A print FILE "<ADDRESS>$_</ADDRESS>\n";
233N/A }
233N/A }
233N/A print FILE "<P>\n";
233N/A}
233N/A
233N/Asub print_footer {
233N/A print FILE <<EOT;
233N/A</BODY>
233N/A</HTML>
233N/AEOT
233N/A}
233N/A
233N/Asub print_toplevel_footer {
233N/A &print_ruler;
233N/A print FILE <<EOT;
233N/AThis document was generated on $TODAY using
233N/A<A HREF=\"$HOMEPAGE\">texi2html</A>&nbsp;$value{texi2html}.
233N/AEOT
233N/A &print_footer;
233N/A}
233N/A
233N/Asub protect_texi {
233N/A # protect @ { } ` '
233N/A s/\@\@/$;0/go;
233N/A s/\@\{/$;1/go;
233N/A s/\@\}/$;2/go;
233N/A s/\@\`/$;3/go;
233N/A s/\@\'/$;4/go;
233N/A}
233N/A
233N/Asub protect_html {
233N/A local($what) = @_;
233N/A # protect & < >
233N/A $what =~ s/\&/\&\#38;/g;
233N/A $what =~ s/\</\&\#60;/g;
233N/A $what =~ s/\>/\&\#62;/g;
233N/A # but recognize some HTML things
233N/A $what =~ s/\&\#60;\/A\&\#62;/<\/A>/g; # </A>
233N/A $what =~ s/\&\#60;A ([^\&]+)\&\#62;/<A $1>/g; # <A [^&]+>
233N/A $what =~ s/\&\#60;IMG ([^\&]+)\&\#62;/<IMG $1>/g; # <IMG [^&]+>
233N/A return($what);
233N/A}
233N/A
233N/Asub unprotect_texi {
233N/A s/$;0/\@/go;
233N/A s/$;1/\{/go;
233N/A s/$;2/\}/go;
233N/A s/$;3/\`/go;
233N/A s/$;4/\'/go;
233N/A}
233N/A
233N/Asub unprotect_html {
233N/A local($what) = @_;
233N/A $what =~ s/\&\#38;/\&/g;
233N/A $what =~ s/\&\#60;/\</g;
233N/A $what =~ s/\&\#62;/\>/g;
233N/A return($what);
233N/A}
233N/A
233N/Asub byalpha {
233N/A $key2alpha{$a} cmp $key2alpha{$b};
233N/A}
233N/A
233N/A##############################################################################
233N/A
233N/A # These next few lines are legal in both Perl and nroff.
233N/A
233N/A.00 ; # finish .ig
233N/A
233N/A'di \" finish diversion--previous line must be blank
233N/A.nr nl 0-1 \" fake up transition to first page again
233N/A.nr % 0 \" start at page 1
233N/A'; __END__ ############# From here on it's a standard manual page ############
233N/A.TH TEXI2HTML 1 "01/05/98"
233N/A.AT 3
233N/A.SH NAME
233N/Atexi2html \- a Texinfo to HTML converter
233N/A.SH SYNOPSIS
233N/A.B texi2html [options] file
233N/A.PP
233N/A.B texi2html -check [-verbose] files
233N/A.SH DESCRIPTION
233N/A.I Texi2html
233N/Aconverts the given Texinfo file to a set of HTML files. It tries to handle
233N/Amost of the Texinfo commands. It creates hypertext links for cross-references,
233N/Afootnotes...
233N/A.PP
233N/AIt also tries to add links from a reference to its corresponding entry in the
233N/Abibliography (if any). It may also handle a glossary (see the
233N/A.B \-glossary
233N/Aoption).
233N/A.PP
233N/A.I Texi2html
233N/Acreates several files depending on the contents of the Texinfo file and on
233N/Athe chosen options (see FILES).
233N/A.PP
233N/AThe HTML files created by
233N/A.I texi2html
233N/Aare closer to TeX than to Info, that's why
233N/A.I texi2html
233N/Aconverts @iftex sections and not @ifinfo ones by default. You can reverse
233N/Athis with the \-expandinfo option.
233N/A.SH OPTIONS
233N/A.TP 12
233N/A.B \-check
233N/ACheck the given file and give the list of all things that may be Texinfo commands.
233N/AThis may be used to check the output of
233N/A.I texi2html
233N/Ato find the Texinfo commands that have been left in the HTML file.
233N/A.TP
233N/A.B \-expandinfo
233N/AExpand @ifinfo sections, not @iftex ones.
233N/A.TP
233N/A.B \-glossary
233N/AUse the section named 'Glossary' to build a list of terms and put links in the HTML
233N/Adocument from each term toward its definition.
233N/A.TP
233N/A.B \-invisible \fIname\fP
233N/AUse \fIname\fP to create invisible destination anchors for index links
233N/A(you can for instance use the invisible.xbm file shipped with this program).
233N/AThis is a workaround for a known bug of many WWW browsers, including netscape.
233N/A.TP
233N/A.B \-I \fIdir\fP
233N/ALook also in \fIdir\fP to find included files.
233N/A.TP
233N/A.B \-menu
233N/AShow the Texinfo menus; by default they are ignored.
233N/A.TP
233N/A.B \-monolithic
233N/AOutput only one file, including the table of contents and footnotes.
233N/A.TP
233N/A.B \-number
233N/ANumber the sections.
233N/A.TP
233N/A.B \-split_chapter
233N/ASplit the output into several HTML files (one per main section:
233N/Achapter, appendix...).
233N/A.TP
233N/A.B \-split_node
233N/ASplit the output into several HTML files (one per node).
233N/A.TP
233N/A.B \-usage
233N/APrint usage instructions, listing the current available command-line options.
233N/A.TP
233N/A.B \-verbose
233N/AGive a verbose output. Can be used with the
233N/A.B \-check
233N/Aoption.
233N/A.PP
233N/A.SH FILES
233N/ABy default
233N/A.I texi2html
233N/Acreates the following files (foo being the name of the Texinfo file):
233N/A.TP 16
233N/A.B foo_toc.html
233N/AThe table of contents.
233N/A.TP
233N/A.B foo.html
233N/AThe document's contents.
233N/A.TP
233N/A.B foo_foot.html
233N/AThe footnotes (if any).
233N/A.PP
233N/AWhen used with the
233N/A.B \-split
233N/Aoption, it creates several files (one per chapter or node), named
233N/A.B foo_n.html
233N/A(n being the indice of the chapter or node), instead of the single
233N/A.B foo.html
233N/Afile.
233N/A.PP
233N/AWhen used with the
233N/A.B \-monolithic
233N/Aoption, it creates only one file:
233N/A.B foo.html
233N/A.SH VARIABLES
233N/A.I texi2html
233N/Apredefines the following variables: \fBhtml\fP, \fBtexi2html\fP.
233N/A.SH ADDITIONAL COMMANDS
233N/A.I texi2html
233N/Aimplements the following non-Texinfo commands (maybe they are in Texinfo now...):
233N/A.TP 16
233N/A.B @ifhtml
233N/AThis indicates the start of an HTML section, this section will passed through
233N/Awithout any modification.
233N/A.TP
233N/A.B @end ifhtml
233N/AThis indicates the end of an HTML section.
233N/A.SH VERSION
233N/AThis is \fItexi2html\fP version 1.56k, 1999-02-20.
233N/A.PP
233N/AThe latest version of \fItexi2html\fP can be found in WWW, cf. URLs
233N/Ahttp://wwwinfo.cern.ch/dis/texi2html/
233N/A.br
233N/Ahttp://texinfo.org/texi2html/
233N/A.SH AUTHOR
233N/AThe main author is Lionel Cons, CERN IT/DIS/OSE, Lionel.Cons@cern.ch.
233N/AMany other people around the net contributed to this program.
233N/A.SH COPYRIGHT
233N/AThis program is the intellectual property of the European
233N/ALaboratory for Particle Physics (known as CERN). No guarantee whatsoever is
233N/Aprovided by CERN. No liability whatsoever is accepted for any loss or damage
233N/Aof any kind resulting from any defect or inaccuracy in this information or
233N/Acode.
233N/A.PP
233N/ACERN, 1211 Geneva 23, Switzerland
233N/A.SH "SEE ALSO"
233N/AGNU Texinfo Documentation Format,
233N/AHyperText Markup Language (HTML),
233N/AWorld Wide Web (WWW).
233N/A.SH BUGS
233N/AThis program does not understand all Texinfo commands (yet).
233N/A.PP
233N/ATeX specific commands (normally enclosed in @iftex) will be
233N/Apassed unmodified.
233N/A.ex