version 1.1, 2001/04/02 01:31:49 |
version 1.3, 2016/06/29 15:26:24 |
|
|
#!/usr/bin/perl |
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q' |
|
if 0; |
|
'di '; |
|
'ig 00 '; |
#+############################################################################## |
#+############################################################################## |
# # |
# # |
# File: texi2html # |
# File: texi2html # |
|
|
# # |
# # |
#-############################################################################## |
#-############################################################################## |
|
|
# @(#)texi2html 1.52 01/05/98 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch |
# From @(#)texi2html 1.52 01/05/98 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch |
|
# $Id$ |
|
# This version of texi2html is currently maintained at |
|
# ftp://ftp.cs.umb.edu/pub/tex/texi2html by kb@cs.umb.edu. |
|
|
|
# The man page for this program is included at the end of this file and can be |
|
# viewed using the command 'nroff -man texi2html'. |
# Please read the copyright at the end of the man page. |
# Please read the copyright at the end of the man page. |
|
|
#+++############################################################################ |
#+++############################################################################ |
Line 33 $NODESRE = '[^@{}:\'`"]+'; # RE for a list of node na |
|
Line 41 $NODESRE = '[^@{}:\'`"]+'; # RE for a list of node na |
|
$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"; # program name and version |
$THISVERSION = "1.56k"; |
|
$THISPROG = "texi2html $THISVERSION"; # program name and version |
$HOMEPAGE = "http://wwwinfo.cern.ch/dis/texi2html/"; # program home page |
$HOMEPAGE = "http://wwwinfo.cern.ch/dis/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 |
Line 118 $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD |
|
Line 127 $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD |
|
# cf. makeinfo.c |
# cf. makeinfo.c |
"*", "<BR>", # HTML+ |
"*", "<BR>", # HTML+ |
" ", " ", |
" ", " ", |
|
"\t", " ", |
|
"-", "­", # soft hyphen |
"\n", "\n", |
"\n", "\n", |
"|", "", |
"|", "", |
|
'tab', '<\/TD><TD>', |
# spacing commands |
# spacing commands |
":", "", |
":", "", |
"!", "!", |
"!", "!", |
Line 245 $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD |
|
Line 257 $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD |
|
# comments |
# comments |
'c', 1, |
'c', 1, |
'comment', 1, |
'comment', 1, |
|
'ifnothtml', 1, |
# useless |
# useless |
|
'detailmenu', 1, |
|
'direntry', 1, |
'contents', 1, |
'contents', 1, |
'shortcontents', 1, |
'shortcontents', 1, |
'summarycontents', 1, |
'summarycontents', 1, |
Line 259 $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD |
|
Line 274 $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD |
|
'cropmarks', 1, |
'cropmarks', 1, |
'finalout', 1, |
'finalout', 1, |
'headings', 1, |
'headings', 1, |
|
'sp', 1, |
'need', 1, |
'need', 1, |
'page', 1, |
'page', 1, |
'setchapternewpage', 1, |
'setchapternewpage', 1, |
Line 320 To convert a Texinfo file to HMTL: $0 [options] file |
|
Line 336 To convert a Texinfo file to HMTL: $0 [options] file |
|
-usage : print usage instructions |
-usage : print usage instructions |
-verbose : verbose output |
-verbose : verbose output |
To check converted files: $0 -check [-verbose] files |
To check converted files: $0 -check [-verbose] files |
|
It accepts only ja_JP.EUC and ascii files. |
EOT |
EOT |
|
|
while (@ARGV && $ARGV[0] =~ /^-/) { |
while (@ARGV && $ARGV[0] =~ /^-/) { |
Line 361 if (($split_node || $split_chapter) && $monolithic) { |
|
Line 378 if (($split_node || $split_chapter) && $monolithic) { |
|
if ($expandinfo) { |
if ($expandinfo) { |
$to_skip{'ifinfo'}++; |
$to_skip{'ifinfo'}++; |
$to_skip{'end ifinfo'}++; |
$to_skip{'end ifinfo'}++; |
|
$to_skip{'ifnottex'}++; |
|
$to_skip{'end ifnottex'}++; |
} else { |
} else { |
$to_skip{'iftex'}++; |
$to_skip{'iftex'}++; |
$to_skip{'end iftex'}++; |
$to_skip{'end iftex'}++; |
Line 390 if ($monolithic) { |
|
Line 409 if ($monolithic) { |
|
# variables |
# variables |
# |
# |
$value{'html'} = 1; # predefine html (the output format) |
$value{'html'} = 1; # predefine html (the output format) |
$value{'texi2html'} = '1.52'; # predefine texi2html (the translator) |
$value{'texi2html'} = $THISVERSION; # predefine texi2html (the translator) |
# _foo: internal to track @foo |
# _foo: internal to track @foo |
foreach ('_author', '_title', '_subtitle', |
foreach ('_author', '_title', '_subtitle', |
'_settitle', '_setfilename') { |
'_settitle', '_setfilename') { |
Line 514 while ($_ = &next_line) { |
|
Line 533 while ($_ = &next_line) { |
|
# |
# |
$tag = ''; |
$tag = ''; |
$end_tag = ''; |
$end_tag = ''; |
if (/^\@end\s+(\w+)\b/) { |
if (/^\s*\@end\s+(\w+)\b/) { |
$end_tag = $1; |
$end_tag = $1; |
} elsif (/^\@(\w+)\b/) { |
} elsif (/^\s*\@(\w+)\b/) { |
$tag = $1; |
$tag = $1; |
} |
} |
# |
# |
Line 649 while ($_ = &next_line) { |
|
Line 668 while ($_ = &next_line) { |
|
push(@lines, &debug("<$format_map{$tag}>\n", __LINE__)); |
push(@lines, &debug("<$format_map{$tag}>\n", __LINE__)); |
next; |
next; |
} elsif ($tag eq 'table') { |
} elsif ($tag eq 'table') { |
if (/^\@(|f|v|multi)table\s+\@(\w+)/) { |
if (/^\s*\@(|f|v|multi)table\s+\@(\w+)/) { |
$in_table = $2; |
$in_table = $2; |
unshift(@tables, join($;, $table_type, $in_table)); |
unshift(@tables, join($;, $table_type, $in_table)); |
if ($table_type eq "multi") { |
if ($table_type eq "multi") { |
Line 693 while ($_ = &next_line) { |
|
Line 712 while ($_ = &next_line) { |
|
warn "$ERROR Bad defindex line: $_"; |
warn "$ERROR Bad defindex line: $_"; |
} |
} |
next; |
next; |
|
} elsif ($tag eq 'lowersections') { |
|
local ($sec, $level); |
|
while (($sec, $level) = each %sec2level) { |
|
$sec2level{$sec} = $level + 1; |
|
} |
|
next; |
|
} elsif ($tag eq 'raisesections') { |
|
local ($sec, $level); |
|
while (($sec, $level) = each %sec2level) { |
|
$sec2level{$sec} = $level - 1; |
|
} |
|
next; |
} elsif (defined($def_map{$tag})) { |
} elsif (defined($def_map{$tag})) { |
if ($def_map{$tag}) { |
if ($def_map{$tag}) { |
s/^\@$tag\s+//; |
s/^\@$tag\s+//; |
Line 839 while ($_ = &next_line) { |
|
Line 870 while ($_ = &next_line) { |
|
$name = $1; |
$name = $1; |
$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/; |
if ($tag =~ /heading$/) { |
if ($tag =~ /heading$/) { |
push(@lines, &html_debug("\n", __LINE__)); |
push(@lines, &html_debug("\n", __LINE__)); |
Line 847 while ($_ = &next_line) { |
|
Line 878 while ($_ = &next_line) { |
|
# We are in a nice pickle here. We are trying to get a H? heading |
# We are in a nice pickle here. We are trying to get a H? heading |
# even though we are not in the body level. So, we convert it to a |
# even though we are not in the body level. So, we convert it to a |
# nice, bold, line by itself. |
# nice, bold, line by itself. |
$_ = &debug("\n\n<P><STRONG>$name</STRONG></P>\n\n", __LINE__); |
$_ = &debug("\n\n<P><STRONG>$name</STRONG>\n\n", __LINE__); |
} else { |
} else { |
$_ = &debug("<H$level>$name</H$level>\n", __LINE__); |
$_ = &debug("<H$level>$name</H$level>\n", __LINE__); |
&html_push_if('body'); |
&html_push_if('body'); |
|
|
next; |
next; |
} |
} |
# list item |
# list item |
if (/^\@itemx?\s+/) { |
if (/^\s*\@itemx?\s+/) { |
$what = $'; |
$what = $'; |
$what =~ s/\s+$//; |
$what =~ s/\s+$//; |
if ($in_bibliography && $use_bibliography) { |
if ($in_bibliography && $use_bibliography) { |
|
|
next if $#lines >= 0 && $lines[$#lines] eq "\n"; |
next if $#lines >= 0 && $lines[$#lines] eq "\n"; |
if ($html_element eq 'P') { |
if ($html_element eq 'P') { |
push(@lines, "\n"); |
push(@lines, "\n"); |
$_ = &debug("</P>\n", __LINE__); |
$_ = &debug("\n", __LINE__); |
&html_pop; |
&html_pop; |
} |
} |
} elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE') { |
} elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE') { |
Line 1215 while (@lines) { |
|
Line 1246 while (@lines) { |
|
$_ = "$before$;0xref{$nodes}$after"; |
$_ = "$before$;0xref{$nodes}$after"; |
} |
} |
} |
} |
|
|
|
if (/^\@image\s*{/) { |
|
s/\@image\s*{//; |
|
my (@args) = split (/,/); |
|
my $base = $args[0]; |
|
my $image; |
|
if (-r "$base.jpg") { |
|
$image = "$base.jpg"; |
|
} elsif (-r "$base.png") { |
|
$image = "$base.png"; |
|
} elsif (-r "$base.gif") { |
|
$image = "$base.gif"; |
|
} else { |
|
warn "$ERROR no image file for $base: $_"; |
|
} |
|
$_ = "<IMG SRC=\"$image\" ALT=\"$base\">"; |
|
} |
|
|
# |
# |
# try to guess bibliography references or glossary terms |
# try to guess bibliography references or glossary terms |
# |
# |
Line 1378 print "# end of pass 4\n" if $verbose; |
|
Line 1427 print "# end of pass 4\n" if $verbose; |
|
#---############################################################################ |
#---############################################################################ |
|
|
$header = <<EOT; |
$header = <<EOT; |
<!-- This HTML file has been created by $THISPROG |
<!-- Created by $THISPROG from $docu on $TODAY --> |
from $docu on $TODAY --> |
|
EOT |
EOT |
|
|
$full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; |
$full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; |
Line 1506 print "# that's all folks\n" if $verbose; |
|
Line 1554 print "# that's all folks\n" if $verbose; |
|
|
|
sub update_sec_num { |
sub update_sec_num { |
local($name, $level) = @_; |
local($name, $level) = @_; |
|
my $ret; |
|
|
$level--; # here we start at 0 |
$level--; # here we start at 0 |
if ($name =~ /^appendix/) { |
if ($name =~ /^appendix/) { |
# appendix style |
# appendix style |
if (defined(@appendix_sec_num)) { |
if ( @appendix_sec_num ) { |
&incr_sec_num($level, @appendix_sec_num); |
&incr_sec_num($level, @appendix_sec_num); |
} else { |
} else { |
@appendix_sec_num = ('A', 0, 0, 0); |
@appendix_sec_num = ('A', 0, 0, 0); |
} |
} |
return(join('.', @appendix_sec_num[0..$level])); |
$ret = join('.', @appendix_sec_num[0..$level]); |
} else { |
} else { |
# normal style |
# normal style |
if (defined(@normal_sec_num)) { |
if ( @normal_sec_num ) { |
&incr_sec_num($level, @normal_sec_num); |
&incr_sec_num($level, @normal_sec_num); |
} else { |
} else { |
@normal_sec_num = (1, 0, 0, 0); |
@normal_sec_num = (1, 0, 0, 0); |
} |
} |
return(join('.', @normal_sec_num[0..$level])); |
$ret = join('.', @normal_sec_num[0..$level]); |
} |
} |
|
|
|
$ret .= "." if $level == 0; |
|
return $ret; |
} |
} |
|
|
sub incr_sec_num { |
sub incr_sec_num { |
|
|
sub pretty_date { |
sub pretty_date { |
local(@MoY, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); |
local(@MoY, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); |
|
|
@MoY = ('January', 'Febuary', 'March', 'April', 'May', 'June', |
@MoY = ('January', 'February', 'March', 'April', 'May', 'June', |
'July', 'August', 'September', 'October', 'November', 'December'); |
'July', 'August', 'September', 'October', 'November', 'December'); |
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); |
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); |
$year += ($year < 70) ? 2000 : 1900; |
$year += ($year < 70) ? 2000 : 1900; |
Line 1832 sub print_header { |
|
Line 1884 sub print_header { |
|
} |
} |
print FILE <<EOT; |
print FILE <<EOT; |
<HTML> |
<HTML> |
|
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis"> |
<HEAD> |
<HEAD> |
$header |
$header |
<TITLE>$_</TITLE> |
<TITLE>$_</TITLE> |
|
|
sub print_toplevel_footer { |
sub print_toplevel_footer { |
&print_ruler; |
&print_ruler; |
print FILE <<EOT; |
print FILE <<EOT; |
This document was generated on $TODAY using the |
This document was generated on $TODAY using |
<A HREF=\"$HOMEPAGE\">texi2html</A> |
<A HREF=\"$HOMEPAGE\">texi2html</A> $value{texi2html}. |
translator version 1.52.</P> |
|
EOT |
EOT |
&print_footer; |
&print_footer; |
} |
} |
|
|
$key2alpha{$a} cmp $key2alpha{$b}; |
$key2alpha{$a} cmp $key2alpha{$b}; |
} |
} |
|
|
|
############################################################################## |
|
|
|
# These next few lines are legal in both Perl and nroff. |
|
|
|
.00 ; # finish .ig |
|
|
|
'di \" finish diversion--previous line must be blank |
|
.nr nl 0-1 \" fake up transition to first page again |
|
.nr % 0 \" start at page 1 |
|
'; __END__ ############# From here on it's a standard manual page ############ |
|
.TH TEXI2HTML 1 "01/05/98" |
|
.AT 3 |
|
.SH NAME |
|
texi2html \- a Texinfo to HTML converter |
|
.SH SYNOPSIS |
|
.B texi2html [options] file |
|
.PP |
|
.B texi2html -check [-verbose] files |
|
.SH DESCRIPTION |
|
.I Texi2html |
|
converts the given Texinfo file to a set of HTML files. It tries to handle |
|
most of the Texinfo commands. It creates hypertext links for cross-references, |
|
footnotes... |
|
.PP |
|
It also tries to add links from a reference to its corresponding entry in the |
|
bibliography (if any). It may also handle a glossary (see the |
|
.B \-glossary |
|
option). |
|
.PP |
|
.I Texi2html |
|
creates several files depending on the contents of the Texinfo file and on |
|
the chosen options (see FILES). |
|
.PP |
|
The HTML files created by |
|
.I texi2html |
|
are closer to TeX than to Info, that's why |
|
.I texi2html |
|
converts @iftex sections and not @ifinfo ones by default. You can reverse |
|
this with the \-expandinfo option. |
|
.SH OPTIONS |
|
.TP 12 |
|
.B \-check |
|
Check the given file and give the list of all things that may be Texinfo commands. |
|
This may be used to check the output of |
|
.I texi2html |
|
to find the Texinfo commands that have been left in the HTML file. |
|
.TP |
|
.B \-expandinfo |
|
Expand @ifinfo sections, not @iftex ones. |
|
.TP |
|
.B \-glossary |
|
Use the section named 'Glossary' to build a list of terms and put links in the HTML |
|
document from each term toward its definition. |
|
.TP |
|
.B \-invisible \fIname\fP |
|
Use \fIname\fP to create invisible destination anchors for index links |
|
(you can for instance use the invisible.xbm file shipped with this program). |
|
This is a workaround for a known bug of many WWW browsers, including netscape. |
|
.TP |
|
.B \-I \fIdir\fP |
|
Look also in \fIdir\fP to find included files. |
|
.TP |
|
.B \-menu |
|
Show the Texinfo menus; by default they are ignored. |
|
.TP |
|
.B \-monolithic |
|
Output only one file, including the table of contents and footnotes. |
|
.TP |
|
.B \-number |
|
Number the sections. |
|
.TP |
|
.B \-split_chapter |
|
Split the output into several HTML files (one per main section: |
|
chapter, appendix...). |
|
.TP |
|
.B \-split_node |
|
Split the output into several HTML files (one per node). |
|
.TP |
|
.B \-usage |
|
Print usage instructions, listing the current available command-line options. |
|
.TP |
|
.B \-verbose |
|
Give a verbose output. Can be used with the |
|
.B \-check |
|
option. |
|
.PP |
|
.SH FILES |
|
By default |
|
.I texi2html |
|
creates the following files (foo being the name of the Texinfo file): |
|
.TP 16 |
|
.B foo_toc.html |
|
The table of contents. |
|
.TP |
|
.B foo.html |
|
The document's contents. |
|
.TP |
|
.B foo_foot.html |
|
The footnotes (if any). |
|
.PP |
|
When used with the |
|
.B \-split |
|
option, it creates several files (one per chapter or node), named |
|
.B foo_n.html |
|
(n being the indice of the chapter or node), instead of the single |
|
.B foo.html |
|
file. |
|
.PP |
|
When used with the |
|
.B \-monolithic |
|
option, it creates only one file: |
|
.B foo.html |
|
.SH VARIABLES |
|
.I texi2html |
|
predefines the following variables: \fBhtml\fP, \fBtexi2html\fP. |
|
.SH ADDITIONAL COMMANDS |
|
.I texi2html |
|
implements the following non-Texinfo commands (maybe they are in Texinfo now...): |
|
.TP 16 |
|
.B @ifhtml |
|
This indicates the start of an HTML section, this section will passed through |
|
without any modification. |
|
.TP |
|
.B @end ifhtml |
|
This indicates the end of an HTML section. |
|
.SH VERSION |
|
This is \fItexi2html\fP version 1.56k, 1999-02-20. |
|
.PP |
|
The latest version of \fItexi2html\fP can be found in WWW, cf. URLs |
|
http://wwwinfo.cern.ch/dis/texi2html/ |
|
.br |
|
http://texinfo.org/texi2html/ |
|
.SH AUTHOR |
|
The main author is Lionel Cons, CERN IT/DIS/OSE, Lionel.Cons@cern.ch. |
|
Many other people around the net contributed to this program. |
|
.SH COPYRIGHT |
|
This program is the intellectual property of the European |
|
Laboratory for Particle Physics (known as CERN). No guarantee whatsoever is |
|
provided by CERN. No liability whatsoever is accepted for any loss or damage |
|
of any kind resulting from any defect or inaccuracy in this information or |
|
code. |
|
.PP |
|
CERN, 1211 Geneva 23, Switzerland |
|
.SH "SEE ALSO" |
|
GNU Texinfo Documentation Format, |
|
HyperText Markup Language (HTML), |
|
World Wide Web (WWW). |
|
.SH BUGS |
|
This program does not understand all Texinfo commands (yet). |
|
.PP |
|
TeX specific commands (normally enclosed in @iftex) will be |
|
passed unmodified. |
|
.ex |