| 1 |
#!/usr/bin/env perl |
| 2 |
'di '; |
| 3 |
'ig 00 '; |
| 4 |
#+############################################################################## |
| 5 |
# # |
| 6 |
# File: texi2html # |
| 7 |
# # |
| 8 |
# Description: Program to transform most Texinfo documents to HTML # |
| 9 |
# # |
| 10 |
#-############################################################################## |
| 11 |
|
| 12 |
# @(#)texi2html 1.52b 01/05/98 Written (mainly) by Lionel Cons, [email protected] |
| 13 |
# 1.52a: Use acute accent instead of apostrophe. Add support for ISO-8859-1 |
| 14 |
# characters with cedilla, circumflex etc. |
| 15 |
# 1.52b: Add option -expandtex. Expand @ifhtml by default, not @ifinfo. |
| 16 |
# Use Unicode quotation marks instead of grave and acute accents. |
| 17 |
# Emit charset=UTF-8 declaration. |
| 18 |
|
| 19 |
# The man page for this program is included at the end of this file and can be |
| 20 |
# viewed using the command 'nroff -man texi2html'. |
| 21 |
# Please read the copyright at the end of the man page. |
| 22 |
|
| 23 |
#+++############################################################################ |
| 24 |
# # |
| 25 |
# Constants # |
| 26 |
# # |
| 27 |
#---############################################################################ |
| 28 |
|
| 29 |
$DEBUG_TOC = 1; |
| 30 |
$DEBUG_INDEX = 2; |
| 31 |
$DEBUG_BIB = 4; |
| 32 |
$DEBUG_GLOSS = 8; |
| 33 |
$DEBUG_DEF = 16; |
| 34 |
$DEBUG_HTML = 32; |
| 35 |
$DEBUG_USER = 64; |
| 36 |
|
| 37 |
$BIBRE = '\[[\w\/-]+\]'; # RE for a bibliography reference |
| 38 |
$FILERE = '[\/\w.+-]+'; # RE for a file name |
| 39 |
$VARRE = '[^\s\{\}]+'; # RE for a variable name |
| 40 |
$NODERE = '[^@{}:\'`",]+'; # RE for a node name |
| 41 |
$NODESRE = '[^@{}:\'`"]+'; # RE for a list of node names |
| 42 |
$XREFRE = '[^@{}]+'; # RE for a xref (should use NODERE) |
| 43 |
|
| 44 |
$ERROR = "***"; # prefix for errors and warnings |
| 45 |
$THISPROG = "texi2html 1.52b"; # program name and version |
| 46 |
$HOMEPAGE = "http://wwwinfo.cern.ch/dis/texi2html/"; # program home page |
| 47 |
$TODAY = &pretty_date; # like "20 September 1993" |
| 48 |
$SPLITTAG = "<!-- SPLIT HERE -->\n"; # tag to know where to split |
| 49 |
$PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections |
| 50 |
$html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//EN">'; |
| 51 |
|
| 52 |
# |
| 53 |
# language dependent constants |
| 54 |
# |
| 55 |
#$LDC_SEE = 'see'; |
| 56 |
#$LDC_SECTION = 'section'; |
| 57 |
#$LDC_IN = 'in'; |
| 58 |
#$LDC_TOC = 'Table of Contents'; |
| 59 |
#$LDC_GOTO = 'Go to the'; |
| 60 |
#$LDC_FOOT = 'Footnotes'; |
| 61 |
# TODO: @def* shortcuts |
| 62 |
|
| 63 |
# |
| 64 |
# pre-defined indices |
| 65 |
# |
| 66 |
%predefined_index = ( |
| 67 |
'cp', 'c', |
| 68 |
'fn', 'f', |
| 69 |
'vr', 'v', |
| 70 |
'ky', 'k', |
| 71 |
'pg', 'p', |
| 72 |
'tp', 't', |
| 73 |
); |
| 74 |
|
| 75 |
# |
| 76 |
# valid indices |
| 77 |
# |
| 78 |
%valid_index = ( |
| 79 |
'c', 1, |
| 80 |
'f', 1, |
| 81 |
'v', 1, |
| 82 |
'k', 1, |
| 83 |
'p', 1, |
| 84 |
't', 1, |
| 85 |
); |
| 86 |
|
| 87 |
# |
| 88 |
# texinfo section names to level |
| 89 |
# |
| 90 |
%sec2level = ( |
| 91 |
'top', 0, |
| 92 |
'chapter', 1, |
| 93 |
'unnumbered', 1, |
| 94 |
'majorheading', 1, |
| 95 |
'chapheading', 1, |
| 96 |
'appendix', 1, |
| 97 |
'section', 2, |
| 98 |
'unnumberedsec', 2, |
| 99 |
'heading', 2, |
| 100 |
'appendixsec', 2, |
| 101 |
'appendixsection', 2, |
| 102 |
'subsection', 3, |
| 103 |
'unnumberedsubsec', 3, |
| 104 |
'subheading', 3, |
| 105 |
'appendixsubsec', 3, |
| 106 |
'subsubsection', 4, |
| 107 |
'unnumberedsubsubsec', 4, |
| 108 |
'subsubheading', 4, |
| 109 |
'appendixsubsubsec', 4, |
| 110 |
); |
| 111 |
|
| 112 |
# |
| 113 |
# accent map, TeX command to ISO name |
| 114 |
# |
| 115 |
%accent_map = ( |
| 116 |
'"', 'uml', |
| 117 |
'~', 'tilde', |
| 118 |
'^', 'circ', |
| 119 |
'`', 'grave', |
| 120 |
'\'', 'acute', |
| 121 |
); |
| 122 |
|
| 123 |
# |
| 124 |
# texinfo "simple things" (@foo) to HTML ones |
| 125 |
# |
| 126 |
%simple_map = ( |
| 127 |
# cf. makeinfo.c |
| 128 |
"*", "<BR>", # HTML+ |
| 129 |
" ", " ", |
| 130 |
"\n", "\n", |
| 131 |
"|", "", |
| 132 |
# spacing commands |
| 133 |
":", "", |
| 134 |
"!", "!", |
| 135 |
"?", "?", |
| 136 |
".", ".", |
| 137 |
"-", "", |
| 138 |
); |
| 139 |
|
| 140 |
# |
| 141 |
# texinfo "things" (@foo{}) to HTML ones |
| 142 |
# |
| 143 |
%things_map = ( |
| 144 |
'TeX', 'TeX', |
| 145 |
'br', '<P>', # paragraph break |
| 146 |
'bullet', '*', |
| 147 |
'copyright', '(C)', |
| 148 |
'dots', '...', |
| 149 |
'equiv', '==', |
| 150 |
'error', 'error-->', |
| 151 |
'expansion', '==>', |
| 152 |
'minus', '-', |
| 153 |
'point', '-!-', |
| 154 |
'print', '-|', |
| 155 |
'result', '=>', |
| 156 |
'today', $TODAY, |
| 157 |
'aa', 'å', |
| 158 |
'AA', 'Å', |
| 159 |
'ae', 'æ', |
| 160 |
'AE', 'Æ', |
| 161 |
'o', 'ø', |
| 162 |
'O', 'Ø', |
| 163 |
'ss', 'ß', |
| 164 |
'exclamdown', '¡', |
| 165 |
'questiondown', '¿', |
| 166 |
'pounds', '£' |
| 167 |
); |
| 168 |
|
| 169 |
# |
| 170 |
# texinfo styles (@foo{bar}) to HTML ones |
| 171 |
# |
| 172 |
%style_map = ( |
| 173 |
'asis', '', |
| 174 |
'b', 'B', |
| 175 |
'cite', 'CITE', |
| 176 |
'code', 'CODE', |
| 177 |
'ctrl', '&do_ctrl', # special case |
| 178 |
'dfn', 'EM', # DFN tag is illegal in the standard |
| 179 |
'dmn', '', # useless |
| 180 |
'email', '&do_email', # insert a clickable email address |
| 181 |
'emph', 'EM', |
| 182 |
'file', '"TT', # will put quotes, cf. &apply_style |
| 183 |
'i', 'I', |
| 184 |
'kbd', 'KBD', |
| 185 |
'key', 'KBD', |
| 186 |
'math', 'EM', |
| 187 |
'r', '', # unsupported |
| 188 |
'samp', '"SAMP', # will put quotes, cf. &apply_style |
| 189 |
'sc', '&do_sc', # special case |
| 190 |
'strong', 'STRONG', |
| 191 |
't', 'TT', |
| 192 |
'titlefont', '', # useless |
| 193 |
'uref', '&do_uref', # insert a clickable URL |
| 194 |
'url', '&do_url', # insert a clickable URL |
| 195 |
'var', 'VAR', |
| 196 |
'w', '', # unsupported |
| 197 |
'"', '&do_diaeresis', |
| 198 |
'\'', '&do_acuteaccent', # doesn't work?? |
| 199 |
'\`', '&do_graveaccent', # doesn't work?? |
| 200 |
'~', '&do_tildeaccent', |
| 201 |
',', '&do_cedilla', |
| 202 |
'^', '&do_circumflex', |
| 203 |
); |
| 204 |
|
| 205 |
# |
| 206 |
# texinfo format (@foo/@end foo) to HTML ones |
| 207 |
# |
| 208 |
%format_map = ( |
| 209 |
'display', 'PRE', |
| 210 |
'example', 'PRE', |
| 211 |
'format', 'PRE', |
| 212 |
'lisp', 'PRE', |
| 213 |
'quotation', 'BLOCKQUOTE', |
| 214 |
'smallexample', 'PRE', |
| 215 |
'smalllisp', 'PRE', |
| 216 |
# lists |
| 217 |
'itemize', 'UL', |
| 218 |
'enumerate', 'OL', |
| 219 |
# poorly supported |
| 220 |
'flushleft', 'PRE', |
| 221 |
'flushright', 'PRE', |
| 222 |
); |
| 223 |
|
| 224 |
# |
| 225 |
# texinfo definition shortcuts to real ones |
| 226 |
# |
| 227 |
%def_map = ( |
| 228 |
# basic commands |
| 229 |
'deffn', 0, |
| 230 |
'defvr', 0, |
| 231 |
'deftypefn', 0, |
| 232 |
'deftypevr', 0, |
| 233 |
'defcv', 0, |
| 234 |
'defop', 0, |
| 235 |
'deftp', 0, |
| 236 |
# basic x commands |
| 237 |
'deffnx', 0, |
| 238 |
'defvrx', 0, |
| 239 |
'deftypefnx', 0, |
| 240 |
'deftypevrx', 0, |
| 241 |
'defcvx', 0, |
| 242 |
'defopx', 0, |
| 243 |
'deftpx', 0, |
| 244 |
# shortcuts |
| 245 |
'defun', 'deffn Function', |
| 246 |
'defmac', 'deffn Macro', |
| 247 |
'defspec', 'deffn {Special Form}', |
| 248 |
'defvar', 'defvr Variable', |
| 249 |
'defopt', 'defvr {User Option}', |
| 250 |
'deftypefun', 'deftypefn Function', |
| 251 |
'deftypevar', 'deftypevr Variable', |
| 252 |
'defivar', 'defcv {Instance Variable}', |
| 253 |
'defmethod', 'defop Method', |
| 254 |
# x shortcuts |
| 255 |
'defunx', 'deffnx Function', |
| 256 |
'defmacx', 'deffnx Macro', |
| 257 |
'defspecx', 'deffnx {Special Form}', |
| 258 |
'defvarx', 'defvrx Variable', |
| 259 |
'defoptx', 'defvrx {User Option}', |
| 260 |
'deftypefunx', 'deftypefnx Function', |
| 261 |
'deftypevarx', 'deftypevrx Variable', |
| 262 |
'defivarx', 'defcvx {Instance Variable}', |
| 263 |
'defmethodx', 'defopx Method', |
| 264 |
); |
| 265 |
|
| 266 |
# |
| 267 |
# things to skip |
| 268 |
# |
| 269 |
%to_skip = ( |
| 270 |
# comments |
| 271 |
'c', 1, |
| 272 |
'comment', 1, |
| 273 |
# useless |
| 274 |
'contents', 1, |
| 275 |
'shortcontents', 1, |
| 276 |
'summarycontents', 1, |
| 277 |
'footnotestyle', 1, |
| 278 |
'end ifclear', 1, |
| 279 |
'end ifset', 1, |
| 280 |
'titlepage', 1, |
| 281 |
'end titlepage', 1, |
| 282 |
# unsupported commands (formatting) |
| 283 |
'afourpaper', 1, |
| 284 |
'cropmarks', 1, |
| 285 |
'finalout', 1, |
| 286 |
'headings', 1, |
| 287 |
'need', 1, |
| 288 |
'page', 1, |
| 289 |
'setchapternewpage', 1, |
| 290 |
'everyheading', 1, |
| 291 |
'everyfooting', 1, |
| 292 |
'evenheading', 1, |
| 293 |
'evenfooting', 1, |
| 294 |
'oddheading', 1, |
| 295 |
'oddfooting', 1, |
| 296 |
'smallbook', 1, |
| 297 |
'vskip', 1, |
| 298 |
'filbreak', 1, |
| 299 |
'paragraphindent', 1, |
| 300 |
# unsupported formats |
| 301 |
'cartouche', 1, |
| 302 |
'end cartouche', 1, |
| 303 |
'group', 1, |
| 304 |
'end group', 1, |
| 305 |
); |
| 306 |
|
| 307 |
#+++############################################################################ |
| 308 |
# # |
| 309 |
# Argument parsing, initialisation # |
| 310 |
# # |
| 311 |
#---############################################################################ |
| 312 |
|
| 313 |
%value = (); # hold texinfo variables, see also -D |
| 314 |
|
| 315 |
$use_bibliography = 1; |
| 316 |
$use_acc = 0; |
| 317 |
$debug = 0; |
| 318 |
$doctype = ''; |
| 319 |
$check = 0; |
| 320 |
$expandinfo = 0; |
| 321 |
$expandtex = 0; |
| 322 |
$use_glossary = 0; |
| 323 |
$invisible_mark = ''; |
| 324 |
$use_iso = 0; |
| 325 |
@include_dirs = (); |
| 326 |
$show_menu = 0; |
| 327 |
$number_sections = 0; |
| 328 |
$split_node = 0; |
| 329 |
$split_chapter = 0; |
| 330 |
$monolithic = 0; |
| 331 |
$verbose = 0; |
| 332 |
$output_dir = '.'; |
| 333 |
$usage = <<EOT; |
| 334 |
This is $THISPROG |
| 335 |
To convert a Texinfo file to HMTL: $0 [options] file |
| 336 |
where options can be: |
| 337 |
-expandinfo : use \@ifinfo sections, not \@ifhtml |
| 338 |
-expandtex : use \@iftex sections, not \@ifhtml |
| 339 |
-glossary : handle a glossary |
| 340 |
-invisible name: use 'name' as an invisible anchor |
| 341 |
-Dname : define name like with \@set |
| 342 |
-I dir : search also for files in 'dir' |
| 343 |
-menu : handle menus |
| 344 |
-monolithic : output only one file including ToC |
| 345 |
-number : number sections |
| 346 |
-outdir DIR : output directory |
| 347 |
-split_chapter : split on main sections |
| 348 |
-split_node : split on nodes |
| 349 |
-usage : print usage instructions |
| 350 |
-verbose : verbose output |
| 351 |
To check converted files: $0 -check [-verbose] files |
| 352 |
EOT |
| 353 |
|
| 354 |
while (@ARGV && $ARGV[0] =~ /^-/) { |
| 355 |
$_ = shift(@ARGV); |
| 356 |
if (/^-acc$/) { $use_acc = 1; next; } |
| 357 |
if (/^-d(ebug)?(\d+)?$/) { $debug = $2 || shift(@ARGV); next; } |
| 358 |
if (/^-doctype$/) { $doctype = shift(@ARGV); next; } |
| 359 |
if (/^-c(heck)?$/) { $check = 1; next; } |
| 360 |
if (/^-expandi(nfo)?$/) { $expandinfo = 1; next; } |
| 361 |
if (/^-expandt(ex)?$/) { $expandtex = 1; next; } |
| 362 |
if (/^-g(lossary)?$/) { $use_glossary = 1; next; } |
| 363 |
if (/^-i(nvisible)?$/) { $invisible_mark = shift(@ARGV); next; } |
| 364 |
if (/^-iso$/) { $use_iso = 1; next; } |
| 365 |
if (/^-D(.+)?$/) { $value{$1 || shift(@ARGV)} = 1; next; } |
| 366 |
if (/^-I(.+)?$/) { push(@include_dirs, $1 || shift(@ARGV)); next; } |
| 367 |
if (/^-m(enu)?$/) { $show_menu = 1; next; } |
| 368 |
if (/^-mono(lithic)?$/) { $monolithic = 1; next; } |
| 369 |
if (/^-n(umber)?$/) { $number_sections = 1; next; } |
| 370 |
if (/^-s(plit)?_?(n(ode)?|c(hapter)?)?$/) { |
| 371 |
if ($2 =~ /^n/) { |
| 372 |
$split_node = 1; |
| 373 |
} else { |
| 374 |
$split_chapter = 1; |
| 375 |
} |
| 376 |
next; |
| 377 |
} |
| 378 |
if (/^-v(erbose)?$/) { $verbose = 1; next; } |
| 379 |
if (/^-o(utdir=?)?(.+)?$/) { $output_dir = $2 || shift(@ARGV); next; } |
| 380 |
die $usage; |
| 381 |
} |
| 382 |
if ($check) { |
| 383 |
die $usage unless @ARGV > 0; |
| 384 |
✓ |
| 385 |
exit; |
| 386 |
} |
| 387 |
|
| 388 |
if (($split_node || $split_chapter) && $monolithic) { |
| 389 |
warn "Can't use -monolithic with -split, -monolithic ignored.\n"; |
| 390 |
$monolithic = 0; |
| 391 |
} |
| 392 |
if ($expandinfo) { |
| 393 |
$to_skip{'ifinfo'}++; |
| 394 |
$to_skip{'end ifinfo'}++; |
| 395 |
$to_skip{'ifnottex'}++; |
| 396 |
$to_skip{'end ifnottex'}++; |
| 397 |
$to_skip{'ifnothtml'}++; |
| 398 |
$to_skip{'end ifnothtml'}++; |
| 399 |
} elsif ($expandtex) { |
| 400 |
$to_skip{'ifnotinfo'}++; |
| 401 |
$to_skip{'end ifnotinfo'}++; |
| 402 |
$to_skip{'iftex'}++; |
| 403 |
$to_skip{'end iftex'}++; |
| 404 |
$to_skip{'ifnothtml'}++; |
| 405 |
$to_skip{'end ifnothtml'}++; |
| 406 |
} else { |
| 407 |
$to_skip{'ifnotinfo'}++; |
| 408 |
$to_skip{'end ifnotinfo'}++; |
| 409 |
$to_skip{'ifnottex'}++; |
| 410 |
$to_skip{'end ifnottex'}++; |
| 411 |
$to_skip{'ifhtml'}++; |
| 412 |
$to_skip{'end ifhtml'}++; |
| 413 |
} |
| 414 |
$invisible_mark = '<IMG SRC="invisible.xbm">' if $invisible_mark eq 'xbm'; |
| 415 |
die $usage unless @ARGV == 1; |
| 416 |
$docu = shift(@ARGV); |
| 417 |
if ($docu =~ /.*\//) { |
| 418 |
chop($docu_dir = $&); |
| 419 |
$docu_name = $'; |
| 420 |
} else { |
| 421 |
$docu_dir = '.'; |
| 422 |
$docu_name = $docu; |
| 423 |
} |
| 424 |
unshift(@include_dirs, $docu_dir); |
| 425 |
$docu_name =~ s/\.te?x(i|info)?$//; # basename of the document |
| 426 |
|
| 427 |
$docu_doc = "$docu_name.html"; # document's contents |
| 428 |
if ($monolithic) { |
| 429 |
$docu_toc = $docu_foot = $docu_doc; |
| 430 |
} else { |
| 431 |
$docu_toc = "${docu_name}_toc.html"; # document's table of contents |
| 432 |
$docu_foot = "${docu_name}_foot.html"; # document's footnotes |
| 433 |
} |
| 434 |
|
| 435 |
# |
| 436 |
# variables |
| 437 |
# |
| 438 |
$value{'html'} = 1; # predefine html (the output format) |
| 439 |
$value{'texi2html'} = '1.52b'; # predefine texi2html (the translator) |
| 440 |
# _foo: internal to track @foo |
| 441 |
foreach ('_author', '_title', '_subtitle', |
| 442 |
'_settitle', '_setfilename') { |
| 443 |
$value{$_} = ''; # prevent -w warnings |
| 444 |
} |
| 445 |
%node2sec = (); # node to section name |
| 446 |
%node2href = (); # node to HREF |
| 447 |
%bib2href = (); # bibliography reference to HREF |
| 448 |
%gloss2href = (); # glossary term to HREF |
| 449 |
@sections = (); # list of sections |
| 450 |
%tag2pro = (); # protected sections |
| 451 |
|
| 452 |
# |
| 453 |
# initial indexes |
| 454 |
# |
| 455 |
$bib_num = 0; |
| 456 |
$foot_num = 0; |
| 457 |
$gloss_num = 0; |
| 458 |
$idx_num = 0; |
| 459 |
$sec_num = 0; |
| 460 |
$doc_num = 0; |
| 461 |
$html_num = 0; |
| 462 |
|
| 463 |
# |
| 464 |
# can I use ISO8879 characters? (HTML+) |
| 465 |
# |
| 466 |
if ($use_iso) { |
| 467 |
$things_map{'bullet'} = "•"; |
| 468 |
$things_map{'copyright'} = "©"; |
| 469 |
$things_map{'dots'} = "…"; |
| 470 |
$things_map{'equiv'} = "≡"; |
| 471 |
$things_map{'expansion'} = "→"; |
| 472 |
$things_map{'point'} = "∗"; |
| 473 |
$things_map{'result'} = "⇒"; |
| 474 |
} |
| 475 |
|
| 476 |
# |
| 477 |
# read texi2html extensions (if any) |
| 478 |
# |
| 479 |
$extensions = 'texi2html.ext'; # extensions in working directory |
| 480 |
if (-f $extensions) { |
| 481 |
print "# reading extensions from $extensions\n" if $verbose; |
| 482 |
require($extensions); |
| 483 |
} |
| 484 |
($progdir = $0) =~ s/[^\/]+$//; |
| 485 |
if ($progdir && ($progdir ne './')) { |
| 486 |
$extensions = "${progdir}texi2html.ext"; # extensions in texi2html directory |
| 487 |
if (-f $extensions) { |
| 488 |
print "# reading extensions from $extensions\n" if $verbose; |
| 489 |
require($extensions); |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
print "# reading from $docu\n" if $verbose; |
| 494 |
|
| 495 |
#+++############################################################################ |
| 496 |
# # |
| 497 |
# Pass 1: read source, handle command, variable, simple substitution # |
| 498 |
# # |
| 499 |
#---############################################################################ |
| 500 |
|
| 501 |
@lines = (); # whole document |
| 502 |
@toc_lines = (); # table of contents |
| 503 |
$toplevel = 0; # top level seen in hierarchy |
| 504 |
$curlevel = 0; # current level in TOC |
| 505 |
$node = ''; # current node name |
| 506 |
$in_table = 0; # am I inside a table |
| 507 |
$table_type = ''; # type of table ('', 'f', 'v', 'multi') |
| 508 |
@tables = (); # nested table support |
| 509 |
$in_bibliography = 0; # am I inside a bibliography |
| 510 |
$in_glossary = 0; # am I inside a glossary |
| 511 |
$in_top = 0; # am I inside the top node |
| 512 |
$in_pre = 0; # am I inside a preformatted section |
| 513 |
$in_list = 0; # am I inside a list |
| 514 |
$in_html = 0; # am I inside an HTML section |
| 515 |
$first_line = 1; # is it the first line |
| 516 |
$dont_html = 0; # don't protect HTML on this line |
| 517 |
$split_num = 0; # split index |
| 518 |
$deferred_ref = ''; # deferred reference for indexes |
| 519 |
@html_stack = (); # HTML elements stack |
| 520 |
$html_element = ''; # current HTML element |
| 521 |
&html_reset; |
| 522 |
|
| 523 |
# build code for simple substitutions |
| 524 |
# the maps used (%simple_map and %things_map) MUST be aware of this |
| 525 |
# watch out for regexps, / and escaped characters! |
| 526 |
$subst_code = ''; |
| 527 |
foreach (keys(%simple_map)) { |
| 528 |
($re = $_) =~ s/(\W)/\\$1/g; # protect regexp chars |
| 529 |
$subst_code .= "s/\\\@$re/$simple_map{$_}/g;\n"; |
| 530 |
} |
| 531 |
foreach (keys(%things_map)) { |
| 532 |
$subst_code .= "s/\\\@$_\\{\\}/$things_map{$_}/g;\n"; |
| 533 |
} |
| 534 |
if ($use_acc) { |
| 535 |
# accentuated characters |
| 536 |
foreach (keys(%accent_map)) { |
| 537 |
if ($_ eq "`") { |
| 538 |
$subst_code .= "s/$;3"; |
| 539 |
} elsif ($_ eq "'") { |
| 540 |
$subst_code .= "s/$;4"; |
| 541 |
} else { |
| 542 |
$subst_code .= "s/\\\@\\$_"; |
| 543 |
} |
| 544 |
$subst_code .= "([aeiou])/&\${1}$accent_map{$_};/gi;\n"; |
| 545 |
} |
| 546 |
} |
| 547 |
eval("sub simple_substitutions { $subst_code }"); |
| 548 |
|
| 549 |
&init_input; |
| 550 |
while ($_ = &next_line) { |
| 551 |
# |
| 552 |
# remove \input on the first lines only |
| 553 |
# |
| 554 |
if ($first_line) { |
| 555 |
next if /^\\input/; |
| 556 |
$first_line = 0; |
| 557 |
} |
| 558 |
# |
| 559 |
# parse texinfo tags |
| 560 |
# |
| 561 |
$tag = ''; |
| 562 |
$end_tag = ''; |
| 563 |
if (/^\@end\s+(\w+)\b/) { |
| 564 |
$end_tag = $1; |
| 565 |
} elsif (/^\@(\w+)\b/) { |
| 566 |
$tag = $1; |
| 567 |
} |
| 568 |
# |
| 569 |
# handle @ifhtml / @end ifhtml |
| 570 |
# |
| 571 |
if ($in_html) { |
| 572 |
if ($end_tag eq 'ifhtml') { |
| 573 |
$in_html = 0; |
| 574 |
} else { |
| 575 |
$tag2pro{$in_html} .= $_; |
| 576 |
} |
| 577 |
next; |
| 578 |
} elsif ($tag eq 'ifhtml') { |
| 579 |
$in_html = $PROTECTTAG . ++$html_num; |
| 580 |
push(@lines, $in_html); |
| 581 |
next; |
| 582 |
} |
| 583 |
# |
| 584 |
# try to skip the line |
| 585 |
# |
| 586 |
if ($end_tag) { |
| 587 |
next if $to_skip{"end $end_tag"}; |
| 588 |
} elsif ($tag) { |
| 589 |
next if $to_skip{$tag}; |
| 590 |
last if $tag eq 'bye'; |
| 591 |
} |
| 592 |
if ($in_top) { |
| 593 |
# parsing the top node |
| 594 |
if ($tag eq 'node' || $tag eq 'include' || $sec2level{$tag}) { |
| 595 |
# no more in top |
| 596 |
$in_top = 0; |
| 597 |
} else { |
| 598 |
# skip it |
| 599 |
next; |
| 600 |
} |
| 601 |
} |
| 602 |
# |
| 603 |
# try to remove inlined comments |
| 604 |
# syntax from tex-mode.el comment-start-skip |
| 605 |
# |
| 606 |
s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/; |
| 607 |
# non-@ substitutions cf. texinfmt.el |
| 608 |
unless ($in_pre) { |
| 609 |
s/``/“/g; |
| 610 |
s/''/”/g; |
| 611 |
s/([\w ])---([\w ])/$1--$2/g; |
| 612 |
} |
| 613 |
# |
| 614 |
# analyze the tag |
| 615 |
# |
| 616 |
if ($tag) { |
| 617 |
# skip lines |
| 618 |
&skip_until($tag), next if $tag eq 'ignore'; |
| 619 |
if ($expandinfo) { |
| 620 |
&skip_until($tag), next if $tag eq 'ifnotinfo'; |
| 621 |
&skip_until($tag), next if $tag eq 'iftex'; |
| 622 |
&skip_until($tag), next if $tag eq 'ifhtml'; |
| 623 |
} elsif ($expandtex) { |
| 624 |
&skip_until($tag), next if $tag eq 'ifinfo'; |
| 625 |
&skip_until($tag), next if $tag eq 'ifnottex'; |
| 626 |
&skip_until($tag), next if $tag eq 'ifhtml'; |
| 627 |
} else { |
| 628 |
&skip_until($tag), next if $tag eq 'ifinfo'; |
| 629 |
&skip_until($tag), next if $tag eq 'iftex'; |
| 630 |
&skip_until($tag), next if $tag eq 'ifnothtml'; |
| 631 |
} |
| 632 |
&skip_until($tag), next if $tag eq 'tex'; |
| 633 |
# handle special tables |
| 634 |
if ($tag =~ /^(|f|v|multi)table$/) { |
| 635 |
$table_type = $1; |
| 636 |
$tag = 'table'; |
| 637 |
} |
| 638 |
# special cases |
| 639 |
if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+top\s*,/i)) { |
| 640 |
$in_top = 1; |
| 641 |
@lines = (); # ignore all lines before top (title page garbage) |
| 642 |
next; |
| 643 |
} elsif ($tag eq 'node') { |
| 644 |
$in_top = 0; |
| 645 |
warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o; |
| 646 |
$_ = &protect_html($_); # if node contains '&' for instance |
| 647 |
s/^\@node\s+//; |
| 648 |
($node) = split(/,/); |
| 649 |
&normalise_node($node); |
| 650 |
if ($split_node) { |
| 651 |
&next_doc; |
| 652 |
push(@lines, $SPLITTAG) if $split_num++; |
| 653 |
push(@sections, $node); |
| 654 |
} |
| 655 |
next; |
| 656 |
} elsif ($tag eq 'include') { |
| 657 |
if (/^\@include\s+($FILERE)\s*$/o) { |
| 658 |
$file = $1; |
| 659 |
unless (-e $file) { |
| 660 |
foreach $dir (@include_dirs) { |
| 661 |
$file = "$dir/$1"; |
| 662 |
last if -e $file; |
| 663 |
} |
| 664 |
} |
| 665 |
if (-e $file) { |
| 666 |
&open($file); |
| 667 |
print "# including $file\n" if $verbose; |
| 668 |
} else { |
| 669 |
warn "$ERROR Can't find $file, skipping"; |
| 670 |
} |
| 671 |
} else { |
| 672 |
warn "$ERROR Bad include line: $_"; |
| 673 |
} |
| 674 |
next; |
| 675 |
} elsif ($tag eq 'ifclear') { |
| 676 |
if (/^\@ifclear\s+($VARRE)\s*$/o) { |
| 677 |
next unless defined($value{$1}); |
| 678 |
&skip_until($tag); |
| 679 |
} else { |
| 680 |
warn "$ERROR Bad ifclear line: $_"; |
| 681 |
} |
| 682 |
next; |
| 683 |
} elsif ($tag eq 'ifset') { |
| 684 |
if (/^\@ifset\s+($VARRE)\s*$/o) { |
| 685 |
next if defined($value{$1}); |
| 686 |
&skip_until($tag); |
| 687 |
} else { |
| 688 |
warn "$ERROR Bad ifset line: $_"; |
| 689 |
} |
| 690 |
next; |
| 691 |
} elsif ($tag eq 'menu') { |
| 692 |
unless ($show_menu) { |
| 693 |
&skip_until($tag); |
| 694 |
next; |
| 695 |
} |
| 696 |
&html_push_if($tag); |
| 697 |
push(@lines, &html_debug("\n", __LINE__)); |
| 698 |
} elsif ($format_map{$tag}) { |
| 699 |
$in_pre = 1 if $format_map{$tag} eq 'PRE'; |
| 700 |
&html_push_if($format_map{$tag}); |
| 701 |
push(@lines, &html_debug("\n", __LINE__)); |
| 702 |
$in_list++ if $format_map{$tag} eq 'UL' || $format_map{$tag} eq 'OL' ; |
| 703 |
push(@lines, &debug("<$format_map{$tag}>\n", __LINE__)); |
| 704 |
next; |
| 705 |
} elsif ($tag eq 'table') { |
| 706 |
if (/^\@(|f|v|multi)table\s+\@(\w+)/) { |
| 707 |
$in_table = $2; |
| 708 |
unshift(@tables, join($;, $table_type, $in_table)); |
| 709 |
if ($table_type eq "multi") { |
| 710 |
push(@lines, &debug("<TABLE BORDER>\n", __LINE__)); |
| 711 |
&html_push_if('TABLE'); |
| 712 |
} else { |
| 713 |
push(@lines, &debug("<DL COMPACT>\n", __LINE__)); |
| 714 |
&html_push_if('DL'); |
| 715 |
} |
| 716 |
push(@lines, &html_debug("\n", __LINE__)); |
| 717 |
} else { |
| 718 |
warn "$ERROR Bad table line: $_"; |
| 719 |
} |
| 720 |
next; |
| 721 |
} elsif ($tag eq 'synindex' || $tag eq 'syncodeindex') { |
| 722 |
if (/^\@$tag\s+(\w)\w\s+(\w)\w\s*$/) { |
| 723 |
eval("*${1}index = *${2}index"); |
| 724 |
} else { |
| 725 |
warn "$ERROR Bad syn*index line: $_"; |
| 726 |
} |
| 727 |
next; |
| 728 |
} elsif ($tag eq 'sp') { |
| 729 |
push(@lines, &debug("<P>\n", __LINE__)); |
| 730 |
next; |
| 731 |
} elsif ($tag eq 'setref') { |
| 732 |
&protect_html; # if setref contains '&' for instance |
| 733 |
if (/^\@$tag\s*{($NODERE)}\s*$/) { |
| 734 |
$setref = $1; |
| 735 |
$setref =~ s/\s+/ /g; # normalize |
| 736 |
$setref =~ s/ $//; |
| 737 |
$node2sec{$setref} = $name; |
| 738 |
$node2href{$setref} = "$docu_doc#$docid"; |
| 739 |
} else { |
| 740 |
warn "$ERROR Bad setref line: $_"; |
| 741 |
} |
| 742 |
next; |
| 743 |
} elsif ($tag eq 'defindex' || $tag eq 'defcodeindex') { |
| 744 |
if (/^\@$tag\s+(\w\w)\s*$/) { |
| 745 |
$valid_index{$1} = 1; |
| 746 |
} else { |
| 747 |
warn "$ERROR Bad defindex line: $_"; |
| 748 |
} |
| 749 |
next; |
| 750 |
} elsif (defined($def_map{$tag})) { |
| 751 |
if ($def_map{$tag}) { |
| 752 |
s/^\@$tag\s+//; |
| 753 |
$tag = $def_map{$tag}; |
| 754 |
$_ = "\@$tag $_"; |
| 755 |
$tag =~ s/\s.*//; |
| 756 |
} |
| 757 |
} elsif (defined($user_sub{$tag})) { |
| 758 |
s/^\@$tag\s+//; |
| 759 |
$sub = $user_sub{$tag}; |
| 760 |
print "# user $tag = $sub, arg: $_" if $debug & $DEBUG_USER; |
| 761 |
if (defined(&$sub)) { |
| 762 |
chop($_); |
| 763 |
&$sub($_); |
| 764 |
} else { |
| 765 |
warn "$ERROR Bad user sub for $tag: $sub\n"; |
| 766 |
} |
| 767 |
next; |
| 768 |
} |
| 769 |
if (defined($def_map{$tag})) { |
| 770 |
s/^\@$tag\s+//; |
| 771 |
if ($tag =~ /x$/) { |
| 772 |
# extra definition line |
| 773 |
$tag = $`; |
| 774 |
$is_extra = 1; |
| 775 |
} else { |
| 776 |
$is_extra = 0; |
| 777 |
} |
| 778 |
while (/\{([^\{\}]*)\}/) { |
| 779 |
# this is a {} construct |
| 780 |
($before, $contents, $after) = ($`, $1, $'); |
| 781 |
# protect spaces |
| 782 |
$contents =~ s/\s+/$;9/g; |
| 783 |
# restore $_ protecting {} |
| 784 |
$_ = "$before$;7$contents$;8$after"; |
| 785 |
} |
| 786 |
@args = split(/\s+/, &protect_html($_)); |
| 787 |
foreach (@args) { |
| 788 |
s/$;9/ /g; # unprotect spaces |
| 789 |
s/$;7/\{/g; # ... { |
| 790 |
s/$;8/\}/g; # ... } |
| 791 |
} |
| 792 |
$type = shift(@args); |
| 793 |
$type =~ s/^\{(.*)\}$/$1/; |
| 794 |
print "# def ($tag): {$type} ", join(', ', @args), "\n" |
| 795 |
if $debug & $DEBUG_DEF; |
| 796 |
$type .= ':'; # it's nicer like this |
| 797 |
$name = shift(@args); |
| 798 |
$name =~ s/^\{(.*)\}$/$1/; |
| 799 |
if ($is_extra) { |
| 800 |
$_ = &debug("<DT>", __LINE__); |
| 801 |
} else { |
| 802 |
$_ = &debug("<DL>\n<DT>", __LINE__); |
| 803 |
} |
| 804 |
if ($tag eq 'deffn' || $tag eq 'defvr' || $tag eq 'deftp') { |
| 805 |
$_ .= "<U>$type</U> <B>$name</B>"; |
| 806 |
$_ .= " <I>@args</I>" if @args; |
| 807 |
} elsif ($tag eq 'deftypefn' || $tag eq 'deftypevr' |
| 808 |
|| $tag eq 'defcv' || $tag eq 'defop') { |
| 809 |
$ftype = $name; |
| 810 |
$name = shift(@args); |
| 811 |
$name =~ s/^\{(.*)\}$/$1/; |
| 812 |
$_ .= "<U>$type</U> $ftype <B>$name</B>"; |
| 813 |
$_ .= " <I>@args</I>" if @args; |
| 814 |
} else { |
| 815 |
warn "$ERROR Unknown definition type: $tag\n"; |
| 816 |
$_ .= "<U>$type</U> <B>$name</B>"; |
| 817 |
$_ .= " <I>@args</I>" if @args; |
| 818 |
} |
| 819 |
$_ .= &debug("\n<DD>", __LINE__); |
| 820 |
$name = &unprotect_html($name); |
| 821 |
if ($tag eq 'deffn' || $tag eq 'deftypefn') { |
| 822 |
unshift(@input_spool, "\@findex $name\n"); |
| 823 |
} elsif ($tag eq 'defop') { |
| 824 |
unshift(@input_spool, "\@findex $name on $ftype\n"); |
| 825 |
} elsif ($tag eq 'defvr' || $tag eq 'deftypevr' || $tag eq 'defcv') { |
| 826 |
unshift(@input_spool, "\@vindex $name\n"); |
| 827 |
} else { |
| 828 |
unshift(@input_spool, "\@tindex $name\n"); |
| 829 |
} |
| 830 |
$dont_html = 1; |
| 831 |
} |
| 832 |
} elsif ($end_tag) { |
| 833 |
if ($format_map{$end_tag}) { |
| 834 |
$in_pre = 0 if $format_map{$end_tag} eq 'PRE'; |
| 835 |
$in_list-- if $format_map{$end_tag} eq 'UL' || $format_map{$end_tag} eq 'OL' ; |
| 836 |
&html_pop_if('LI', 'P'); |
| 837 |
&html_pop_if(); |
| 838 |
push(@lines, &debug("</$format_map{$end_tag}>\n", __LINE__)); |
| 839 |
push(@lines, &html_debug("\n", __LINE__)); |
| 840 |
} elsif ($end_tag =~ /^(|f|v|multi)table$/) { |
| 841 |
unless (@tables) { |
| 842 |
warn "$ERROR \@end $end_tag without \@*table\n"; |
| 843 |
next; |
| 844 |
} |
| 845 |
($table_type, $in_table) = split($;, shift(@tables)); |
| 846 |
unless ($1 eq $table_type) { |
| 847 |
warn "$ERROR \@end $end_tag without matching \@$end_tag\n"; |
| 848 |
next; |
| 849 |
} |
| 850 |
if ($table_type eq "multi") { |
| 851 |
push(@lines, "</TR></TABLE>\n"); |
| 852 |
&html_pop_if('TR'); |
| 853 |
} else { |
| 854 |
push(@lines, "</DL>\n"); |
| 855 |
&html_pop_if('DD'); |
| 856 |
} |
| 857 |
&html_pop_if(); |
| 858 |
if (@tables) { |
| 859 |
($table_type, $in_table) = split($;, $tables[0]); |
| 860 |
} else { |
| 861 |
$in_table = 0; |
| 862 |
} |
| 863 |
} elsif (defined($def_map{$end_tag})) { |
| 864 |
push(@lines, &debug("</DL>\n", __LINE__)); |
| 865 |
} elsif ($end_tag eq 'menu') { |
| 866 |
&html_pop_if(); |
| 867 |
push(@lines, $_); # must keep it for pass 2 |
| 868 |
} |
| 869 |
next; |
| 870 |
} |
| 871 |
# |
| 872 |
# misc things |
| 873 |
# |
| 874 |
# protect texi and HTML things |
| 875 |
&protect_texi; |
| 876 |
$_ = &protect_html($_) unless $dont_html; |
| 877 |
$dont_html = 0; |
| 878 |
# substitution (unsupported things) |
| 879 |
s/^\@center\s+//g; |
| 880 |
s/^\@exdent\s+//g; |
| 881 |
s/\@noindent\s+//g; |
| 882 |
s/\@refill\s+//g; |
| 883 |
# other substitutions |
| 884 |
&simple_substitutions; |
| 885 |
s/\@value\{($VARRE)\}/$value{$1}/eg; |
| 886 |
s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4 |
| 887 |
# |
| 888 |
# analyze the tag again |
| 889 |
# |
| 890 |
if ($tag) { |
| 891 |
if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) { |
| 892 |
if (/^\@$tag\s+(.+)$/) { |
| 893 |
$name = $1; |
| 894 |
$name =~ s/\s+$//; |
| 895 |
$level = $sec2level{$tag}; |
| 896 |
$name = &update_sec_num($tag, $level) . " $name" |
| 897 |
if $number_sections && $tag !~ /^unnumbered/; |
| 898 |
if ($tag =~ /heading$/) { |
| 899 |
push(@lines, &html_debug("\n", __LINE__)); |
| 900 |
if ($html_element ne 'body') { |
| 901 |
# We are in a nice pickle here. We are trying to get a H? heading |
| 902 |
# even though we are not in the body level. So, we convert it to a |
| 903 |
# nice, bold, line by itself. |
| 904 |
$_ = &debug("\n\n<P><STRONG>$name</STRONG></P>\n\n", __LINE__); |
| 905 |
} else { |
| 906 |
$_ = &debug("<H$level>$name</H$level>\n", __LINE__); |
| 907 |
&html_push_if('body'); |
| 908 |
} |
| 909 |
print "# heading, section $name, level $level\n" |
| 910 |
if $debug & $DEBUG_TOC; |
| 911 |
} else { |
| 912 |
if ($split_chapter) { |
| 913 |
unless ($toplevel) { |
| 914 |
# first time we see a "section" |
| 915 |
unless ($level == 1) { |
| 916 |
warn "$ERROR The first section found is not of level 1: $_"; |
| 917 |
warn "$ERROR I'll split on sections of level $level...\n"; |
| 918 |
} |
| 919 |
$toplevel = $level; |
| 920 |
} |
| 921 |
if ($level == $toplevel) { |
| 922 |
&next_doc; |
| 923 |
push(@lines, $SPLITTAG) if $split_num++; |
| 924 |
push(@sections, $name); |
| 925 |
} |
| 926 |
} |
| 927 |
$sec_num++; |
| 928 |
$docid = "SEC$sec_num"; |
| 929 |
$tocid = "TOC$sec_num"; |
| 930 |
# check biblio and glossary |
| 931 |
$in_bibliography = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i); |
| 932 |
$in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i); |
| 933 |
# check node |
| 934 |
if ($node) { |
| 935 |
if ($node2sec{$node}) { |
| 936 |
warn "$ERROR Duplicate node found: $node\n"; |
| 937 |
} else { |
| 938 |
$node2sec{$node} = $name; |
| 939 |
$node2href{$node} = "$docu_doc#$docid"; |
| 940 |
print "# node $node, section $name, level $level\n" |
| 941 |
if $debug & $DEBUG_TOC; |
| 942 |
} |
| 943 |
$node = ''; |
| 944 |
} else { |
| 945 |
print "# no node, section $name, level $level\n" |
| 946 |
if $debug & $DEBUG_TOC; |
| 947 |
} |
| 948 |
# update TOC |
| 949 |
while ($level > $curlevel) { |
| 950 |
$curlevel++; |
| 951 |
push(@toc_lines, "<UL>\n"); |
| 952 |
} |
| 953 |
while ($level < $curlevel) { |
| 954 |
$curlevel--; |
| 955 |
push(@toc_lines, "</UL>\n"); |
| 956 |
} |
| 957 |
$_ = "<LI>" . &anchor($tocid, "$docu_doc#$docid", $name, 1); |
| 958 |
push(@toc_lines, &substitute_style($_)); |
| 959 |
# update DOC |
| 960 |
push(@lines, &html_debug("\n", __LINE__)); |
| 961 |
&html_reset; |
| 962 |
$_ = "<H$level>".&anchor($docid, "$docu_toc#$tocid", $name)."</H$level>\n"; |
| 963 |
$_ = &debug($_, __LINE__); |
| 964 |
push(@lines, &html_debug("\n", __LINE__)); |
| 965 |
} |
| 966 |
# update DOC |
| 967 |
foreach $line (split(/\n+/, $_)) { |
| 968 |
push(@lines, "$line\n"); |
| 969 |
} |
| 970 |
next; |
| 971 |
} else { |
| 972 |
warn "$ERROR Bad section line: $_"; |
| 973 |
} |
| 974 |
} else { |
| 975 |
# track variables |
| 976 |
$value{$1} = $2, next if /^\@set\s+($VARRE)\s+(.*)$/o; |
| 977 |
delete $value{$1}, next if /^\@clear\s+($VARRE)\s*$/o; |
| 978 |
# store things |
| 979 |
$value{'_setfilename'} = $1, next if /^\@setfilename\s+(.*)$/; |
| 980 |
$value{'_settitle'} = $1, next if /^\@settitle\s+(.*)$/; |
| 981 |
$value{'_author'} .= "$1\n", next if /^\@author\s+(.*)$/; |
| 982 |
$value{'_subtitle'} .= "$1\n", next if /^\@subtitle\s+(.*)$/; |
| 983 |
$value{'_title'} .= "$1\n", next if /^\@title\s+(.*)$/; |
| 984 |
# index |
| 985 |
if (/^\@(..?)index\s+/) { |
| 986 |
unless ($valid_index{$1}) { |
| 987 |
warn "$ERROR Undefined index command: $_"; |
| 988 |
next; |
| 989 |
} |
| 990 |
$id = 'IDX' . ++$idx_num; |
| 991 |
$index = $1 . 'index'; |
| 992 |
$what = &substitute_style($'); |
| 993 |
$what =~ s/\s+$//; |
| 994 |
print "# found $index for '$what' id $id\n" |
| 995 |
if $debug & $DEBUG_INDEX; |
| 996 |
eval(<<EOC); |
| 997 |
if (defined(\$$index\{\$what\})) { |
| 998 |
\$$index\{\$what\} .= "$;$docu_doc#$id"; |
| 999 |
} else { |
| 1000 |
\$$index\{\$what\} = "$docu_doc#$id"; |
| 1001 |
} |
| 1002 |
EOC |
| 1003 |
# |
| 1004 |
# dirty hack to see if I can put an invisible anchor... |
| 1005 |
# |
| 1006 |
if ($html_element eq 'P' || |
| 1007 |
$html_element eq 'LI' || |
| 1008 |
$html_element eq 'DT' || |
| 1009 |
$html_element eq 'DD' || |
| 1010 |
$html_element eq 'ADDRESS' || |
| 1011 |
$html_element eq 'B' || |
| 1012 |
$html_element eq 'BLOCKQUOTE' || |
| 1013 |
$html_element eq 'PRE' || |
| 1014 |
$html_element eq 'SAMP') { |
| 1015 |
push(@lines, &anchor($id, '', $invisible_mark, !$in_pre)); |
| 1016 |
} elsif ($html_element eq 'body') { |
| 1017 |
push(@lines, &debug("<P>\n", __LINE__)); |
| 1018 |
push(@lines, &anchor($id, '', $invisible_mark, !$in_pre)); |
| 1019 |
&html_push('P'); |
| 1020 |
} elsif ($html_element eq 'DL' || |
| 1021 |
$html_element eq 'UL' || |
| 1022 |
$html_element eq 'OL' ) { |
| 1023 |
$deferred_ref .= &anchor($id, '', $invisible_mark, !$in_pre) . " "; |
| 1024 |
} |
| 1025 |
next; |
| 1026 |
} |
| 1027 |
# list item |
| 1028 |
if (/^\@itemx?\s+/) { |
| 1029 |
$what = $'; |
| 1030 |
$what =~ s/\s+$//; |
| 1031 |
if ($in_bibliography && $use_bibliography) { |
| 1032 |
if ($what =~ /^$BIBRE$/o) { |
| 1033 |
$id = 'BIB' . ++$bib_num; |
| 1034 |
$bib2href{$what} = "$docu_doc#$id"; |
| 1035 |
print "# found bibliography for '$what' id $id\n" |
| 1036 |
if $debug & $DEBUG_BIB; |
| 1037 |
$what = &anchor($id, '', $what); |
| 1038 |
} |
| 1039 |
} elsif ($in_glossary && $use_glossary) { |
| 1040 |
$id = 'GLOSS' . ++$gloss_num; |
| 1041 |
$entry = $what; |
| 1042 |
$entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/; |
| 1043 |
$gloss2href{$entry} = "$docu_doc#$id"; |
| 1044 |
print "# found glossary for '$entry' id $id\n" |
| 1045 |
if $debug & $DEBUG_GLOSS; |
| 1046 |
$what = &anchor($id, '', $what); |
| 1047 |
} |
| 1048 |
&html_pop_if('P'); |
| 1049 |
if ($html_element eq 'DL' || $html_element eq 'DD') { |
| 1050 |
if ($things_map{$in_table} && !$what) { |
| 1051 |
# special case to allow @table @bullet for instance |
| 1052 |
push(@lines, &debug("<DT>$things_map{$in_table}\n", __LINE__)); |
| 1053 |
} else { |
| 1054 |
push(@lines, &debug("<DT>\@$in_table\{$what\}\n", __LINE__)); |
| 1055 |
} |
| 1056 |
push(@lines, "<DD>"); |
| 1057 |
&html_push('DD') unless $html_element eq 'DD'; |
| 1058 |
if ($table_type) { # add also an index |
| 1059 |
unshift(@input_spool, "\@${table_type}index $what\n"); |
| 1060 |
} |
| 1061 |
} elsif ($html_element eq 'TABLE') { |
| 1062 |
push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__)); |
| 1063 |
&html_push('TR'); |
| 1064 |
} elsif ($html_element eq 'TR') { |
| 1065 |
push(@lines, &debug("</TR>\n", __LINE__)); |
| 1066 |
push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__)); |
| 1067 |
} else { |
| 1068 |
push(@lines, &debug("<LI>$what\n", __LINE__)); |
| 1069 |
&html_push('LI') unless $html_element eq 'LI'; |
| 1070 |
} |
| 1071 |
push(@lines, &html_debug("\n", __LINE__)); |
| 1072 |
if ($deferred_ref) { |
| 1073 |
push(@lines, &debug("$deferred_ref\n", __LINE__)); |
| 1074 |
$deferred_ref = ''; |
| 1075 |
} |
| 1076 |
next; |
| 1077 |
} elsif (/^\@tab\s+(.*)$/) { |
| 1078 |
push(@lines, "<TD>$1</TD>\n"); |
| 1079 |
next; |
| 1080 |
} |
| 1081 |
} |
| 1082 |
} |
| 1083 |
# paragraph separator |
| 1084 |
if ($_ eq "\n") { |
| 1085 |
next if $#lines >= 0 && $lines[$#lines] eq "\n"; |
| 1086 |
if ($html_element eq 'P') { |
| 1087 |
push(@lines, "\n"); |
| 1088 |
$_ = &debug("</P>\n", __LINE__); |
| 1089 |
&html_pop; |
| 1090 |
} |
| 1091 |
} elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE') { |
| 1092 |
push(@lines, "<P>\n"); |
| 1093 |
&html_push('P'); |
| 1094 |
$_ = &debug($_, __LINE__); |
| 1095 |
} |
| 1096 |
# otherwise |
| 1097 |
push(@lines, $_); |
| 1098 |
} |
| 1099 |
|
| 1100 |
# finish TOC |
| 1101 |
$level = 0; |
| 1102 |
while ($level < $curlevel) { |
| 1103 |
$curlevel--; |
| 1104 |
push(@toc_lines, "</UL>\n"); |
| 1105 |
} |
| 1106 |
|
| 1107 |
print "# end of pass 1\n" if $verbose; |
| 1108 |
|
| 1109 |
#+++############################################################################ |
| 1110 |
# # |
| 1111 |
# Pass 2/3: handle style, menu, index, cross-reference # |
| 1112 |
# # |
| 1113 |
#---############################################################################ |
| 1114 |
|
| 1115 |
@lines2 = (); # whole document (2nd pass) |
| 1116 |
@lines3 = (); # whole document (3rd pass) |
| 1117 |
$in_menu = 0; # am I inside a menu |
| 1118 |
|
| 1119 |
while (@lines) { |
| 1120 |
$_ = shift(@lines); |
| 1121 |
# |
| 1122 |
# special case (protected sections) |
| 1123 |
# |
| 1124 |
if (/^$PROTECTTAG/o) { |
| 1125 |
push(@lines2, $_); |
| 1126 |
next; |
| 1127 |
} |
| 1128 |
# |
| 1129 |
# menu |
| 1130 |
# |
| 1131 |
$in_menu = 1, push(@lines2, &debug("<UL>\n", __LINE__)), next if /^\@menu\b/; |
| 1132 |
$in_menu = 0, push(@lines2, &debug("</UL>\n", __LINE__)), next if /^\@end\s+menu\b/; |
| 1133 |
if ($in_menu) { |
| 1134 |
if (/^\*\s+($NODERE)::/o) { |
| 1135 |
$descr = $'; |
| 1136 |
chop($descr); |
| 1137 |
&menu_entry($1, $1, $descr); |
| 1138 |
} elsif (/^\*\s+(.+):\s+([^\t,\.\n]+)[\t,\.\n]/) { |
| 1139 |
$descr = $'; |
| 1140 |
chop($descr); |
| 1141 |
&menu_entry($1, $2, $descr); |
| 1142 |
} elsif (/^\*/) { |
| 1143 |
warn "$ERROR Bad menu line: $_"; |
| 1144 |
} else { # description continued? |
| 1145 |
push(@lines2, $_); |
| 1146 |
} |
| 1147 |
next; |
| 1148 |
} |
| 1149 |
# |
| 1150 |
# printindex |
| 1151 |
# |
| 1152 |
if (/^\@printindex\s+(\w\w)\b/) { |
| 1153 |
local($index, *ary, @keys, $key, $letter, $last_letter, @refs); |
| 1154 |
if ($predefined_index{$1}) { |
| 1155 |
$index = $predefined_index{$1} . 'index'; |
| 1156 |
} else { |
| 1157 |
$index = $1 . 'index'; |
| 1158 |
} |
| 1159 |
eval("*ary = *$index"); |
| 1160 |
@keys = keys(%ary); |
| 1161 |
foreach $key (@keys) { |
| 1162 |
$_ = $key; |
| 1163 |
1 while s/<(\w+)>\`(.*)\´<\/\1>/$2/; # remove HTML tags with quotes |
| 1164 |
1 while s/<(\w+)>(.*)<\/\1>/$2/; # remove HTML tags |
| 1165 |
$_ = &unprotect_html($_); |
| 1166 |
&unprotect_texi; |
| 1167 |
tr/A-Z/a-z/; # lowercase |
| 1168 |
$key2alpha{$key} = $_; |
| 1169 |
print "# index $key sorted as $_\n" |
| 1170 |
if $key ne $_ && $debug & $DEBUG_INDEX; |
| 1171 |
} |
| 1172 |
push(@lines2, "Jump to:\n"); |
| 1173 |
$last_letter = undef; |
| 1174 |
foreach $key (sort byalpha @keys) { |
| 1175 |
$letter = substr($key2alpha{$key}, 0, 1); |
| 1176 |
$letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;; |
| 1177 |
if (!defined($last_letter) || $letter ne $last_letter) { |
| 1178 |
push(@lines2, "-\n") if defined($last_letter); |
| 1179 |
push(@lines2, "<A HREF=\"#$index\_$letter\">" . &protect_html($letter) . "</A>\n"); |
| 1180 |
$last_letter = $letter; |
| 1181 |
} |
| 1182 |
} |
| 1183 |
push(@lines2, "<P>\n"); |
| 1184 |
$last_letter = undef; |
| 1185 |
foreach $key (sort byalpha @keys) { |
| 1186 |
$letter = substr($key2alpha{$key}, 0, 1); |
| 1187 |
$letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;; |
| 1188 |
if (!defined($last_letter) || $letter ne $last_letter) { |
| 1189 |
push(@lines2, "</DIR>\n") if defined($last_letter); |
| 1190 |
push(@lines2, "<H2><A NAME=\"$index\_$letter\">" . &protect_html($letter) . "</A></H2>\n"); |
| 1191 |
push(@lines2, "<DIR>\n"); |
| 1192 |
$last_letter = $letter; |
| 1193 |
} |
| 1194 |
@refs = (); |
| 1195 |
foreach (split(/$;/, $ary{$key})) { |
| 1196 |
push(@refs, &anchor('', $_, $key, 0)); |
| 1197 |
} |
| 1198 |
push(@lines2, "<LI>" . join(", ", @refs) . "\n"); |
| 1199 |
} |
| 1200 |
push(@lines2, "</DIR>\n") if defined($last_letter); |
| 1201 |
next; |
| 1202 |
} |
| 1203 |
# |
| 1204 |
# simple style substitutions |
| 1205 |
# |
| 1206 |
$_ = &substitute_style($_); |
| 1207 |
# |
| 1208 |
# xref |
| 1209 |
# |
| 1210 |
while (/\@(x|px|info|)ref\{($XREFRE)(\}?)/o) { |
| 1211 |
# note: Texinfo may accept other characters |
| 1212 |
($type, $nodes, $full) = ($1, $2, $3); |
| 1213 |
($before, $after) = ($`, $'); |
| 1214 |
if (! $full && $after) { |
| 1215 |
warn "$ERROR Bad xref (no ending } on line): $_"; |
| 1216 |
$_ = "$before$;0${type}ref\{$nodes$after"; |
| 1217 |
next; # while xref |
| 1218 |
} |
| 1219 |
if ($type eq 'x') { |
| 1220 |
$type = 'See '; |
| 1221 |
} elsif ($type eq 'px') { |
| 1222 |
$type = 'see '; |
| 1223 |
} elsif ($type eq 'info') { |
| 1224 |
$type = 'See Info'; |
| 1225 |
} else { |
| 1226 |
$type = ''; |
| 1227 |
} |
| 1228 |
unless ($full) { |
| 1229 |
$next = shift(@lines); |
| 1230 |
$next = &substitute_style($next); |
| 1231 |
chop($nodes); # remove final newline |
| 1232 |
if ($next =~ /\}/) { # split on 2 lines |
| 1233 |
$nodes .= " $`"; |
| 1234 |
$after = $'; |
| 1235 |
} else { |
| 1236 |
$nodes .= " $next"; |
| 1237 |
$next = shift(@lines); |
| 1238 |
$next = &substitute_style($next); |
| 1239 |
chop($nodes); |
| 1240 |
if ($next =~ /\}/) { # split on 3 lines |
| 1241 |
$nodes .= " $`"; |
| 1242 |
$after = $'; |
| 1243 |
} else { |
| 1244 |
warn "$ERROR Bad xref (no ending }): $_"; |
| 1245 |
$_ = "$before$;0xref\{$nodes$after"; |
| 1246 |
unshift(@lines, $next); |
| 1247 |
next; # while xref |
| 1248 |
} |
| 1249 |
} |
| 1250 |
} |
| 1251 |
$nodes =~ s/\s+/ /g; # remove useless spaces |
| 1252 |
@args = split(/\s*,\s*/, $nodes); |
| 1253 |
$node = $args[0]; # the node is always the first arg |
| 1254 |
&normalise_node($node); |
| 1255 |
$sec = $node2sec{$node}; |
| 1256 |
if (@args == 5) { # reference to another manual |
| 1257 |
$sec = $args[2] || $node; |
| 1258 |
$man = $args[4] || $args[3]; |
| 1259 |
$_ = "${before}${type}section ‘$sec’ in \@cite{$man}$after"; |
| 1260 |
} elsif ($type =~ /Info/) { # inforef |
| 1261 |
warn "$ERROR Wrong number of arguments: $_" unless @args == 3; |
| 1262 |
($nn, $_, $in) = @args; |
| 1263 |
$_ = "${before}${type} file ‘$in’, node ‘$nn’$after"; |
| 1264 |
} elsif ($sec) { |
| 1265 |
$href = $node2href{$node}; |
| 1266 |
$_ = "${before}${type}section " . &anchor('', $href, $sec) . $after; |
| 1267 |
} else { |
| 1268 |
warn "$ERROR Undefined node ($node): $_"; |
| 1269 |
$_ = "$before$;0xref{$nodes}$after"; |
| 1270 |
} |
| 1271 |
} |
| 1272 |
# |
| 1273 |
# try to guess bibliography references or glossary terms |
| 1274 |
# |
| 1275 |
unless (/^<H\d><A NAME=\"SEC\d/) { |
| 1276 |
if ($use_bibliography) { |
| 1277 |
$done = ''; |
| 1278 |
while (/$BIBRE/o) { |
| 1279 |
($pre, $what, $post) = ($`, $&, $'); |
| 1280 |
$href = $bib2href{$what}; |
| 1281 |
if (defined($href) && $post !~ /^[^<]*<\/A>/) { |
| 1282 |
$done .= $pre . &anchor('', $href, $what); |
| 1283 |
} else { |
| 1284 |
$done .= "$pre$what"; |
| 1285 |
} |
| 1286 |
$_ = $post; |
| 1287 |
} |
| 1288 |
$_ = $done . $_; |
| 1289 |
} |
| 1290 |
if ($use_glossary) { |
| 1291 |
$done = ''; |
| 1292 |
while (/\b\w+\b/) { |
| 1293 |
($pre, $what, $post) = ($`, $&, $'); |
| 1294 |
$entry = $what; |
| 1295 |
$entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/; |
| 1296 |
$href = $gloss2href{$entry}; |
| 1297 |
if (defined($href) && $post !~ /^[^<]*<\/A>/) { |
| 1298 |
$done .= $pre . &anchor('', $href, $what); |
| 1299 |
} else { |
| 1300 |
$done .= "$pre$what"; |
| 1301 |
} |
| 1302 |
$_ = $post; |
| 1303 |
} |
| 1304 |
$_ = $done . $_; |
| 1305 |
} |
| 1306 |
} |
| 1307 |
# otherwise |
| 1308 |
push(@lines2, $_); |
| 1309 |
} |
| 1310 |
print "# end of pass 2\n" if $verbose; |
| 1311 |
|
| 1312 |
# |
| 1313 |
# split style substitutions |
| 1314 |
# |
| 1315 |
while (@lines2) { |
| 1316 |
$_ = shift(@lines2); |
| 1317 |
# |
| 1318 |
# special case (protected sections) |
| 1319 |
# |
| 1320 |
if (/^$PROTECTTAG/o) { |
| 1321 |
push(@lines3, $_); |
| 1322 |
next; |
| 1323 |
} |
| 1324 |
# |
| 1325 |
# split style substitutions |
| 1326 |
# |
| 1327 |
$old = ''; |
| 1328 |
while ($old ne $_) { |
| 1329 |
$old = $_; |
| 1330 |
if (/\@(\w+|"|\~|,|\^)\{/) { |
| 1331 |
($before, $style, $after) = ($`, $1, $'); |
| 1332 |
if (defined($style_map{$style})) { |
| 1333 |
$_ = $after; |
| 1334 |
$text = ''; |
| 1335 |
$after = ''; |
| 1336 |
$failed = 1; |
| 1337 |
while (@lines2) { |
| 1338 |
if (/\}/) { |
| 1339 |
$text .= $`; |
| 1340 |
$after = $'; |
| 1341 |
$failed = 0; |
| 1342 |
last; |
| 1343 |
} else { |
| 1344 |
$text .= $_; |
| 1345 |
$_ = shift(@lines2); |
| 1346 |
} |
| 1347 |
} |
| 1348 |
if ($failed) { |
| 1349 |
die "* Bad syntax (\@$style) after: $before\n"; |
| 1350 |
} else { |
| 1351 |
$text = &apply_style($style, $text); |
| 1352 |
$_ = "$before$text$after"; |
| 1353 |
} |
| 1354 |
} |
| 1355 |
} |
| 1356 |
} |
| 1357 |
# otherwise |
| 1358 |
push(@lines3, $_); |
| 1359 |
} |
| 1360 |
print "# end of pass 3\n" if $verbose; |
| 1361 |
|
| 1362 |
#+++############################################################################ |
| 1363 |
# # |
| 1364 |
# Pass 4: foot notes, final cleanup # |
| 1365 |
# # |
| 1366 |
#---############################################################################ |
| 1367 |
|
| 1368 |
@foot_lines = (); # footnotes |
| 1369 |
@doc_lines = (); # final document |
| 1370 |
$end_of_para = 0; # true if last line is <P> |
| 1371 |
|
| 1372 |
while (@lines3) { |
| 1373 |
$_ = shift(@lines3); |
| 1374 |
# |
| 1375 |
# special case (protected sections) |
| 1376 |
# |
| 1377 |
if (/^$PROTECTTAG/o) { |
| 1378 |
push(@doc_lines, $_); |
| 1379 |
$end_of_para = 0; |
| 1380 |
next; |
| 1381 |
} |
| 1382 |
# |
| 1383 |
# footnotes |
| 1384 |
# |
| 1385 |
while (/\@footnote([^\{\s]+)\{/) { |
| 1386 |
($before, $d, $after) = ($`, $1, $'); |
| 1387 |
$_ = $after; |
| 1388 |
$text = ''; |
| 1389 |
$after = ''; |
| 1390 |
$failed = 1; |
| 1391 |
while (@lines3) { |
| 1392 |
if (/\}/) { |
| 1393 |
$text .= $`; |
| 1394 |
$after = $'; |
| 1395 |
$failed = 0; |
| 1396 |
last; |
| 1397 |
} else { |
| 1398 |
$text .= $_; |
| 1399 |
$_ = shift(@lines3); |
| 1400 |
} |
| 1401 |
} |
| 1402 |
if ($failed) { |
| 1403 |
die "* Bad syntax (\@footnote) after: $before\n"; |
| 1404 |
} else { |
| 1405 |
$foot_num++; |
| 1406 |
$docid = "DOCF$foot_num"; |
| 1407 |
$footid = "FOOT$foot_num"; |
| 1408 |
$foot = "($foot_num)"; |
| 1409 |
push(@foot_lines, "<H3>" . &anchor($footid, "$d#$docid", $foot) . "</H3>\n"); |
| 1410 |
$text = "<P>$text" unless $text =~ /^\s*<P>/; |
| 1411 |
push(@foot_lines, "$text\n"); |
| 1412 |
$_ = $before . &anchor($docid, "$docu_foot#$footid", $foot) . $after; |
| 1413 |
} |
| 1414 |
} |
| 1415 |
# |
| 1416 |
# remove unnecessary <P> |
| 1417 |
# |
| 1418 |
if (/^\s*<P>\s*$/) { |
| 1419 |
next if $end_of_para++; |
| 1420 |
} else { |
| 1421 |
$end_of_para = 0; |
| 1422 |
} |
| 1423 |
# otherwise |
| 1424 |
push(@doc_lines, $_); |
| 1425 |
} |
| 1426 |
print "# end of pass 4\n" if $verbose; |
| 1427 |
|
| 1428 |
#+++############################################################################ |
| 1429 |
# # |
| 1430 |
# Pass 5: print things # |
| 1431 |
# # |
| 1432 |
#---############################################################################ |
| 1433 |
|
| 1434 |
$header = <<EOT; |
| 1435 |
<!-- This HTML file has been created by $THISPROG |
| 1436 |
from $docu on $TODAY --> |
| 1437 |
EOT |
| 1438 |
|
| 1439 |
$full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; |
| 1440 |
$title = $value{'_settitle'} || $full_title; |
| 1441 |
$_ = &substitute_style($full_title); |
| 1442 |
&unprotect_texi; |
| 1443 |
s/\n$//; # rmv last \n (if any) |
| 1444 |
$full_title = "<H1>" . join("</H1>\n<H1>", split(/\n/, $_)) . "</H1>\n"; |
| 1445 |
|
| 1446 |
# |
| 1447 |
# print ToC |
| 1448 |
# |
| 1449 |
if (!$monolithic && @toc_lines) { |
| 1450 |
if (open(FILE, "> $output_dir/$docu_toc")) { |
| 1451 |
print "# creating $docu_toc...\n" if $verbose; |
| 1452 |
&print_toplevel_header("$title - Table of Contents"); |
| 1453 |
&print_ruler; |
| 1454 |
&print(*toc_lines, FILE); |
| 1455 |
&print_toplevel_footer; |
| 1456 |
close(FILE); |
| 1457 |
} else { |
| 1458 |
warn "$ERROR Can't write to $docu_toc: $!\n"; |
| 1459 |
} |
| 1460 |
} |
| 1461 |
|
| 1462 |
# |
| 1463 |
# print footnotes |
| 1464 |
# |
| 1465 |
if (!$monolithic && @foot_lines) { |
| 1466 |
if (open(FILE, "> $output_dir/$docu_foot")) { |
| 1467 |
print "# creating $docu_foot...\n" if $verbose; |
| 1468 |
&print_toplevel_header("$title - Footnotes"); |
| 1469 |
&print_ruler; |
| 1470 |
&print(*foot_lines, FILE); |
| 1471 |
&print_toplevel_footer; |
| 1472 |
close(FILE); |
| 1473 |
} else { |
| 1474 |
warn "$ERROR Can't write to $docu_foot: $!\n"; |
| 1475 |
} |
| 1476 |
} |
| 1477 |
|
| 1478 |
# |
| 1479 |
# print document |
| 1480 |
# |
| 1481 |
if ($split_chapter || $split_node) { # split |
| 1482 |
$doc_num = 0; |
| 1483 |
$last_num = scalar(@sections); |
| 1484 |
$first_doc = &doc_name(1); |
| 1485 |
$last_doc = &doc_name($last_num); |
| 1486 |
while (@sections) { |
| 1487 |
$section = shift(@sections); |
| 1488 |
&next_doc; |
| 1489 |
if (open(FILE, "> $output_dir/$docu_doc")) { |
| 1490 |
print "# creating $docu_doc...\n" if $verbose; |
| 1491 |
&print_header("$title - $section"); |
| 1492 |
$prev_doc = ($doc_num == 1 ? undef : &doc_name($doc_num - 1)); |
| 1493 |
$next_doc = ($doc_num == $last_num ? undef : &doc_name($doc_num + 1)); |
| 1494 |
$navigation = "Go to the "; |
| 1495 |
$navigation .= ($prev_doc ? &anchor('', $first_doc, "first") : "first"); |
| 1496 |
$navigation .= ", "; |
| 1497 |
$navigation .= ($prev_doc ? &anchor('', $prev_doc, "previous") : "previous"); |
| 1498 |
$navigation .= ", "; |
| 1499 |
$navigation .= ($next_doc ? &anchor('', $next_doc, "next") : "next"); |
| 1500 |
$navigation .= ", "; |
| 1501 |
$navigation .= ($next_doc ? &anchor('', $last_doc, "last") : "last"); |
| 1502 |
$navigation .= " section, " . &anchor('', $docu_toc, "table of contents") . ".\n"; |
| 1503 |
print FILE $navigation; |
| 1504 |
&print_ruler; |
| 1505 |
# find corresponding lines |
| 1506 |
@tmp_lines = (); |
| 1507 |
while (@doc_lines) { |
| 1508 |
$_ = shift(@doc_lines); |
| 1509 |
last if ($_ eq $SPLITTAG); |
| 1510 |
push(@tmp_lines, $_); |
| 1511 |
} |
| 1512 |
&print(*tmp_lines, FILE); |
| 1513 |
&print_ruler; |
| 1514 |
print FILE $navigation; |
| 1515 |
&print_footer; |
| 1516 |
close(FILE); |
| 1517 |
} else { |
| 1518 |
warn "$ERROR Can't write to $docu_doc: $!\n"; |
| 1519 |
} |
| 1520 |
} |
| 1521 |
} else { # not split |
| 1522 |
if (open(FILE, "> $output_dir/$docu_doc")) { |
| 1523 |
print "# creating $docu_doc...\n" if $verbose; |
| 1524 |
if ($monolithic || !@toc_lines) { |
| 1525 |
&print_toplevel_header($title); |
| 1526 |
} else { |
| 1527 |
&print_header($title); |
| 1528 |
print FILE $full_title; |
| 1529 |
} |
| 1530 |
if ($monolithic && @toc_lines) { |
| 1531 |
&print_ruler; |
| 1532 |
print FILE "<H1>Table of Contents</H1>\n"; |
| 1533 |
&print(*toc_lines, FILE); |
| 1534 |
} |
| 1535 |
&print_ruler; |
| 1536 |
&print(*doc_lines, FILE); |
| 1537 |
if ($monolithic && @foot_lines) { |
| 1538 |
&print_ruler; |
| 1539 |
print FILE "<H1>Footnotes</H1>\n"; |
| 1540 |
&print(*foot_lines, FILE); |
| 1541 |
} |
| 1542 |
if ($monolithic || !@toc_lines) { |
| 1543 |
&print_toplevel_footer; |
| 1544 |
} else { |
| 1545 |
&print_footer; |
| 1546 |
} |
| 1547 |
close(FILE); |
| 1548 |
} else { |
| 1549 |
warn "$ERROR Can't write to $docu_doc: $!\n"; |
| 1550 |
} |
| 1551 |
} |
| 1552 |
|
| 1553 |
print "# that's all folks\n" if $verbose; |
| 1554 |
|
| 1555 |
#+++############################################################################ |
| 1556 |
# # |
| 1557 |
# Low level functions # |
| 1558 |
# # |
| 1559 |
#---############################################################################ |
| 1560 |
|
| 1561 |
sub update_sec_num { |
| 1562 |
local($name, $level) = @_; |
| 1563 |
|
| 1564 |
$level--; # here we start at 0 |
| 1565 |
if ($name =~ /^appendix/) { |
| 1566 |
# appendix style |
| 1567 |
if (@appendix_sec_num) { |
| 1568 |
&incr_sec_num($level, @appendix_sec_num); |
| 1569 |
} else { |
| 1570 |
@appendix_sec_num = ('A', 0, 0, 0); |
| 1571 |
} |
| 1572 |
return(join('.', @appendix_sec_num[0..$level])); |
| 1573 |
} else { |
| 1574 |
# normal style |
| 1575 |
if (@normal_sec_num) { |
| 1576 |
&incr_sec_num($level, @normal_sec_num); |
| 1577 |
} else { |
| 1578 |
@normal_sec_num = (1, 0, 0, 0); |
| 1579 |
} |
| 1580 |
return(join('.', @normal_sec_num[0..$level])); |
| 1581 |
} |
| 1582 |
} |
| 1583 |
|
| 1584 |
sub incr_sec_num { |
| 1585 |
local($level, $l); |
| 1586 |
$level = shift(@_); |
| 1587 |
$_[$level]++; |
| 1588 |
foreach $l ($level+1 .. 3) { |
| 1589 |
$_[$l] = 0; |
| 1590 |
} |
| 1591 |
} |
| 1592 |
|
| 1593 |
sub check { |
| 1594 |
local($_, %seen, %context, $before, $match, $after); |
| 1595 |
|
| 1596 |
while (<>) { |
| 1597 |
if (/\@(\*|\.|\:|\@|\{|\})/) { |
| 1598 |
$seen{$&}++; |
| 1599 |
$context{$&} .= "> $_" if $verbose; |
| 1600 |
$_ = "$`XX$'"; |
| 1601 |
redo; |
| 1602 |
} |
| 1603 |
if (/\@(\w+)/) { |
| 1604 |
($before, $match, $after) = ($`, $&, $'); |
| 1605 |
if ($before =~ /\b[\w-]+$/ && $after =~ /^[\w-.]*\b/) { # e-mail address |
| 1606 |
$seen{'e-mail address'}++; |
| 1607 |
$context{'e-mail address'} .= "> $_" if $verbose; |
| 1608 |
} else { |
| 1609 |
$seen{$match}++; |
| 1610 |
$context{$match} .= "> $_" if $verbose; |
| 1611 |
} |
| 1612 |
$match =~ s/^\@/X/; |
| 1613 |
$_ = "$before$match$after"; |
| 1614 |
redo; |
| 1615 |
} |
| 1616 |
} |
| 1617 |
|
| 1618 |
foreach (sort(keys(%seen))) { |
| 1619 |
if ($verbose) { |
| 1620 |
print "$_\n"; |
| 1621 |
print $context{$_}; |
| 1622 |
} else { |
| 1623 |
print "$_ ($seen{$_})\n"; |
| 1624 |
} |
| 1625 |
} |
| 1626 |
} |
| 1627 |
|
| 1628 |
sub open { |
| 1629 |
local($name) = @_; |
| 1630 |
|
| 1631 |
++$fh_name; |
| 1632 |
if (open($fh_name, $name)) { |
| 1633 |
unshift(@fhs, $fh_name); |
| 1634 |
} else { |
| 1635 |
warn "$ERROR Can't read file $name: $!\n"; |
| 1636 |
} |
| 1637 |
} |
| 1638 |
|
| 1639 |
sub init_input { |
| 1640 |
@fhs = (); # hold the file handles to read |
| 1641 |
@input_spool = (); # spooled lines to read |
| 1642 |
$fh_name = 'FH000'; |
| 1643 |
&open($docu); |
| 1644 |
} |
| 1645 |
|
| 1646 |
sub next_line { |
| 1647 |
local($fh, $line); |
| 1648 |
|
| 1649 |
if (@input_spool) { |
| 1650 |
$line = shift(@input_spool); |
| 1651 |
return($line); |
| 1652 |
} |
| 1653 |
while (@fhs) { |
| 1654 |
$fh = $fhs[0]; |
| 1655 |
$line = <$fh>; |
| 1656 |
return($line) if $line; |
| 1657 |
close($fh); |
| 1658 |
shift(@fhs); |
| 1659 |
} |
| 1660 |
return(undef); |
| 1661 |
} |
| 1662 |
|
| 1663 |
# used in pass 1, use &next_line |
| 1664 |
sub skip_until { |
| 1665 |
local($tag) = @_; |
| 1666 |
local($_); |
| 1667 |
|
| 1668 |
while ($_ = &next_line) { |
| 1669 |
return if /^\@end\s+$tag\s*$/; |
| 1670 |
} |
| 1671 |
die "* Failed to find '$tag' after: " . $lines[$#lines]; |
| 1672 |
} |
| 1673 |
|
| 1674 |
# |
| 1675 |
# HTML stacking to have a better HTML output |
| 1676 |
# |
| 1677 |
|
| 1678 |
sub html_reset { |
| 1679 |
@html_stack = ('html'); |
| 1680 |
$html_element = 'body'; |
| 1681 |
} |
| 1682 |
|
| 1683 |
sub html_push { |
| 1684 |
local($what) = @_; |
| 1685 |
push(@html_stack, $html_element); |
| 1686 |
$html_element = $what; |
| 1687 |
} |
| 1688 |
|
| 1689 |
sub html_push_if { |
| 1690 |
local($what) = @_; |
| 1691 |
push(@html_stack, $html_element) |
| 1692 |
if ($html_element && $html_element ne 'P'); |
| 1693 |
$html_element = $what; |
| 1694 |
} |
| 1695 |
|
| 1696 |
sub html_pop { |
| 1697 |
$html_element = pop(@html_stack); |
| 1698 |
} |
| 1699 |
|
| 1700 |
sub html_pop_if { |
| 1701 |
local($elt); |
| 1702 |
|
| 1703 |
if (@_) { |
| 1704 |
foreach $elt (@_) { |
| 1705 |
if ($elt eq $html_element) { |
| 1706 |
$html_element = pop(@html_stack) if @html_stack; |
| 1707 |
last; |
| 1708 |
} |
| 1709 |
} |
| 1710 |
} else { |
| 1711 |
$html_element = pop(@html_stack) if @html_stack; |
| 1712 |
} |
| 1713 |
} |
| 1714 |
|
| 1715 |
sub html_debug { |
| 1716 |
local($what, $line) = @_; |
| 1717 |
return("<!-- $line @html_stack, $html_element -->$what") |
| 1718 |
if $debug & $DEBUG_HTML; |
| 1719 |
return($what); |
| 1720 |
} |
| 1721 |
|
| 1722 |
# to debug the output... |
| 1723 |
sub debug { |
| 1724 |
local($what, $line) = @_; |
| 1725 |
return("<!-- $line -->$what") |
| 1726 |
if $debug & $DEBUG_HTML; |
| 1727 |
return($what); |
| 1728 |
} |
| 1729 |
|
| 1730 |
sub normalise_node { |
| 1731 |
$_[0] =~ s/\s+/ /g; |
| 1732 |
$_[0] =~ s/ $//; |
| 1733 |
$_[0] =~ s/^ //; |
| 1734 |
} |
| 1735 |
|
| 1736 |
sub menu_entry { |
| 1737 |
local($entry, $node, $descr) = @_; |
| 1738 |
local($href); |
| 1739 |
|
| 1740 |
&normalise_node($node); |
| 1741 |
$href = $node2href{$node}; |
| 1742 |
if ($href) { |
| 1743 |
$descr =~ s/^\s+//; |
| 1744 |
$descr = ": $descr" if $descr; |
| 1745 |
push(@lines2, "<LI>" . &anchor('', $href, $entry) . "$descr\n"); |
| 1746 |
} else { |
| 1747 |
warn "$ERROR Undefined node ($node): $_"; |
| 1748 |
} |
| 1749 |
} |
| 1750 |
|
| 1751 |
sub do_ctrl { "^$_[0]" } |
| 1752 |
|
| 1753 |
sub do_email { |
| 1754 |
local($addr, $text) = split(/,\s*/, $_[0]); |
| 1755 |
|
| 1756 |
$text = $addr unless $text; |
| 1757 |
&anchor('', "mailto:$addr", $text); |
| 1758 |
} |
| 1759 |
|
| 1760 |
sub do_sc { "\U$_[0]\E" } |
| 1761 |
|
| 1762 |
sub do_uref { |
| 1763 |
local($url, $text) = split(/,\s*/, $_[0]); |
| 1764 |
|
| 1765 |
$text = $url unless $text; |
| 1766 |
&anchor('', $url, $text); |
| 1767 |
} |
| 1768 |
|
| 1769 |
sub do_url { &anchor('', $_[0], $_[0]) } |
| 1770 |
|
| 1771 |
sub do_diaeresis { return "&$_[0]uml;"; } |
| 1772 |
sub do_acuteaccent { return "&$_[0]acute;"; } |
| 1773 |
sub do_graveaccent { return "&$_[0]grave;"; } |
| 1774 |
sub do_tildeaccent { return "&$_[0]tilde;"; } |
| 1775 |
sub do_cedilla { return "&$_[0]cedil;"; } |
| 1776 |
sub do_circumflex { return "&$_[0]circ;"; } |
| 1777 |
|
| 1778 |
sub apply_style { |
| 1779 |
local($texi_style, $text) = @_; |
| 1780 |
local($style); |
| 1781 |
|
| 1782 |
$style = $style_map{$texi_style}; |
| 1783 |
if (defined($style)) { # known style |
| 1784 |
if ($style =~ /^\"/) { # add quotes |
| 1785 |
$style = $'; |
| 1786 |
$text = "\‘$text\’"; |
| 1787 |
} |
| 1788 |
if ($style =~ /^\&/) { # custom |
| 1789 |
$style = $'; |
| 1790 |
$text = &$style($text); |
| 1791 |
} elsif ($style) { # good style |
| 1792 |
$text = "<$style>$text</$style>"; |
| 1793 |
} else { # no style |
| 1794 |
} |
| 1795 |
} else { # unknown style |
| 1796 |
$text = undef; |
| 1797 |
} |
| 1798 |
return($text); |
| 1799 |
} |
| 1800 |
|
| 1801 |
# remove Texinfo styles |
| 1802 |
sub remove_style { |
| 1803 |
local($_) = @_; |
| 1804 |
s/\@\w+{([^\{\}]+)}/$1/g; |
| 1805 |
return($_); |
| 1806 |
} |
| 1807 |
|
| 1808 |
sub substitute_style { |
| 1809 |
local($_) = @_; |
| 1810 |
local($changed, $done, $style, $text); |
| 1811 |
|
| 1812 |
$changed = 1; |
| 1813 |
while ($changed) { |
| 1814 |
$changed = 0; |
| 1815 |
$done = ''; |
| 1816 |
while (/\@(\w+|"|\~|,|\^)\{([^\{\}]+)\}/) { |
| 1817 |
$text = &apply_style($1, $2); |
| 1818 |
if ($text) { |
| 1819 |
$_ = "$`$text$'"; |
| 1820 |
$changed = 1; |
| 1821 |
} else { |
| 1822 |
$done .= "$`\@$1"; |
| 1823 |
$_ = "{$2}$'"; |
| 1824 |
} |
| 1825 |
} |
| 1826 |
$_ = $done . $_; |
| 1827 |
} |
| 1828 |
return($_); |
| 1829 |
} |
| 1830 |
|
| 1831 |
sub anchor { |
| 1832 |
local($name, $href, $text, $newline) = @_; |
| 1833 |
local($result); |
| 1834 |
|
| 1835 |
$result = "<A"; |
| 1836 |
$result .= " NAME=\"$name\"" if $name; |
| 1837 |
$result .= " HREF=\"$href\"" if $href; |
| 1838 |
$result .= ">$text</A>"; |
| 1839 |
$result .= "\n" if $newline; |
| 1840 |
return($result); |
| 1841 |
} |
| 1842 |
|
| 1843 |
sub pretty_date { |
| 1844 |
local(@MoY, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); |
| 1845 |
|
| 1846 |
@MoY = ('January', 'February', 'March', 'April', 'May', 'June', |
| 1847 |
'July', 'August', 'September', 'October', 'November', 'December'); |
| 1848 |
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); |
| 1849 |
$year += ($year < 70) ? 2000 : 1900; |
| 1850 |
return("$mday $MoY[$mon] $year"); |
| 1851 |
} |
| 1852 |
|
| 1853 |
sub doc_name { |
| 1854 |
local($num) = @_; |
| 1855 |
|
| 1856 |
return("${docu_name}_$num.html"); |
| 1857 |
} |
| 1858 |
|
| 1859 |
sub next_doc { |
| 1860 |
$docu_doc = &doc_name(++$doc_num); |
| 1861 |
} |
| 1862 |
|
| 1863 |
sub print { |
| 1864 |
local(*lines, $fh) = @_; |
| 1865 |
local($_); |
| 1866 |
|
| 1867 |
while (@lines) { |
| 1868 |
$_ = shift(@lines); |
| 1869 |
if (/^$PROTECTTAG/o) { |
| 1870 |
$_ = $tag2pro{$_}; |
| 1871 |
} else { |
| 1872 |
&unprotect_texi; |
| 1873 |
} |
| 1874 |
print $fh $_; |
| 1875 |
} |
| 1876 |
} |
| 1877 |
|
| 1878 |
sub print_ruler { |
| 1879 |
print FILE "<P><HR><P>\n"; |
| 1880 |
} |
| 1881 |
|
| 1882 |
sub print_header { |
| 1883 |
local($_); |
| 1884 |
|
| 1885 |
# clean the title |
| 1886 |
$_ = &remove_style($_[0]); |
| 1887 |
&unprotect_texi; |
| 1888 |
# print the header |
| 1889 |
if ($doctype eq 'html2') { |
| 1890 |
print FILE $html2_doctype; |
| 1891 |
} elsif ($doctype) { |
| 1892 |
print FILE $doctype; |
| 1893 |
} |
| 1894 |
print FILE <<EOT; |
| 1895 |
<HTML> |
| 1896 |
<HEAD> |
| 1897 |
$header |
| 1898 |
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"> |
| 1899 |
<TITLE>$_</TITLE> |
| 1900 |
</HEAD> |
| 1901 |
<BODY> |
| 1902 |
EOT |
| 1903 |
} |
| 1904 |
|
| 1905 |
sub print_toplevel_header { |
| 1906 |
local($_); |
| 1907 |
|
| 1908 |
&print_header; # pass given arg... |
| 1909 |
print FILE $full_title; |
| 1910 |
if ($value{'_subtitle'}) { |
| 1911 |
$value{'_subtitle'} =~ s/\n+$//; |
| 1912 |
foreach (split(/\n/, $value{'_subtitle'})) { |
| 1913 |
$_ = &substitute_style($_); |
| 1914 |
&unprotect_texi; |
| 1915 |
print FILE "<H2>$_</H2>\n"; |
| 1916 |
} |
| 1917 |
} |
| 1918 |
if ($value{'_author'}) { |
| 1919 |
$value{'_author'} =~ s/\n+$//; |
| 1920 |
foreach (split(/\n/, $value{'_author'})) { |
| 1921 |
$_ = &substitute_style($_); |
| 1922 |
&unprotect_texi; |
| 1923 |
s/[\w.-]+\@[\w.-]+/<A HREF="mailto:$&">$&<\/A>/g; |
| 1924 |
print FILE "<ADDRESS>$_</ADDRESS>\n"; |
| 1925 |
} |
| 1926 |
} |
| 1927 |
print FILE "<P>\n"; |
| 1928 |
} |
| 1929 |
|
| 1930 |
sub print_footer { |
| 1931 |
print FILE <<EOT; |
| 1932 |
</BODY> |
| 1933 |
</HTML> |
| 1934 |
EOT |
| 1935 |
} |
| 1936 |
|
| 1937 |
sub print_toplevel_footer { |
| 1938 |
&print_ruler; |
| 1939 |
print FILE <<EOT; |
| 1940 |
This document was generated on $TODAY using the |
| 1941 |
<A HREF=\"$HOMEPAGE\">texi2html</A> |
| 1942 |
translator version 1.52b.</P> |
| 1943 |
EOT |
| 1944 |
&print_footer; |
| 1945 |
} |
| 1946 |
|
| 1947 |
sub protect_texi { |
| 1948 |
# protect @ { } ` ' |
| 1949 |
s/\@\@/$;0/go; |
| 1950 |
s/\@\{/$;1/go; |
| 1951 |
s/\@\}/$;2/go; |
| 1952 |
s/\@\`/$;3/go; |
| 1953 |
s/\@\'/$;4/go; |
| 1954 |
} |
| 1955 |
|
| 1956 |
sub protect_html { |
| 1957 |
local($what) = @_; |
| 1958 |
# protect & < > |
| 1959 |
$what =~ s/\&/\&\#38;/g; |
| 1960 |
$what =~ s/\</\&\#60;/g; |
| 1961 |
$what =~ s/\>/\&\#62;/g; |
| 1962 |
# but recognize some HTML things |
| 1963 |
$what =~ s/\&\#60;\/A\&\#62;/<\/A>/g; # </A> |
| 1964 |
$what =~ s/\&\#60;A ([^\&]+)\&\#62;/<A $1>/g; # <A [^&]+> |
| 1965 |
$what =~ s/\&\#60;IMG ([^\&]+)\&\#62;/<IMG $1>/g; # <IMG [^&]+> |
| 1966 |
return($what); |
| 1967 |
} |
| 1968 |
|
| 1969 |
sub unprotect_texi { |
| 1970 |
s/$;0/\@/go; |
| 1971 |
s/$;1/\{/go; |
| 1972 |
s/$;2/\}/go; |
| 1973 |
s/$;3/\`/go; |
| 1974 |
s/$;4/\'/go; |
| 1975 |
} |
| 1976 |
|
| 1977 |
sub unprotect_html { |
| 1978 |
local($what) = @_; |
| 1979 |
$what =~ s/\&\#38;/\&/g; |
| 1980 |
$what =~ s/\&\#60;/\</g; |
| 1981 |
$what =~ s/\&\#62;/\>/g; |
| 1982 |
return($what); |
| 1983 |
} |
| 1984 |
|
| 1985 |
sub byalpha { |
| 1986 |
$key2alpha{$a} cmp $key2alpha{$b}; |
| 1987 |
} |
| 1988 |
|
| 1989 |
############################################################################## |
| 1990 |
|
| 1991 |
# These next few lines are legal in both Perl and nroff. |
| 1992 |
|
| 1993 |
.00 ; # finish .ig |
| 1994 |
|
| 1995 |
'di \" finish diversion--previous line must be blank |
| 1996 |
.nr nl 0-1 \" fake up transition to first page again |
| 1997 |
.nr % 0 \" start at page 1 |
| 1998 |
'; __END__ ############# From here on it's a standard manual page ############ |
| 1999 |
.TH TEXI2HTML 1 "01/05/98" |
| 2000 |
.AT 3 |
| 2001 |
.SH NAME |
| 2002 |
texi2html \- a Texinfo to HTML converter |
| 2003 |
.SH SYNOPSIS |
| 2004 |
.B texi2html [options] file |
| 2005 |
.PP |
| 2006 |
.B texi2html -check [-verbose] files |
| 2007 |
.SH DESCRIPTION |
| 2008 |
.I Texi2html |
| 2009 |
converts the given Texinfo file to a set of HTML files. It tries to handle |
| 2010 |
most of the Texinfo commands. It creates hypertext links for cross-references, |
| 2011 |
footnotes... |
| 2012 |
.PP |
| 2013 |
It also tries to add links from a reference to its corresponding entry in the |
| 2014 |
bibliography (if any). It may also handle a glossary (see the |
| 2015 |
.B \-glossary |
| 2016 |
option). |
| 2017 |
.PP |
| 2018 |
.I Texi2html |
| 2019 |
creates several files depending on the contents of the Texinfo file and on |
| 2020 |
the chosen options (see FILES). |
| 2021 |
.PP |
| 2022 |
The HTML files created by |
| 2023 |
.I texi2html |
| 2024 |
are closer to TeX than to Info, that's why |
| 2025 |
.I texi2html |
| 2026 |
converts @ifhtml sections and not @ifinfo or @iftex ones by default. You can |
| 2027 |
change this with the \-expandinfo or \-expandtex options. |
| 2028 |
.SH OPTIONS |
| 2029 |
.TP 12 |
| 2030 |
.B \-check |
| 2031 |
Check the given file and give the list of all things that may be Texinfo commands. |
| 2032 |
This may be used to check the output of |
| 2033 |
.I texi2html |
| 2034 |
to find the Texinfo commands that have been left in the HTML file. |
| 2035 |
.TP |
| 2036 |
.B \-expandinfo |
| 2037 |
Expand @ifinfo sections, not @ifhtml ones. |
| 2038 |
.TP |
| 2039 |
.B \-expandtex |
| 2040 |
Expand @iftex sections, not @ifhtml ones. |
| 2041 |
.TP |
| 2042 |
.B \-glossary |
| 2043 |
Use the section named 'Glossary' to build a list of terms and put links in the HTML |
| 2044 |
document from each term toward its definition. |
| 2045 |
.TP |
| 2046 |
.B \-invisible \fIname\fP |
| 2047 |
Use \fIname\fP to create invisible destination anchors for index links |
| 2048 |
(you can for instance use the invisible.xbm file shipped with this program). |
| 2049 |
This is a workaround for a known bug of many WWW browsers, including netscape. |
| 2050 |
.TP |
| 2051 |
.B \-I \fIdir\fP |
| 2052 |
Look also in \fIdir\fP to find included files. |
| 2053 |
.TP |
| 2054 |
.B \-menu |
| 2055 |
Show the Texinfo menus; by default they are ignored. |
| 2056 |
.TP |
| 2057 |
.B \-monolithic |
| 2058 |
Output only one file, including the table of contents and footnotes. |
| 2059 |
.TP |
| 2060 |
.B \-number |
| 2061 |
Number the sections. |
| 2062 |
.TP |
| 2063 |
.B \-split_chapter |
| 2064 |
Split the output into several HTML files (one per main section: |
| 2065 |
chapter, appendix...). |
| 2066 |
.TP |
| 2067 |
.B \-split_node |
| 2068 |
Split the output into several HTML files (one per node). |
| 2069 |
.TP |
| 2070 |
.B \-usage |
| 2071 |
Print usage instructions, listing the current available command-line options. |
| 2072 |
.TP |
| 2073 |
.B \-verbose |
| 2074 |
Give a verbose output. Can be used with the |
| 2075 |
.B \-check |
| 2076 |
option. |
| 2077 |
.PP |
| 2078 |
.SH FILES |
| 2079 |
By default |
| 2080 |
.I texi2html |
| 2081 |
creates the following files (foo being the name of the Texinfo file): |
| 2082 |
.TP 16 |
| 2083 |
.B foo_toc.html |
| 2084 |
The table of contents. |
| 2085 |
.TP |
| 2086 |
.B foo.html |
| 2087 |
The document's contents. |
| 2088 |
.TP |
| 2089 |
.B foo_foot.html |
| 2090 |
The footnotes (if any). |
| 2091 |
.PP |
| 2092 |
When used with the |
| 2093 |
.B \-split |
| 2094 |
option, it creates several files (one per chapter or node), named |
| 2095 |
.B foo_n.html |
| 2096 |
(n being the indice of the chapter or node), instead of the single |
| 2097 |
.B foo.html |
| 2098 |
file. |
| 2099 |
.PP |
| 2100 |
When used with the |
| 2101 |
.B \-monolithic |
| 2102 |
option, it creates only one file: |
| 2103 |
.B foo.html |
| 2104 |
.SH VARIABLES |
| 2105 |
.I texi2html |
| 2106 |
predefines the following variables: \fBhtml\fP, \fBtexi2html\fP. |
| 2107 |
.SH ADDITIONAL COMMANDS |
| 2108 |
.I texi2html |
| 2109 |
implements the following non-Texinfo commands (maybe they are in Texinfo now...): |
| 2110 |
.TP 16 |
| 2111 |
.B @ifhtml |
| 2112 |
This indicates the start of an HTML section, this section will passed through |
| 2113 |
without any modification. |
| 2114 |
.TP |
| 2115 |
.B @end ifhtml |
| 2116 |
This indicates the end of an HTML section. |
| 2117 |
.SH VERSION |
| 2118 |
This is \fItexi2html\fP version 1.52b, 01/05/98. |
| 2119 |
.PP |
| 2120 |
The latest version of \fItexi2html\fP can be found in WWW, cf. URL |
| 2121 |
http://wwwinfo.cern.ch/dis/texi2html/ |
| 2122 |
.SH AUTHOR |
| 2123 |
The main author is Lionel Cons, CERN IT/DIS/OSE, [email protected]. |
| 2124 |
Many other people around the net contributed to this program. |
| 2125 |
.SH COPYRIGHT |
| 2126 |
This program is the intellectual property of the European |
| 2127 |
Laboratory for Particle Physics (known as CERN). No guarantee whatsoever is |
| 2128 |
provided by CERN. No liability whatsoever is accepted for any loss or damage |
| 2129 |
of any kind resulting from any defect or inaccuracy in this information or |
| 2130 |
code. |
| 2131 |
.PP |
| 2132 |
CERN, 1211 Geneva 23, Switzerland |
| 2133 |
.SH "SEE ALSO" |
| 2134 |
GNU Texinfo Documentation Format, |
| 2135 |
HyperText Markup Language (HTML), |
| 2136 |
World Wide Web (WWW). |
| 2137 |
.SH BUGS |
| 2138 |
This program does not understand all Texinfo commands (yet). |
| 2139 |
.ex |