texi2html:

  Updated version of texi2html so that 4.0.22 HTML manual doesn't turn out all goofy.
parent 4437787b
#!PATH_TO_PERL -*- perl -*- #!/usr/bin/perl
# Add path to perl on the previous line and make this executable # Add path to perl on the previous line and make this executable
# if you want to use this as a normal script. # if you want to use this as a normal script.
'di '; 'di ';
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#-############################################################################## #-##############################################################################
# @(#)texi2html 1.52 971230 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch # @(#)texi2html 1.52 971230 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch
# Enhanced by David Axmark, david@detron.se # Enhanced by David Axmark
# The man page for this program is included at the end of this file and can be # The man page for this program is included at the end of this file and can be
# viewed using the command 'nroff -man texi2html'. # viewed using the command 'nroff -man texi2html'.
...@@ -40,8 +40,7 @@ $NODESRE = '[^@{}:\'`"]+'; # RE for a list of node names ...@@ -40,8 +40,7 @@ $NODESRE = '[^@{}:\'`"]+'; # RE for a list of node names
$XREFRE = '[^@{}]+'; # RE for a xref (should use NODERE) $XREFRE = '[^@{}]+'; # RE for a xref (should use NODERE)
$ERROR = "***"; # prefix for errors and warnings $ERROR = "***"; # prefix for errors and warnings
$THISPROG = "texi2html 1.52 (hacked by david\@detron.se)"; # program name and version $THISPROG = "texi2html 1.52 (with additions by MySQL AB)"; # program name and version
$HOMEPAGE = "http://www.mathematik.uni-kl.de/~obachman/Texi2html/"; # program home page
$TODAY = &pretty_date; # like "20 September 1993" $TODAY = &pretty_date; # like "20 September 1993"
$SPLITTAG = "<!-- SPLIT HERE -->\n"; # tag to know where to split $SPLITTAG = "<!-- SPLIT HERE -->\n"; # tag to know where to split
$PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections $PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections
...@@ -114,10 +113,12 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E ...@@ -114,10 +113,12 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E
# #
%accent_map = ( %accent_map = (
'"', 'uml', '"', 'uml',
'\'', 'acute',
',{', 'cedil',
'~', 'tilde', '~', 'tilde',
'^', 'circ', '^', 'circ',
'`', 'grave', '`', 'grave',
'\'', 'acute', 'ringaccent{', 'ring',
); );
# #
...@@ -125,7 +126,7 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E ...@@ -125,7 +126,7 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E
# #
%simple_map = ( %simple_map = (
# cf. makeinfo.c # cf. makeinfo.c
"*", "<BR>", # HTML+ "*", "<br />", # HTML+
" ", " ", " ", " ",
"\n", "\n", "\n", "\n",
"|", "", "|", "",
...@@ -134,6 +135,8 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E ...@@ -134,6 +135,8 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E
"!", "!", "!", "!",
"?", "?", "?", "?",
".", ".", ".", ".",
# @- means "allow word break", not &mdash;
"-", "",
); );
# #
...@@ -141,9 +144,10 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E ...@@ -141,9 +144,10 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E
# #
%things_map = ( %things_map = (
'TeX', 'TeX', 'TeX', 'TeX',
'br', '<P>', # paragraph break 'br', '<p>', # paragraph break
'bullet', '*', 'bullet', '*',
'copyright', '(C)', 'copyright', '(C)',
'registeredsymbol', '(R)',
'dots', '...', 'dots', '...',
'equiv', '==', 'equiv', '==',
'error', 'error-->', 'error', 'error-->',
...@@ -161,27 +165,28 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E ...@@ -161,27 +165,28 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E
%style_map = ( %style_map = (
'asis', '', 'asis', '',
'b', 'B', 'b', 'B',
'cite', 'CITE', 'cite', 'cite',
'code', 'CODE', 'code', 'code',
'command', 'code',
'ctrl', '&do_ctrl', # special case 'ctrl', '&do_ctrl', # special case
'dfn', 'STRONG', # DFN tag is illegal in the standard 'dfn', 'strong', # DFN tag is illegal in the standard
'dmn', '', # useless 'dmn', '', # useless
'email', '&fix_email', # special 'email', '&fix_email', # special
'emph', 'EM', 'emph', 'em',
'file', '"TT', # will put quotes, cf. &apply_style 'file', '"tt', # will put quotes, cf. &apply_style
'i', 'I', 'i', 'i',
'kbd', 'KBD', 'kbd', 'kbd',
'key', 'KBD', 'key', 'kbd',
'r', '', # unsupported 'r', '', # unsupported
'samp', '"SAMP', # will put quotes, cf. &apply_style 'samp', '"samp', # will put quotes, cf. &apply_style
'sc', '&do_sc', # special case 'sc', '&do_sc', # special case
'strong', 'STRONG', 'strong', 'strong',
't', 'TT', 't', 'tt',
'titlefont', '', # useless 'titlefont', '', # useless
'image', '&fix_image', # Image 'image', '&fix_image', # Image
'url', '&fix_url', # URL 'url', '&fix_url', # URL
'uref', '&fix_uref', # URL Reference 'uref', '&fix_uref', # URL Reference
'var', 'VAR', 'var', 'var',
'w', '', # unsupported 'w', '', # unsupported
); );
...@@ -317,6 +322,7 @@ $usage = <<EOT; ...@@ -317,6 +322,7 @@ $usage = <<EOT;
This is $THISPROG This is $THISPROG
To convert a Texinfo file to HMTL: $0 [options] file To convert a Texinfo file to HMTL: $0 [options] file
where options can be: where options can be:
-acc : convert @"-like accents to &entities;
-expandinfo : use \@ifinfo sections, not \@iftex -expandinfo : use \@ifinfo sections, not \@iftex
-glossary : handle a glossary -glossary : handle a glossary
-invisible name: use 'name' as an invisible anchor -invisible name: use 'name' as an invisible anchor
...@@ -445,11 +451,15 @@ $html_num = 0; ...@@ -445,11 +451,15 @@ $html_num = 0;
if ($use_iso) { if ($use_iso) {
$things_map{'bullet'} = "&bull;"; $things_map{'bullet'} = "&bull;";
$things_map{'copyright'} = "&copy;"; $things_map{'copyright'} = "&copy;";
$things_map{'registeredsymbol'} = "&reg;";
$things_map{'dots'} = "&hellip;"; $things_map{'dots'} = "&hellip;";
$things_map{'equiv'} = "&equiv;"; $things_map{'equiv'} = "&equiv;";
$things_map{'expansion'} = "&rarr;"; $things_map{'expansion'} = "&rarr;";
$things_map{'point'} = "&lowast;"; $things_map{'point'} = "&lowast;";
$things_map{'result'} = "&rArr;"; $things_map{'result'} = "&rArr;";
$things_map{'ss'} = "&szlig;";
$things_map{'o'} = "&oslash;";
$things_map{'O'} = "&Oslash;";
} }
# #
...@@ -505,23 +515,27 @@ $html_element = ''; # current HTML element ...@@ -505,23 +515,27 @@ $html_element = ''; # current HTML element
# watch out for regexps, / and escaped characters! # watch out for regexps, / and escaped characters!
$subst_code = ''; $subst_code = '';
foreach (keys(%simple_map)) { foreach (keys(%simple_map)) {
($re = $_) =~ s/(\W)/\\$1/g; # protect regexp chars $re = quotemeta $_; # protect regexp chars
$subst_code .= "s/\\\@$re/$simple_map{$_}/g;\n"; $sub = quotemeta $simple_map{$_};
$subst_code .= "s/\\\@$re/$sub/g;\n";
} }
foreach (keys(%things_map)) { foreach (keys(%things_map)) {
$subst_code .= "s/\\\@$_\\{\\}/$things_map{$_}/g;\n"; $re = quotemeta $_; # protect regexp chars
$sub = quotemeta $things_map{$_};
$subst_code .= "s/\\\@$re\\{\\}/$sub/g;\n";
} }
if ($use_acc) { if ($use_acc) {
# accentuated characters # accentuated characters
foreach (keys(%accent_map)) { foreach (keys(%accent_map)) {
my $brace = /{$/ ? '}' : '';
if ($_ eq "`") { if ($_ eq "`") {
$subst_code .= "s/$;3"; $subst_code .= "s/$;3";
} elsif ($_ eq "'") { } elsif ($_ eq "'") {
$subst_code .= "s/$;4"; $subst_code .= "s/$;4";
} else { } else {
$subst_code .= "s/\\\@\\$_"; $subst_code .= "s/\\\@\\Q$_\\E";
} }
$subst_code .= "([aeiou])/&\${1}$accent_map{$_};/gi;\n"; $subst_code .= "(\\w)$brace/&\${1}$accent_map{$_};/gi;\n";
} }
} }
eval("sub simple_substitutions { $subst_code }"); eval("sub simple_substitutions { $subst_code }");
...@@ -703,7 +717,7 @@ READ_LINE: while ($_ = &next_line) ...@@ -703,7 +717,7 @@ READ_LINE: while ($_ = &next_line)
s/{[^{}]+}//g); s/{[^{}]+}//g);
print "# Multitable with $multitable_cols columns\n" print "# Multitable with $multitable_cols columns\n"
if $debug and $DEBUG_USER; if $debug and $DEBUG_USER;
push(@lines, &debug("<TABLE BORDER WIDTH=\"100%\">\n", __LINE__)); push(@lines, &debug("<TABLE BORDER>\n", __LINE__));
} else { } else {
warn "$ERROR Bad table line: $_"; warn "$ERROR Bad table line: $_";
} }
...@@ -873,7 +887,7 @@ READ_LINE: while ($_ = &next_line) ...@@ -873,7 +887,7 @@ READ_LINE: while ($_ = &next_line)
&simple_substitutions; &simple_substitutions;
s/\@value{($VARRE)}/$value{$1}/eg; s/\@value{($VARRE)}/$value{$1}/eg;
s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4 s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4
s|\s+\@tab\s*| </TD><TD> |g if ($in_multitable); s/(^|\s+)\@tab\s*/ <\/TD><TD> /g if ($in_multitable);
# #
# analyze the tag again # analyze the tag again
...@@ -885,7 +899,7 @@ READ_LINE: while ($_ = &next_line) ...@@ -885,7 +899,7 @@ READ_LINE: while ($_ = &next_line)
$name =~ s/\s+$//; $name =~ s/\s+$//;
$level = $sec2level{$tag}; $level = $sec2level{$tag};
$name = &update_sec_num($tag, $level) . " $name" $name = &update_sec_num($tag, $level) . " $name"
if $number_sections && $tag !~ /^unnumbered/; if $number_sections && $tag !~ /^unnumbered/ && $tag ne 'subsubheading';
if ($tag =~ /heading$/) { if ($tag =~ /heading$/) {
push(@lines, &html_debug("\n", __LINE__)); push(@lines, &html_debug("\n", __LINE__));
if ($html_element ne 'body') { if ($html_element ne 'body') {
...@@ -1079,7 +1093,7 @@ EOC ...@@ -1079,7 +1093,7 @@ EOC
push(@lines, &debug("</TD></TR>\n", __LINE__)) push(@lines, &debug("</TD></TR>\n", __LINE__))
unless $html_element eq 'TABLE'; unless $html_element eq 'TABLE';
&html_pop_if('TR'); &html_pop_if('TR');
$what =~ s|\s+\@tab\s*| </TD><TD> |g; $what =~ s/(^|\s+)\@tab\s*/ <\/TD><TD> /g;
push(@lines, &debug("<TR><TD>$what\n", __LINE__)); push(@lines, &debug("<TR><TD>$what\n", __LINE__));
&html_push('TR'); &html_push('TR');
if ($deferred_ref) if ($deferred_ref)
...@@ -1463,11 +1477,7 @@ print "# end of pass 4\n" if $verbose; ...@@ -1463,11 +1477,7 @@ print "# end of pass 4\n" if $verbose;
# # # #
#---############################################################################ #---############################################################################
$header = <<EOT; $header = '';
<!-- This HTML file has been created by $THISPROG
from $docu on $TODAY -->
EOT
$full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; $full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document";
$title = $value{'_settitle'} || $full_title; $title = $value{'_settitle'} || $full_title;
$_ = &substitute_style($full_title); $_ = &substitute_style($full_title);
...@@ -1815,8 +1825,10 @@ sub fix_image ...@@ -1815,8 +1825,10 @@ sub fix_image
die "error in image: '$text'" unless defined($1); die "error in image: '$text'" unless defined($1);
$arg1 = $1; $arg1 = $1;
$arg1 =~ s/@@/@/g; $arg1 =~ s/@@/@/g;
$ext = "jpg" if -f "$arg1.jpg"; foreach (@include_dirs) {
$ext = "gif" if -f "$arg1.gif"; $ext = "jpg" if -f "$_/$arg1.jpg";
$ext = "gif" if -f "$_/$arg1.gif";
}
if (defined($ext)) if (defined($ext))
{ {
"<IMG SRC=\"$arg1.$ext\">"; "<IMG SRC=\"$arg1.$ext\">";
...@@ -2010,7 +2022,7 @@ sub print_toplevel_header ...@@ -2010,7 +2022,7 @@ sub print_toplevel_header
{ {
local($_); local($_);
&print_header; # pass given arg... &print_header unless $opt_empty_headers; # pass given arg...
print FILE $full_title; print FILE $full_title;
if ($value{'_subtitle'}) { if ($value{'_subtitle'}) {
$value{'_subtitle'} =~ s/\n+$//; $value{'_subtitle'} =~ s/\n+$//;
...@@ -2042,13 +2054,7 @@ EOT ...@@ -2042,13 +2054,7 @@ EOT
sub print_toplevel_footer sub print_toplevel_footer
{ {
&print_ruler; &print_footer unless $opt_empty_headers;
print FILE <<EOT;
This document was generated on $TODAY using the
<A HREF=\"$HOMEPAGE\">texi2html</A>
translator version 1.52 (extended by davida\@detron.se).</P>
EOT
&print_footer;
} }
sub protect_texi sub protect_texi
...@@ -2065,8 +2071,10 @@ sub protect_html ...@@ -2065,8 +2071,10 @@ sub protect_html
{ {
local($what) = @_; local($what) = @_;
# protect & < > # protect & < >
# Avoid loop in & replacement. This instead bugs out for &# in text.. # hack for the two entity-like variable reference in existing examples
$what =~ s/\&([^#]|$)/\&\#38;$1/g; $what =~ s/\&(length|ts);/\&\#38;$1;/g;
# this leaves alone entities, but encodes standalone ampersands
$what =~ s/\&(?!([a-z0-9]+|#\d+);)/\&\#38;/ig;
$what =~ s/\</\&\#60;/g; $what =~ s/\</\&\#60;/g;
$what =~ s/\>/\&\#62;/g; $what =~ s/\>/\&\#62;/g;
# but recognize some HTML things # but recognize some HTML things
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment