Changeset 4e425a in git
- Timestamp:
- Jul 30, 1999, 12:37:05 PM (24 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- 3d276d2b96d8b91e89923453839edc84b93c91ed
- Parents:
- 9613a6779c21616f1854f49fb05fae3c10886d20
- Location:
- doc
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/Makefile.lib2doc
r9613a6 r4e425a 2 2 ## 3 3 ## Makefiel for generation of docu for libraries 4 ## $Id: Makefile.lib2doc,v 1. 1 1999-07-28 11:36:31obachman Exp $4 ## $Id: Makefile.lib2doc,v 1.2 1999-07-30 10:37:02 obachman Exp $ 5 5 ##################################################################### 6 6 … … 19 19 ## 2.) Set this to the name of your latex2html program, if you have latex2html 20 20 ## 21 LATEX2HTML = 21 LATEX2HTML = latex2html 22 22 23 23 -
doc/lib2doc.texi
r9613a6 r4e425a 16 16 @strong{Important:} 17 17 @*To use @code{lib2doc}, you need 18 to have @code{Singular}, @code{libparse}, and @code{perl} (version 5 or 18 to have @code{perl} (version 5 or 19 higher) and @code{Singular} and @code{libparse} (version 1-3-4 or 19 20 higher) installed on your system. 20 21 21 22 22 To generate the documentation for a library, follow these steps: -
doc/pl2doc.pl
r9613a6 r4e425a 1 1 #!/usr/local/bin/perl 2 # $Id: pl2doc.pl,v 1. 6 1999-07-28 11:36:32obachman Exp $2 # $Id: pl2doc.pl,v 1.7 1999-07-30 10:37:04 obachman Exp $ 3 3 ################################################################### 4 4 # Computer Algebra System SINGULAR … … 55 55 56 56 undef @procs; # will be again defined by OutLibInfo 57 $parsing = "info-string of lib $lib:"; 57 58 $ref = OutLibInfo(\*LDOC, $info, ! $no_fun); 58 59 OutRef(\*LDOC, $ref) if $ref; … … 95 96 $table_is_open = 1; 96 97 # print help 98 $parsing = "help-string of $lib:$procs[$i]:"; 97 99 $ref = OutInfo(\*LDOC, $help{$procs[$i]}); 98 100 print LDOC "\@end table\n"; … … 118 120 { 119 121 print LDOC <<EOT; 122 \@c ---------------------------------------------------------- 123 \@node Index, , Singular libraries, Top 124 \@chapter Index 125 \@printindex cp 120 126 121 127 \@bye … … 124 130 125 131 close(LDOC); 132 if ($error) 133 { 134 print STDERR "ERROR: $error\n"; 135 exit(1); 136 } 126 137 exit(0); 127 138 … … 134 145 my ($FH, $info, $l_fun) = @_; 135 146 print $FH "\@c ---content LibInfo---\n"; 136 147 if ($info =~ /^\@/) 137 148 { 138 149 print $FH $info; … … 153 164 { 154 165 my ($FH, $info, $l_fun) = @_; 155 if ($info =~ /^\ s*\@/)166 if ($info =~ /^\@/) 156 167 { 157 168 print $FH $info; … … 184 195 { 185 196 my $length = shift; 197 my ($pline, $line, $text, $ptext, $special); 198 my ($in_format, $in_example, $in_texinfo); 199 186 200 $length = 0 unless $length; 187 # insert @* infront of all lines whose previous line is shorter than 188 # 60 characters 189 $_ = ' ' x $length . $_; 190 if (/^(.*)\n/) 191 { 192 $_ .= "\n"; 193 my $pline; 194 my $line; 195 my $ptext = $_; 196 my $text = ''; 197 while ($ptext =~ /(.*)\n/g) 198 { 199 $line = $1; 200 # break line if 201 $text .= '@*' 202 if ($line =~ /\w/ && $pline =~ /\w/ # line and prev line are not empty 203 && $line !~ /^\s*\@\*/ # line does not start with @* 204 && $pline !~ /\@\*\s*/ # prev line does not end with @* 205 && 206 ((length($pline) < 60 && # prev line is shorter than 60 chars 207 $pline !~ /\@code{.*?}/ # and does not contain @code, @math 208 && $pline !~ /\@math{.*?}/) 209 || 210 $line =~ /^\s*\w*\(.*?\)/ # $line starts with \w*(..) 211 || 212 $pline =~ /^\s*\w*\(.*?\)[\s;:]*$/)); # prev line is only \w(..) 213 $line =~ s/\s*$//; 214 $text .= "$line\n"; 215 $pline = $line; 216 } 217 $_ = $text; 218 } 219 s/\t/ /g; 220 s/\n +/\n/g; 221 s/\s*$//g; 222 s/ +/ /g; # replace double whitespaces by one 223 s/(\w+\(.*?\))/\@code{$1}/g; 224 s/\@\*\s*/\@\*/g; 225 s/(\@[^\*])/\@$1/g; # escape @ signs, except @* 226 s/{/\@{/g; # escape {} 227 s/}/\@}/g; 228 # unprotect @@math@{@}, @code@{@} 229 while (s/\@\@math\@{(.*?)\@}/\@math{$1}/g) {} 230 while (s/\@\@code\@{(.*?)\@}/\@code{$1}/g) {} 231 # remove @code{} inside @code{} and inside @math{} 232 while (s/\@math{([^}]*)\@code{(.*?)}(.*)?}/\@math{$1$2$3}/g) {} 233 while (s/\@code{([^}]*)\@code{(.*?)}(.*)?}/\@code{$1$2$3}/g) {} 201 $_ .= "\n"; 202 $ptext = $_; 203 while ($ptext =~ /(.*)\n/g) 204 { 205 $pline = $line; 206 $line = $1; 207 # check whether we are in protected env 208 if ($in_format || $in_example || $in_texinfo) 209 { 210 # end protected env? 211 if ($line =~ /^\s*\@end (format|example|texinfo)\s*$/) 212 { 213 if ($in_format && $1 eq 'format') 214 { 215 $in_format = 0; 216 $text .= "$line\n"; 217 } 218 elsif ($in_example && $1 eq 'example') 219 { 220 $in_example = 0; 221 $text .= "\@end smallexample\n"; 222 } 223 elsif ($in_texinfo && $1 eq 'texinfo') 224 { 225 $in_texinfo = 0; 226 $text .= "\n"; 227 } 228 else 229 { 230 $error = "While parsing $parsing: \@end $1 found without matching \@$1" unless $error; 231 } 232 next; 233 } 234 else 235 { 236 $text .= "$line\n"; 237 next; 238 } 239 } 240 # look for @example, @format, @texinfo 241 if ($line =~ /^\s*\@(example|format|texinfo)\s*$/) 242 { 243 $special = 1; 244 if ($1 eq 'example') 245 { 246 $text .= "\@smallexample\n"; 247 $in_example = 1; 248 } 249 elsif ($1 eq 'format') 250 { 251 $text .= "$line\n"; 252 $in_format = 1; 253 } 254 else 255 { 256 $text .= "\n"; 257 $in_texinfo = 1; 258 } 259 next; 260 } 261 if ($line =~ /([^\@]|^)\@(code|math){(.*?)}/) 262 { 263 my $l = $line; 264 $l =~ s/^\s*//; 265 $l =~ s/\s$//; 266 while ($l =~ /([^\@]|^)\@(code|math){(.*?)}/) 267 { 268 $text .= CleanAscii($`.$1); 269 $text .= "\@$2\{$3\}"; 270 $l = $'; 271 } 272 $special = 1; 273 $text .= CleanAscii($l) . "\n"; 274 next; 275 } 276 # break line if 277 $text .= '@*' 278 if ($line =~ /\w/ 279 && $pline =~ /\w/ # line and prev line are not empty 280 && $line !~ /^\s*\@\*/ # line does not start with @* 281 && $pline !~ /\@\*\s*/ # prev line does not end with @* 282 && length($pline) + $length < 60 # prev line is shorter than 60 chars 283 && ! $special); # prev line was not special line 284 $line =~ s/^\s*//; 285 $line =~ s/\s$//; 286 $special = 0; 287 $text .= CleanAscii($line) . "\n"; 288 } 289 $_ = $text; 290 s/^\s*//; 291 s/\s*$//; 292 $_ .= "\n"; 293 if ($in_format || $in_texinfo || $in_example) 294 { 295 $error = "While parsing $parsing: no matching \@end " . 296 ($in_format ? "format" : ($in_texinfo ? "texinfo" : "example" )) . 297 " found" 298 unless $error; 299 } 300 } 301 302 sub CleanAscii 303 { 304 my $a = shift; 305 $a =~ s/(\@([^\*]|$))/\@$1/g; # escape @ signs, except @*, @{, @} 306 $a =~ s/{/\@{/g; # escape {} 307 $a =~ s/}/\@}/g; 308 $a =~ s/\t/ /g; 309 $a =~ s/ +/ /g; 310 return $a; 234 311 } 235 312 … … 237 314 { 238 315 my ($FH, $item, $text, $l_fun) = @_; 316 local $parsing = $parsing . uc($item); 239 317 240 318 $item = lc $item; … … 291 369 return ''; 292 370 } 293 371 elsif ($item =~ m/keywords/i || m/keyphrases/i) 372 { 373 # index entries 374 return OutKeywords($FH, $text); 375 } 376 294 377 if (! $table_is_open) 295 378 { … … 326 409 s/\n/ /g; 327 410 FormatInfoText(); 328 329 411 if ($l_fun) 330 412 { 331 print $FH "* ${proc}:: $_ \n";413 print $FH "* ${proc}:: $_"; 332 414 push @procs, $proc; 333 415 } … … 335 417 { 336 418 print $FH "\@item \@code{$proc($procargs)} "; 337 print $FH "\n\@cindex $proc\n$_ \n";419 print $FH "\n\@cindex $proc\n$_"; 338 420 } 339 421 } … … 360 442 } 361 443 444 sub OutKeywords 445 { 446 my ($FH, $kws) = @_; 447 for $kw (split (/;/, $kws)) 448 { 449 $kw =~ s/^\s*(.*?)\s*$/$1/; 450 print $FH "\@cindex $kw\n"; 451 } 452 } 453 362 454 sub CleanUpExample 363 455 { … … 408 500 \@setfilename $hlp_file 409 501 \@settitle Formatted manual of $lib.lib 502 \@paragraphindent 0 410 503 \@c %**end of header 411 504 … … 426 519 \@menu 427 520 * Singular libraries:: 521 * Index:: 428 522 \@end menu 429 523 430 \@node Singular libraries, ,,Top524 \@node Singular libraries, Index,,Top 431 525 \@comment node-name,next, previous, up 432 526 \@chapter Singular libraries -
doc/t2h_singular.init
r9613a6 r4e425a 67 67 EOT 68 68 } 69 70 # always use bottom navigation 71 $T2H_WORDS_IN_PAGE = 0; 69 72 70 73 $T2H_VERTICAL_HEAD_NAVIGATION = 1; -
doc/texi2html
r9613a6 r4e425a 1 #!/usr/ bin/perl1 #!/usr/local/bin/perl 2 2 'di '; 3 3 'ig 00 '; 4 # $Id: texi2html,v 1.7 1998-06-19 15:55:28 obachman Exp $ 5 # Description: Program to transform most Texinfo documents to HTML. 6 # The plan is for the next version of makeinfo to support HTML output 7 # directly, but until then ... 8 9 $THISPROG = "texi2html 1.54"; # program name and version 10 # This version of texi2html is currently maintained at 11 # ftp://ftp.cs.umb.edu/pub/tex/texi2html by kb@cs.umb.edu. 12 4 #+############################################################################## 5 # # 6 # File: texi2html # 7 # # 8 # Description: Program to transform most Texinfo documents to HTML # 9 # # 10 #-############################################################################## 11 12 # From @(#)texi2html 1.52 01/05/98 13 # $Id: texi2html,v 1.8 1999-07-30 10:37:05 obachman Exp $ 14 # Homepage: 15 $T2H_HOMEPAGE = <<EOT; 16 http://www.mathematik.uni-kl.de/~obachman/Texi2html 17 EOT 18 # Authors: 19 $T2H_AUTHORS = <<EOT; 20 Written (mainly) by: Lionel Cons, Lionel.Cons\@cern.ch 21 Currently maintained by : Olaf Bachmann, obachman\@mathematik.uni-kl.de 22 EOT 23 # Version: 24 $THISVERSION = "1.58"; 25 $THISPROG = "texi2html $THISVERSION"; # program name and version 26 13 27 # The man page for this program is included at the end of this file and can be 14 28 # viewed using the command 'nroff -man texi2html'. 15 29 # Please read the copyright at the end of the man page. 16 30 17 # Fixme: 18 # deal with @macro @unmacro @shorttitlepage @detailmenu @image 19 # [plus more fixmes below] 20 # Use <link>s for Up, Index, Glossary? 21 # Inserting copyright links: Having texinfo markup for the online copyright 22 # would allow a link to that from wherever. 31 $T2H_TODAY = &pretty_date; # like "20 September 1993" 32 ($T2H_USER = (getpwuid ($<))[6]) =~ s/,.*//; # Who am i 33 34 #+++############################################################################ 35 # # 36 # Initialization # 37 # Pasted content of File $T2H_HOME/texi2html.init # 38 # # 39 #---############################################################################ 40 41 require "$ENV{T2H_HOME}/texi2html.init"; # Makefile:include 23 42 24 43 #+++############################################################################ … … 35 54 $DEBUG_HTML = 32; 36 55 $DEBUG_USER = 64; 37 38 #$IMG_FIRST_ACTIVE = "<IMG SRC=\"first-b.gif\">"; 39 #$IMG_FIRST_PASSIVE = "<IMG SRC=\"first-t.gif\">"; 40 #$IMG_LAST_ACTIVE = "<IMG SRC=\"last-b.gif\">"; 41 #$IMG_LAST_PASSIVE = "<IMG SRC=\"last-t.gif\">"; 42 #$IMG_NEXT_ACTIVE = "<IMG SRC=\"next-b.gif\">"; 43 #$IMG_NEXT_PASSIVE = "<IMG SRC=\"next-t.gif\">"; 44 #$IMG_PREV_ACTIVE = "<IMG SRC=\"previous-b.gif\">"; 45 #$IMG_PREV_PASSIVE = "<IMG SRC=\"previous-t.gif\">"; 46 #$IMG_TOC = "<IMG SRC=\"toc-b.gif\">"; 47 $IMG_FIRST_ACTIVE = ""; 48 $IMG_FIRST_PASSIVE = ""; 49 $IMG_LAST_ACTIVE = ""; 50 $IMG_LAST_PASSIVE = ""; 51 $IMG_NEXT_ACTIVE = "<IMG SRC=\"images/next_motif.gif\">"; 52 $IMG_NEXT_PASSIVE = "<IMG SRC=\"images/next_motif_gr.gif\">"; 53 $IMG_PREV_ACTIVE = "<IMG SRC=\"images/previous_motif.gif\">"; 54 $IMG_PREV_PASSIVE = "<IMG SRC=\"images/previous_motif_gr.gif\">"; 55 $IMG_TOC = "<IMG SRC=\"images/contents_motif.gif\">"; 56 $IMG_LEFT = "images/bg_left.gif"; 57 $IMG_RIGHT = "images/bg_right.gif"; 58 59 $BIBRE = '\[[\w\/]+\]'; # RE for a bibliography reference 56 $DEBUG_L2H = 128; 57 58 59 $BIBRE = '\[[\w\/-]+\]'; # RE for a bibliography reference 60 60 $FILERE = '[\/\w.+-]+'; # RE for a file name 61 61 $VARRE = '[^\s\{\}]+'; # RE for a variable name … … 65 65 66 66 $ERROR = "***"; # prefix for errors and warnings 67 $HOMEPAGE = "http://wwwcn.cern.ch/dci/texi2html/"; # program home page 68 $TODAY = &pretty_date; # like "20 September 1993" 69 $SPLITTAG = "<!-- SPLIT HERE -->\n"; # tag to know where to split 67 # program home page 70 68 $PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections 71 $TOPTAG = "<!--top-->"; # tag to mark first node (end of preamble) 72 $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//EN">'; 73 69 70 $CHAPTEREND = "<!-- End chapter -->\n"; # to know where a chpater ends 71 $SECTIONEND = "<!-- End section -->\n"; # to know where section ends 72 $TOPEND = "<!-- End top -->\n"; # to know where top ends 73 74 74 75 # 75 76 # language dependent constants … … 81 82 #$LDC_GOTO = 'Go to the'; 82 83 #$LDC_FOOT = 'Footnotes'; 83 # 84 #TODO: @def* shortcuts 84 85 85 86 # … … 141 142 '`', 'grave', 142 143 '\'', 'acute', 143 ',', 'cedil',144 # fixme: (not Latin1) = H d dotaccent dotless ringaccent145 # tieaccent u ubaraccent v146 144 ); 147 145 … … 152 150 # cf. makeinfo.c 153 151 "*", "<BR>", # HTML+ 154 " ", " ", # nbsp 152 " ", " ", 153 "\t", " ", 154 "-", "­", # soft hyphen 155 155 "\n", "\n", 156 156 "|", "", 157 'tab', '<\/TD><TD>', 157 158 # spacing commands 158 159 ":", "", … … 160 161 "?", "?", 161 162 ".", ".", 162 "\t", " ", 163 "-", "­", # soft hyphen 164 'tab', '<TD>', 165 '-', '', 163 "-", "", 166 164 ); 167 165 … … 171 169 %things_map = ( 172 170 'TeX', 'TeX', 173 'br', '<P>', # paragraph break . Gone from texinfo 3.9171 'br', '<P>', # paragraph break 174 172 'bullet', '*', 175 'copyright', ' ©',173 'copyright', '(C)', 176 174 'dots', '...', 177 'enddots', '....',178 175 'equiv', '==', 179 176 'error', 'error-->', … … 183 180 'print', '-|', 184 181 'result', '=>', 185 'today', $TODAY, 186 # fixme: output these Latin1 characters as such rather 187 # than as entities? 188 'pounds', '£', 189 'questiondown', '¿', 190 'ss', 'ß', 191 'exclamdown', '¡', 192 'AA', 'Å', 193 'AE', 'Æ', 194 'aa', 'å', 195 'ae', 'æ', 196 'O', 'Ø', 197 'o', 'ø', 198 # follow info rendering: 199 'L', 'L\/', 200 'l', 'l\/', 201 'OE', 'OE', 202 'oe', 'oe', 182 'today', $T2H_TODAY, 183 'aa', 'å', 184 'AA', 'Å', 185 'ae', 'æ', 186 'AE', 'Æ', 187 'o', 'ø', 188 'O', 'Ø', 189 'ss', 'ß', 203 190 ); 204 191 … … 206 193 # texinfo styles (@foo{bar}) to HTML ones 207 194 # 208 %style_l_map = (209 'center', 'CENTER',210 );211 212 195 %style_map = ( 213 'asis', '', # ??196 'asis', '', 214 197 'b', 'B', 215 198 'cite', 'CITE', 216 199 'code', 'CODE', 217 'ctrl', '&do_ctrl', # special case (obsolete)218 'dfn', ' STRONG', # DFN tag is illegal in the standard200 'ctrl', '&do_ctrl', # special case 201 'dfn', 'EM', # DFN tag is illegal in the standard 219 202 'dmn', '', # useless 203 'email', '&do_email', # insert a clickable email address 220 204 'emph', 'EM', 221 'email', '&do_email', # new special case222 205 'file', '"TT', # will put quotes, cf. &apply_style 223 206 'i', 'I', 224 'image', '&do_image', # in-line images225 207 'kbd', 'KBD', 226 'key', 'KBD', # fixme: probably not <KBD>; possibly227 # enclose in angles like makeinfo now does208 'key', 'KBD', 209 'math', '&do_math', 228 210 'r', '', # unsupported 229 211 'samp', '"SAMP', # will put quotes, cf. &apply_style … … 231 213 'strong', 'STRONG', 232 214 't', 'TT', 233 'titlefont', ' B', # make it distinctive, at least234 'uref', '&do_uref', # new special case235 'url', '&do_url', # new special case215 'titlefont', '', # useless 216 'uref', '&do_uref', # insert a clickable URL 217 'url', '&do_url', # insert a clickable URL 236 218 'var', 'VAR', 237 219 'w', '', # unsupported 238 # 'math', 'I', # not very useful, but at least italicize239 'math', '', # don't want italic numbers240 220 ); 241 221 … … 246 226 'display', 'PRE', 247 227 'example', 'PRE', 248 'format', 'PRE', # fixme: shouldn't use tt, but can't avoid?228 'format', 'PRE', 249 229 'lisp', 'PRE', 250 230 'quotation', 'BLOCKQUOTE', … … 304 284 # things to skip 305 285 # 306 %to_ignore = (307 'manual', 1,308 'end manual', 1,309 );310 311 286 %to_skip = ( 312 287 # comments 313 288 'c', 1, 314 289 'comment', 1, 290 'ifnotinfo', 1, 291 'ifnottex', 1, 292 'ifhtml', 1, 293 'end ifhtml', 1, 294 'end ifnotinfo', 1, 295 'end ifnottex', 1, 315 296 # useless 297 'detailmenu', 1, 298 'direntry', 1, 316 299 'contents', 1, 317 300 'shortcontents', 1, … … 322 305 'titlepage', 1, 323 306 'end titlepage', 1, 324 'dircategory', 1,325 307 # unsupported commands (formatting) 326 308 'afourpaper', 1, … … 328 310 'finalout', 1, 329 311 'headings', 1, 312 'sp', 1, 330 313 'need', 1, 331 314 'page', 1, … … 340 323 'vskip', 1, 341 324 'filbreak', 1, 342 'centerchap', 1, 343 'setchapterstyle', 1, 344 'hyphenation', 1, 325 'paragraphindent', 1, 345 326 # unsupported formats 346 327 'cartouche', 1, … … 350 331 ); 351 332 352 %append2num = (353 'A', 1,354 'B', 2,355 'C', 3,356 'D', 4,357 'E', 5,358 'F', 6,359 'G', 7,360 'H', 8,361 'I', 9,362 'J', 10,363 );364 333 #+++############################################################################ 365 334 # # … … 368 337 #---############################################################################ 369 338 339 # 340 # flush stdout and stderr after every write 341 # 342 select(STDERR); 343 $| = 1; 344 select(STDOUT); 345 $| = 1; 346 347 %value = (); # hold texinfo variables, see also -D 348 370 349 $use_bibliography = 1; 371 350 $use_acc = 0; 372 $debug = 0;373 $doctype = '';374 $check = 0;375 $expandinfo = 0;376 $use_glossary = 0;377 $invisible_mark = '';378 $use_iso = 0;379 @include_dirs = ();380 $show_menu = 0;381 $number_sections = 0;382 $split_node = 0;383 $split_chapter = 0;384 $monolithic = 0;385 $verbose = 0;386 $make_entry_page = 1;387 $make_menu_page = 1;388 $section_type = 0;389 $ignore_part = 0;390 351 $usage = <<EOT; 391 352 This is $THISPROG 392 353 To convert a Texinfo file to HMTL: $0 [options] file 393 where options can be: 394 -expandinfo : use \@ifinfo sections, not \@iftex 395 -glossary : handle a glossary 396 -invisible name: use 'name' as an invisible anchor 397 -I dir : search also for files in 'dir' 398 -menu : handle menus and don\'t do the ToC 399 -monolithic : output only one file including ToC 400 -number : number sections 401 -split_chapter : split on main sections 402 -split_node : split on nodes 403 -check : check given file for possible Texinfo commands 404 -usage : print usage instructions 405 -verbose : verbose output 354 where options can be: 355 -expandinfo : use \@ifinfo sections, not \@iftex 356 -glossary : handle a glossary 357 -invisible name : use 'name' as an invisible anchor 358 -Dname : define name like with \@set 359 -I dir : search also for files in 'dir' 360 -index_file file : use 'file' as index file 361 -menu : handle menus 362 -number : number sections 363 -split node|chapter : split on node or chapter 364 -short_ref : cross references without section numbers 365 -l2h : use latex2html for \@math, \@tex, and \@sc 366 -l2h_latex2html prog: use 'prog' as latex2html program 367 (default: 'latex2html') 368 -l2h_tmp dir : use 'dir' as temp dir for latex2html 369 -l2h_clean : remove temporary files generated by l2h extension 370 -l2h_skip : skip latex2html run (needs temporary files) 371 -init_file 'file' : use 'file' for texi2html and latex2html initialization 372 -sidx : index jump label to top of section 373 -usage : print usage instructions 374 -verbose : verbose output 406 375 To check converted files: $0 -check [-verbose] files 407 376 EOT 408 377 409 while ( $#ARGV >= 0&& $ARGV[0] =~ /^-/) {378 while (@ARGV && $ARGV[0] =~ /^-/) { 410 379 $_ = shift(@ARGV); 411 380 if (/^-acc$/) { $use_acc = 1; next; } 412 if (/^-d(ebug)?(\d+)?$/) { $debug = $2 || shift(@ARGV); next; } 413 if (/^-doctype$/) { $doctype = shift(@ARGV); next; } 414 if (/^-c(heck)?$/) { $check = 1; next; } 415 if (/^-e(xpandinfo)?$/) { $expandinfo = 1; next; } 416 if (/^-g(lossary)?$/) { $use_glossary = 1; next; } 417 if (/^-i(nvisible)?$/) { $invisible_mark = shift(@ARGV); next; } 418 if (/^-iso$/) { $use_iso = 1; next; } 419 if (/^-I(.+)?$/) { push(@include_dirs, $1 || shift(@ARGV)); next; } 420 if (/^-m(enu)?$/) { $show_menu = 1; next; } 421 if (/^-mono(lithic)?$/) { $monolithic = 1; next; } 422 if (/^-n(umber)?$/) { $number_sections = 1; next; } 423 if (/^-s(plit)?_?(n(ode)?|c(hapter)?)?$/) { 424 if ($2 =~ /^n/) { 425 $split_node = 1; 426 } else { 427 $split_chapter = 1; 428 } 429 next; 430 } 431 if (/^-v(erbose)?$/) { $verbose = 1; next; } 432 die $usage; 433 } 434 if ($check) { 435 die $usage unless @ARGV > 0; 381 if (/^-D(.+)?$/) { $value{$1 || shift(@ARGV)} = 1; next; } 382 if (/^-d(ebug)?(\d+)?$/) { $T2H_DEBUG = $2 || shift(@ARGV); next; } 383 if (/^-doctype$/) { $T2H_DOCTYPE = shift(@ARGV); next; } 384 if (/^-c(heck)?$/) { $T2H_CHECK = 1; next; } 385 if (/^-e(xpand)?$/) { $T2H_EXPAND = shift(@ARGV); next; } 386 if (/^-g(lossary)?$/) { $T2H_USE_GLOSSARY = 1; next; } 387 if (/^-i(nvisible)?$/) { $T2H_INVISIBLE_MARK = shift(@ARGV); next; } 388 if (/^-I(.+)?$/) { push(@T2H_INCLUDE_DIRS, $1 || shift(@ARGV)); next; } 389 if (/^-iso$/) { $T2H_USE_ISO = 1; next; } 390 if (/^-init_file$/) 391 { 392 $init_file = shift(@ARGV); 393 if (-f $init_file) 394 { 395 print "# reading initialization file from $init_file\n" 396 if ($T2H_VERBOSE); 397 require($init_file); 398 } 399 else 400 { 401 print "$ERROR Error: can't read init file $int_file\n"; 402 $init_file = ''; 403 } 404 next; 405 } 406 if (/^-l2h$/) { $T2H_L2H = 1; next; } 407 if (/^-l2h_l2h$/) { $T2H_L2H_L2H = shift(@ARGV); next; } 408 if (/^-l2h_skip$/) { $T2H_L2H_SKIP= 1; next; } 409 if (/^-l2h_tmp$/) { $T2H_L2H_TMP = shift(@ARGV); next; } 410 if (/^-l2h_clean$/) { $T2H_L2H_CLEAN= 1; next; } 411 if (/^-m(enu)?$/) { $T2H_SHOW_MENU = 1; next; } 412 if (/^-nu(mber)?$/) { $T2H_NUMBER_SECTIONS = 1; next; } 413 if (/^-o(ut_file)?$/) { $T2H_OUT = shift (@ARGV); 414 undef $T2H_SPLIT; next;} 415 if (/^-p(refix)?$/) { $T2H_PREFIX = shift(@ARGV); next; } 416 if (/^-su(bdir)?$/) { $T2H_SUBDIR = shift(@ARGV); next; } 417 if (/^-short_e(xtn)?$/) { $T2H_SHORTEXTN = 1; next; } 418 if (/^-short_r(ef)?$/) { $T2H_SHORT_REF = 1; next; } 419 if (/^-si(dx)?$/) { $T2H_SECTION_IDX = 1; next; } 420 if (/^-s(plit)?$/) { $T2H_SPLIT = shift(@ARGV); next;} 421 if (/^-t(op_file)?$/) { $T2H_TOP_FILE = shift (@ARGV); next;} 422 if (/^-v(erbose)?$/) { $T2H_VERBOSE = 1; next; } 423 if (/^-no_v(erbose)?$/) { $T2H_VERBOSE = 0; next; } 424 if (/^-vers(ion)?$/) { print "$THISPROGRAM\n"; exit;} 425 die "Unknown option: $_\n$usage"; 426 } 427 if ($T2H_CHECK) { 428 die "Need file to check\n$usage" unless @ARGV > 0; 436 429 ✓ 437 430 exit; 438 431 } 439 432 440 if (($split_node || $split_chapter) && $monolithic) { 441 warn "Can't use -monolithic with -split, -monolithic ignored.\n"; 442 $monolithic = 0; 443 } 444 if ($expandinfo) { 445 $to_skip{'ifinfo'}++; 446 $to_skip{'end ifinfo'}++; 447 } else { 448 $to_skip{'iftex'}++; 449 $to_skip{'end iftex'}++; 450 } 451 $invisible_mark = '<IMG SRC="images/invisible.xbm" ALT="">' if $invisible_mark eq 'xbm'; 452 die $usage unless @ARGV == 1; 433 if ($T2H_EXPAND eq 'info') 434 { 435 $to_skip{'ifinfo'} = 1; 436 $to_skip{'end ifinfo'} = 1; 437 } 438 elsif ($T2H_EXPAND eq 'tex') 439 { 440 $to_skip{'iftex'} = 1; 441 $to_skip{'end iftex'} = 1; 442 443 } 444 445 $T2H_INVISIBLE_MARK = '<IMG SRC="invisible.xbm">' if $T2H_INVISIBLE_MARK eq 'xbm'; 446 447 # 448 # file name buisness 449 # 450 die "Need exactly one file to translate\n$usage" unless @ARGV == 1; 453 451 $docu = shift(@ARGV); 454 452 if ($docu =~ /.*\//) { … … 459 457 $docu_name = $docu; 460 458 } 461 unshift(@ include_dirs, $docu_dir);459 unshift(@T2H_INCLUDE_DIRS, $docu_dir); 462 460 $docu_name =~ s/\.te?x(i|info)?$//; # basename of the document 463 464 $docu_doc = "$docu_name.html"; # document's contents 465 if ($monolithic) { 466 $docu_toc = $docu_foot = $docu_doc; 467 } else { 468 $docu_toc = "${docu_name}_toc.html"; # document's table of contents 469 $docu_foot = "${docu_name}_foot.html"; # document's footnotes 470 $docu_left = "${docu_name}_left.html"; 471 $docu_main = "index.html"; 472 } 461 $docu_name = $T2H_PREFIX if ($T2H_PREFIX); 462 463 # subdir 464 if ($T2H_SUBDIR && ! $T2H_OUT) 465 { 466 $T2H_SUBDIR =~ s|/*$||; 467 unless (-d "$T2H_SUBDIR" && -w "$T2H_SUBDIR") 468 { 469 if ( mkdir($T2H_SUBDIR, oct(755))) 470 { 471 print "# created directory $T2H_SUBDIR\n" if ($T2H_VERBOSE); 472 } 473 else 474 { 475 warn "$ERROR can't create directory $T2H_SUBDIR. Put results into current directory\n"; 476 $T2H_SUBDIR = ''; 477 } 478 } 479 } 480 481 if ($T2H_SUBDIR && ! $T2H_OUT) 482 { 483 $docu_rdir = "$T2H_SUBDIR/"; 484 print "# putting result files into directory $docu_rdir\n" if ($T2H_VERBOSE); 485 } 486 else 487 { 488 if ($T2H_OUT && $T2H_OUT =~ m|(.*)/|) 489 { 490 $docu_rdir = "$1/"; 491 print "# putting result files into directory $docu_rdir\n" if ($T2H_VERBOSE); 492 } 493 else 494 { 495 print "# putting result files into current directory \n" if ($T2H_VERBOSE); 496 $docu_rdir = ''; 497 } 498 } 499 500 # extension 501 if ($T2H_SHORTEXTN) 502 { 503 $docu_ext = "htm"; 504 } 505 else 506 { 507 $docu_ext = "html"; 508 } 509 if ($T2H_TOP_FILE =~ /\..*$/) 510 { 511 $T2H_TOP_FILE = $`.".$docu_ext"; 512 } 513 else 514 { 515 $T2H_TOP_FILE .= ".$docu_ext"; 516 } 517 518 # result files 519 if (! $T2H_OUT && ($T2H_SPLIT =~ /section/i || $T2H_SPLIT =~ /node/i)) 520 { 521 $T2H_SPLIT = 'section'; 522 } 523 elsif (! $T2H_OUT && $T2H_SPLIT =~ /chapter/i) 524 { 525 $T2H_SPLIT = 'chapter' 526 } 527 else 528 { 529 undef $T2H_SPLIT; 530 } 531 532 $docu_doc = "$docu_name.$docu_ext"; # document's contents 533 $docu_doc_file = "$docu_rdir$docu_doc"; 534 if ($T2H_SPLIT) 535 { 536 $docu_toc = "${docu_name}_toc.$docu_ext"; # document's table of contents 537 $docu_stoc = "${docu_name}_ovr.$docu_ext"; # document's short toc 538 $docu_foot = "${docu_name}_fot.$docu_ext"; # document's footnotes 539 $docu_about = "${docu_name}_abt.$docu_ext"; # about this document 540 $docu_top = $T2H_TOP_FILE; 541 } 542 else 543 { 544 if ($T2H_OUT) 545 { 546 $docu_doc = $T2H_OUT; 547 $docu_doc =~ s|.*/||; 548 } 549 $docu_toc = $docu_foot = $docu_stoc = $docu_about = $docu_top = $docu_doc; 550 } 551 552 $docu_toc_file = "$docu_rdir$docu_toc"; 553 $docu_stoc_file = "$docu_rdir$docu_stoc"; 554 $docu_foot_file = "$docu_rdir$docu_foot"; 555 $docu_about_file = "$docu_rdir$docu_about"; 556 $docu_top_file = "$docu_rdir$docu_top"; 473 557 474 558 # 475 559 # variables 476 560 # 477 %value = (); # hold texinfo variables478 561 $value{'html'} = 1; # predefine html (the output format) 479 $value{'texi2html'} = '1.51a';# predefine texi2html (the translator)562 $value{'texi2html'} = $THISVERSION; # predefine texi2html (the translator) 480 563 # _foo: internal to track @foo 481 564 foreach ('_author', '_title', '_subtitle', … … 484 567 } 485 568 %node2sec = (); # node to section name 569 %sec2node = (); # section to node name 486 570 %node2href = (); # node to HREF 571 %node2next = (); # node to next 572 %node2prev = (); # node to prev 573 %node2up = (); # node to up 487 574 %bib2href = (); # bibliography reference to HREF 488 575 %gloss2href = (); # glossary term to HREF 489 576 @sections = (); # list of sections 490 @left_index = ();491 577 %tag2pro = (); # protected sections 492 578 … … 505 591 # can I use ISO8879 characters? (HTML+) 506 592 # 507 if ($ use_iso) {593 if ($T2H_USE_ISO) { 508 594 $things_map{'bullet'} = "•"; 509 595 $things_map{'copyright'} = "©"; … … 520 606 $extensions = 'texi2html.ext'; # extensions in working directory 521 607 if (-f $extensions) { 522 print "# reading extensions from $extensions\n" if $ verbose;608 print "# reading extensions from $extensions\n" if $T2H_VERBOSE; 523 609 require($extensions); 524 610 } … … 527 613 $extensions = "${progdir}texi2html.ext"; # extensions in texi2html directory 528 614 if (-f $extensions) { 529 print "# reading extensions from $extensions\n" if $ verbose;615 print "# reading extensions from $extensions\n" if $T2H_VERBOSE; 530 616 require($extensions); 531 617 } 532 618 } 533 619 534 print "# reading from $docu\n" if $verbose; 620 621 print "# reading from $docu\n" if $T2H_VERBOSE; 622 623 ######################################################################### 624 # 625 # latex2html stuff 626 # 627 # latex2html conversions consist of three stages: 628 # 1) ToLatex: Put "latex" code into a latex file 629 # 2) ToHtml: Use latex2html to generate corresponding html code and images 630 # 3) FromHtml: Extract generated code and images from latex2html run 631 # 632 633 ########################## 634 # default settings 635 # 636 637 # defaults for files and names 638 639 sub l2h_Init 640 { 641 local($root) = @_; 642 643 return 0 unless ($root); 644 645 $l2h_name = "${root}_l2h"; 646 647 $l2h_latex_file = "$docu_rdir${l2h_name}.tex"; 648 $l2h_cache_file = "${docu_rdir}l2h_cache.pm"; 649 $T2H_L2H_L2H = "latex2html" unless ($T2H_L2H_L2H); 650 651 # destination dir -- generated images are put there, should be the same 652 # as dir of enclosing html document -- 653 $l2h_html_file = "$docu_rdir${l2h_name}.html"; 654 $l2h_prefix = "${l2h_name}_"; 655 return 1; 656 } 657 658 659 ########################## 660 # 661 # First stage: Generation of Latex file 662 # Initialize with: l2h_InitToLatex 663 # Add content with: l2h_ToLatex($text) --> HTML placeholder comment 664 # Finish with: l2h_FinishToLatex 665 # 666 667 $l2h_latex_preample = <<EOT; 668 % This document was automatically generated by the l2h extenstion of texi2html 669 % DO NOT EDIT !!! 670 \\documentclass{article} 671 \\usepackage{html} 672 \\begin{document} 673 EOT 674 675 $l2h_latex_closing = <<EOT; 676 \\end{document} 677 EOT 678 679 # return used latex 1, if l2h could be initalized properly, 0 otherwise 680 sub l2h_InitToLatex 681 { 682 %l2h_to_latex = (); 683 unless ($T2H_L2H_SKIP) 684 { 685 unless (open(L2H_LATEX, ">$l2h_latex_file")) 686 { 687 warn "$ERROR Error l2h: Can't open latex file '$latex_file' for writing\n"; 688 return 0; 689 } 690 print "# l2h: use ${l2h_latex_file} as latex file\n" if ($T2H_VERBOSE); 691 print L2H_LATEX $l2h_latex_preample; 692 } 693 # open database for caching 694 l2h_InitCache(); 695 $l2h_latex_count = 0; 696 $l2h_to_latex_count = 0; 697 $l2h_cached_count = 0; 698 return 1; 699 } 700 701 # print text (1st arg) into latex file (if not already there), return 702 # HTML commentary which can be later on replaced by the latex2html 703 # generated text 704 sub l2h_ToLatex 705 { 706 my($text) = @_; 707 my($count); 708 709 $l2h_to_latex_count++; 710 $text =~ s/(\s*)$//; 711 712 # try whether we can cache it 713 my $cached_text = l2h_FromCache($text); 714 if ($cached_text) 715 { 716 $l2h_cached_count++; 717 return $cached_text; 718 } 719 720 # try whether we have text already on things to do 721 unless ($count = $l2h_to_latex{$text}) 722 { 723 $count = $l2h_latex_count; 724 $l2h_latex_count++; 725 $l2h_to_latex{$text} = $count; 726 $l2h_to_latex[$count] = $text; 727 unless ($T2H_L2H_SKIP) 728 { 729 print L2H_LATEX "\\begin{rawhtml}\n"; 730 print L2H_LATEX "<!-- l2h_begin ${l2h_name} ${count} -->\n"; 731 print L2H_LATEX "\\end{rawhtml}\n"; 732 733 print L2H_LATEX "$text\n"; 734 735 print L2H_LATEX "\\begin{rawhtml}\n"; 736 print L2H_LATEX "<!-- l2h_end ${l2h_name} ${count} -->\n"; 737 print L2H_LATEX "\\end{rawhtml}\n"; 738 } 739 } 740 return "<!-- l2h_replace ${l2h_name} ${count} -->"; 741 } 742 743 # print closing into latex file and close it 744 sub l2h_FinishToLatex 745 { 746 local ($reused); 747 748 $reused = $l2h_to_latex_count - $l2h_latex_count - $l2h_cached_count; 749 unless ($T2H_L2H_SKIP) 750 { 751 print L2H_LATEX $l2h_latex_closing; 752 close(L2H_LATEX); 753 } 754 print "# l2h: finished to latex ($l2h_cached_count cached, $reused reused, $l2h_latex_count contents)\n" if ($T2H_VERBOSE); 755 unless ($l2h_latex_count) 756 { 757 l2h_Finish(); 758 return 0; 759 } 760 return 1; 761 } 762 763 ################################### 764 # Second stage: Use latex2html to generate corresponding html code and images 765 # 766 # l2h_ToHtml([$l2h_latex_file, [$l2h_html_dir]]): 767 # Call latex2html on $l2h_latex_file 768 # Put images (prefixed with $l2h_name."_") and html file(s) in $l2h_html_dir 769 # Return 1, on success 770 # 0, otherwise 771 # 772 sub l2h_ToHtml 773 { 774 local($call, $ext, $root, $dotbug); 775 776 if ($T2H_L2H_SKIP) 777 { 778 print "# l2h: skipping latex2html run\n" if ($T2H_VERBOSE); 779 return 1; 780 } 781 782 # Check for dot in directory where dvips will work 783 if ($T2H_L2H_TMP) 784 { 785 if ($T2H_L2H_TMP =~ /\./) 786 { 787 warn "$ERROR Warning l2h: l2h_tmp dir contains a dot. Use /tmp, instead\n"; 788 $dotbug = 1; 789 } 790 } 791 else 792 { 793 if (&getcwd =~ /\./) 794 { 795 warn "$ERROR Warning l2h: current dir contains a dot. Use /tmp as l2h_tmp dir \n"; 796 $dotbug = 1; 797 } 798 } 799 # fix it, if necessary and hope that it works 800 $T2H_L2H_TMP = "/tmp" if ($dotbug); 801 802 $call = $T2H_L2H_L2H; 803 # use init file, if specified 804 $call = $call . " -init_file " . $init_file if ($init_file && -f $init_file); 805 # set output dir 806 $call .= ($docu_rdir ? " -dir $docu_rdir" : " -no_subdir"); 807 # use l2h_tmp, if specified 808 $call = $call . " -tmp $T2H_L2H_TMP" if ($T2H_L2H_TMP); 809 # options we want to be sure of 810 $call = $call ." -address 0 -info 0 -split 0 -no_navigation -no_auto_link"; 811 $call = $call ." -prefix ${l2h_prefix} $l2h_latex_file"; 812 813 print "# l2h: executing '$call'\n" if ($T2H_VERBOSE); 814 if (system($call)) 815 { 816 warn "l2h ***Error: '${call}' did not succeed\n"; 817 return 0; 818 } 819 else 820 { 821 print "# l2h: latex2html finished successfully\n" if ($T2H_VERBOSE); 822 return 1; 823 } 824 } 825 826 # this is directly pasted over from latex2html 827 sub getcwd { 828 local($_) = `pwd`; 829 830 die "'pwd' failed (out of memory?)\n" 831 unless length; 832 chop; 833 $_; 834 } 835 836 837 ########################## 838 # Third stage: Extract generated contents from latex2html run 839 # Initialize with: l2h_InitFromHtml 840 # open $l2h_html_file for reading 841 # reads in contents into array indexed by numbers 842 # return 1, on success -- 0, otherwise 843 # Extract Html code with: l2h_FromHtml($text) 844 # replaces in $text all previosuly inserted comments by generated html code 845 # returns (possibly changed) $text 846 # Finish with: l2h_FinishFromHtml 847 # closes $l2h_html_dir/$l2h_name.".$docu_ext" 848 849 sub l2h_InitFromHtml 850 { 851 local($h_line, $h_content, $count, %l2h_img); 852 853 if (! open(L2H_HTML, "<${l2h_html_file}")) 854 { 855 print "$ERROR Error l2h: Can't open ${l2h_html_file} for reading\n"; 856 return 0; 857 } 858 print "# l2h: use ${l2h_html_file} as html file\n" if ($T2H_VERBOSE); 859 860 $l2h_html_count = 0; 861 862 while ($h_line = <L2H_HTML>) 863 { 864 if ($h_line =~ /^<!-- l2h_begin $l2h_name ([0-9]+) -->/) 865 { 866 $count = $1; 867 $h_content = ""; 868 while ($h_line = <L2H_HTML>) 869 { 870 if ($h_line =~ /^<!-- l2h_end $l2h_name $count -->/) 871 { 872 chomp $h_content; 873 chomp $h_content; 874 $l2h_html_count++; 875 $h_content = l2h_ToCache($count, $h_content); 876 $l2h_from_html[$count] = $h_content; 877 $h_content = ''; 878 last; 879 } 880 $h_content = $h_content.$h_line; 881 } 882 if ($hcontent) 883 { 884 print "$ERROR Warning l2h: l2h_end $l2h_name $count not found\n" 885 if ($T2H_VERBOSE); 886 close(L2H_HTML); 887 return 0; 888 } 889 } 890 } 891 print "# l2h: Got $l2h_html_count of $l2h_latex_count html contents\n" 892 if ($T2H_VERBOSE); 893 894 close(L2H_HTML); 895 return 1; 896 } 897 898 sub l2h_FromHtml 899 { 900 local($text) = @_; 901 local($done, $to_do, $count); 902 903 $to_do = $text; 904 905 while ($to_do =~ /([^\000]*)<!-- l2h_replace $l2h_name ([0-9]+) -->([^\000]*)/) 906 { 907 $to_do = $1; 908 $count = $2; 909 $done = $3.$done; 910 911 $done = "<!-- l2h_end $l2h_name $count -->".$done 912 if ($T2H_DEBUG & $DEBUG_L2H); 913 914 $done = &l2h_ExtractFromHtml($count) . $done; 915 916 $done = "<!-- l2h_begin $l2h_name $count -->".$done 917 if ($T2H_DEBUG & $DEBUG_L2H); 918 } 919 return $to_do.$done; 920 } 921 922 923 sub l2h_ExtractFromHtml 924 { 925 local($count) = @_; 926 927 return $l2h_from_html[$count] if ($l2h_from_html[$count]); 928 929 if ($count >= 0 && $count < $l2h_latex_count) 930 { 931 # now we are in trouble 932 local($l_l2h, $_); 933 934 $l2h_extract_error++; 935 print "$ERROR l2h: can't extract content $count from html\n" 936 if ($T2H_VERBOSE); 937 # try simple (ordinary) substition (without l2h) 938 $l_l2h = $T2H_L2H; 939 $T2H_L2H = 0; 940 $_ = $l2h_to_latex{$count}; 941 $_ = &substitute_style($_); 942 &unprotect_texi; 943 $_ = "<!-- l2h: ". __LINE__ . " use texi2html -->" . $_ 944 if ($T2H_DEBUG & $DEBUG_L2H); 945 $T2H_L2H = $l_l2h; 946 return $_; 947 } 948 else 949 { 950 # now we have been incorrectly called 951 $l2h_range_error++; 952 print "$ERROR l2h: Request of $count content which is out of valide range [0,$l2h_latex_count)\n"; 953 return "<!-- l2h: ". __LINE__ . " out of range count $count -->" 954 if ($T2H_DEBUG & $DEBUG_L2H); 955 return "<!-- l2h: out of range count $count -->"; 956 } 957 } 958 959 sub l2h_FinishFromHtml 960 { 961 if ($T2H_VERBOSE) 962 { 963 if ($l2h_extract_error + $l2h_range_error) 964 { 965 print "# l2h: finished from html ($l2h_extract_error extract and $l2h_range_error errors)\n"; 966 } 967 else 968 { 969 print "# l2h: finished from html (no errors)\n"; 970 } 971 } 972 } 973 974 sub l2h_Finish 975 { 976 l2h_StoreCache(); 977 if ($T2H_L2H_CLEAN) 978 { 979 print "# l2h: removing temporary files generated by l2h extension\n" 980 if $T2H_VERBOSE; 981 while (<"$docu_rdir$l2h_name"*>) 982 { 983 unlink $_; 984 } 985 } 986 print "# l2h: Finished\n" if $T2H_VERBOSE; 987 return 1; 988 } 989 990 ############################## 991 # stuff for l2h caching 992 # 993 994 # I tried doing this with a dbm data base, but it did not store all 995 # keys/values. Hence, I did as latex2html does it 996 sub l2h_InitCache 997 { 998 if (-r "$l2h_cache_file") 999 { 1000 my $rdo = do "$l2h_cache_file"; 1001 warn("$ERROR l2h Error: could not load $docu_rdir$l2h_cache_file: $@\n") 1002 unless ($rdo); 1003 } 1004 } 1005 1006 sub l2h_StoreCache 1007 { 1008 return unless $l2h_latex_count; 1009 1010 my ($key, $value); 1011 open(FH, ">$l2h_cache_file") || return warn"$ERROR l2h Error: could not open $docu_rdir$l2h_cache_file for writing: $!\n"; 1012 1013 1014 while (($key, $value) = each %l2h_cache) 1015 { 1016 # escape stuff 1017 $key =~ s|/|\\/|g; 1018 $key =~ s|\\\\/|\\/|g; 1019 # weird, a \ at the end of the key results in an error 1020 # maybe this also broke the dbm database stuff 1021 $key =~ s|\\$|\\\\|; 1022 $value =~ s/\|/\\\|/g; 1023 $value =~ s/\\\\\|/\\\|/g; 1024 $value =~ s|\\\\|\\\\\\\\|g; 1025 print FH "\n\$l2h_cache_key = q/$key/;\n"; 1026 print FH "\$l2h_cache{\$l2h_cache_key} = q|$value|;\n"; 1027 } 1028 print FH "1;"; 1029 close(FH); 1030 } 1031 1032 # return cached html, if it exists for text, and if all pictures 1033 # are there, as well 1034 sub l2h_FromCache 1035 { 1036 my $text = shift; 1037 my $cached = $l2h_cache{$text}; 1038 if ($cached) 1039 { 1040 while ($cached =~ m/SRC="(.*?)"/g) 1041 { 1042 unless (-e "$docu_rdir$1") 1043 { 1044 return undef; 1045 } 1046 } 1047 return $cached; 1048 } 1049 return undef; 1050 } 1051 1052 # insert generated html into cache, move away images, 1053 # return transformed html 1054 $maximage = 1; 1055 sub l2h_ToCache 1056 { 1057 my $count = shift; 1058 my $content = shift; 1059 my @images = ($content =~ /SRC="(.*?)"/g); 1060 my ($src, $dest); 1061 1062 for $src (@images) 1063 { 1064 $dest = $l2h_img{$src}; 1065 unless ($dest) 1066 { 1067 my $ext; 1068 if ($src =~ /.*\.(.*)$/ && $1 ne $docu_ext) 1069 { 1070 $ext = $1; 1071 } 1072 else 1073 { 1074 warn "$ERROR: L2h image $src has invalid extension\n"; 1075 next; 1076 } 1077 while (-e "$docu_rdir${docu_name}_$maximage.$ext") { $maximage++;} 1078 $dest = "${docu_name}_$maximage.$ext"; 1079 system("cp -f $docu_rdir$src $docu_rdir$dest"); 1080 $l2h_img{$src} = $dest; 1081 unlink "$docu_rdir$src" unless ($DEBUG & DEBUG_L2H); 1082 } 1083 $content =~ s/$src/$dest/g; 1084 } 1085 $l2h_cache{$l2h_to_latex[$count]} = $content; 1086 return $content; 1087 } 1088 535 1089 536 1090 #+++############################################################################ … … 542 1096 @lines = (); # whole document 543 1097 @toc_lines = (); # table of contents 544 @top_lines = (); # contents of top node 545 @menu_lines = (); 546 $toplevel = 0; # top level seen in hierarchy 1098 @stoc_lines = (); # table of contents 547 1099 $curlevel = 0; # current level in TOC 548 1100 $node = ''; # current node name 1101 $node_next = ''; # current node next name 1102 $node_prev = ''; # current node prev name 1103 $node_up = ''; # current node up name 549 1104 $in_table = 0; # am I inside a table 550 $table_type = ''; # type of table ('', 'f', 'v' )1105 $table_type = ''; # type of table ('', 'f', 'v', 'multi') 551 1106 @tables = (); # nested table support 552 1107 $in_bibliography = 0; # am I inside a bibliography 553 1108 $in_glossary = 0; # am I inside a glossary 554 1109 $in_top = 0; # am I inside the top node 1110 $has_top = 0; # did I see a top node? 555 1111 $in_pre = 0; # am I inside a preformatted section 556 1112 $in_list = 0; # am I inside a list 557 $in_html = 0; # am I inside an HTML section (@ifhtml) 558 $in_raw_html = 0; # am I inside an HTML section (@html) 559 $in_preamble = 1; # am I before the top node 1113 $in_html = 0; # am I inside an HTML section 560 1114 $first_line = 1; # is it the first line 561 1115 $dont_html = 0; # don't protect HTML on this line 562 $split_num = 0; # split index563 1116 $deferred_ref = ''; # deferred reference for indexes 564 1117 @html_stack = (); # HTML elements stack 565 1118 $html_element = ''; # current HTML element 566 1119 &html_reset; 567 @raw_html = (); 1120 1121 # init l2h 1122 $T2H_L2H = &l2h_Init($docu_name) if ($T2H_L2H); 1123 $T2H_L2H = &l2h_InitToLatex if ($T2H_L2H); 568 1124 569 1125 # build code for simple substitutions … … 607 1163 $tag = ''; 608 1164 $end_tag = ''; 609 if (/^\ @end\s+(\w+)\b/) {1165 if (/^\s*\@end\s+(\w+)\b/) { 610 1166 $end_tag = $1; 611 } elsif (/^\ @(\w+)\b/) {1167 } elsif (/^\s*\@(\w+)\b/) { 612 1168 $tag = $1; 613 1169 } 614 1170 # 615 # handle @ ifhtml / @end ifhtml1171 # handle @html / @end html 616 1172 # 617 1173 if ($in_html) { 618 if ($end_tag eq ' ifhtml') {1174 if ($end_tag eq 'html') { 619 1175 $in_html = 0; 620 1176 } else { … … 622 1178 } 623 1179 next; 624 } elsif ($tag eq ' ifhtml') {1180 } elsif ($tag eq 'html') { 625 1181 $in_html = $PROTECTTAG . ++$html_num; 626 push(@ raw_html, $in_html);1182 push(@lines, $in_html); 627 1183 next; 628 }629 #630 # do raw HTML (no escapes)631 #632 if ($in_raw_html) {633 if ($end_tag eq 'html') {634 $in_raw_html = 0;635 } else {636 push (@raw_html, $_);637 }638 next;639 } elsif ($tag eq 'html') {640 $in_raw_html = 1;641 1184 } 642 1185 # … … 649 1192 last if $tag eq 'bye'; 650 1193 } 651 652 if ($end_tag) { 653 if ($to_ignore{"end $end_tag"}) { 654 $ignore_part = 0; 655 next; 656 } 657 } elsif ($tag) { 658 if ($to_ignore{$tag}) { 659 $ignore_part = 1; 660 } 661 } 662 next if $ignore_part; 663 1194 if ($in_top) { 1195 # parsing the top node 1196 if ($tag eq 'node' || $tag eq 'include' || $sec2level{$tag}) { 1197 # no more in top 1198 $in_top = 0; 1199 push(@lines, $TOPEND); 1200 } 1201 } 664 1202 # 665 1203 # try to remove inlined comments 666 1204 # syntax from tex-mode.el comment-start-skip 667 1205 # 668 s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/; 1206 s/((^|[^\@])(\@\@)*)\@c(omment | |\{).*/$1/; 1207 # s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/; 1208 # s/(.*)\@c{.*?}(.*)/$1$2/; 1209 # s/(.*)\@comment{.*?}(.*)/$1$2/; 1210 # s/^(.*)\@c /$1/; 1211 # s/^(.*)\@comment /$1/; 669 1212 # non-@ substitutions cf. texinfmt.el 670 s/``/\"/g; 671 s/''/\"/g; 672 s/([\w ])---([\w ])/$1--$2/g; 1213 unless ($in_pre) { 1214 s/``/\"/g; 1215 s/''/\"/g; 1216 s/([\w ])---([\w ])/$1--$2/g; 1217 } 673 1218 # 674 1219 # analyze the tag … … 677 1222 # skip lines 678 1223 &skip_until($tag), next if $tag eq 'ignore'; 679 if ($expandinfo) { 680 &skip_until($tag), next if $tag eq 'iftex'; 681 } else { 682 &skip_until($tag), next if $tag eq 'ifinfo' && 683 ! $in_preamble; # we want the contents of the top node 684 } 685 &skip_until($tag), next if $tag eq 'tex'; 1224 &skip_until($tag), next if $tag eq 'ifnothtml'; 1225 if ($tag eq 'ifinfo') 1226 { 1227 &skip_until($tag), next unless $T2H_EXPAND eq 'info'; 1228 } 1229 if ($tag eq 'iftex') 1230 { 1231 &skip_until($tag), next unless $T2H_EXPAND eq 'tex'; 1232 } 1233 if ($tag eq 'tex') 1234 { 1235 # add to latex2html file 1236 if ($T2H_EXPAND eq 'tex' && $T2H_L2H && ! $in_pre) 1237 { 1238 # add space to the end -- tex(i2dvi) does this, as well 1239 push(@lines, &l2h_ToLatex(&string_until($tag) . " ")); 1240 } 1241 else 1242 { 1243 &skip_until($tag); 1244 } 1245 next; 1246 } 686 1247 # handle special tables 687 if ($tag eq 'table') { 688 $table_type = ''; 689 } elsif ($tag eq 'ftable') { 1248 if ($tag =~ /^(|f|v|multi)table$/) { 1249 $table_type = $1; 690 1250 $tag = 'table'; 691 $table_type = 'f';692 } elsif ($tag eq 'vtable') {693 $tag = 'table';694 $table_type = 'v';695 } elsif ($tag eq 'multitable') {696 $tag = 'table';697 $table_type = '';698 1251 } 699 1252 # special cases 700 if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+Top\s*,/i)) { 701 # We want to stash the contents of the top node (including 702 # @ifinfo bits). 1253 if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+top\s*,/i)) { 703 1254 $in_top = 1; 704 $in_preamble = 0; 705 #@lines = (); # ignore all lines before top (title page garbage) 706 @lines = @raw_html; 1255 $has_top = 1; 1256 @lines = (); # ignore all lines before top (title page garbage) 707 1257 next; 708 1258 } elsif ($tag eq 'node') { 709 push (@lines, "$TOPTAG") if ($in_top); # Mark end of top node 1259 if ($in_top) 1260 { 710 1261 $in_top = 0; 711 $in_preamble = 0; 712 warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o; 713 $_ = &protect_html($_); # if node contains '&' for instance 714 s/^\@node\s+//; 715 ($node) = split(/,/); 716 &normalise_node($node); 717 if ($split_node) { 718 &next_doc; 719 push(@lines, $SPLITTAG) if $split_num++; 720 push(@sections, $node); 721 } 722 next; 1262 push(@lines, $TOPEND); 1263 } 1264 warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o; 1265 $_ = &protect_html($_); # if node contains '&' for instance 1266 s/^\@node\s+//; 1267 ($node, $node_next, $node_prev, $node_up) = split(/,/); 1268 &normalise_node($node); 1269 &normalise_node($node_next); 1270 &normalise_node($node_prev); 1271 &normalise_node($node_up); 1272 next; 723 1273 } elsif ($tag eq 'include') { 724 1274 if (/^\@include\s+($FILERE)\s*$/o) { 725 1275 $file = $1; 726 1276 unless (-e $file) { 727 foreach $dir (@ include_dirs) {1277 foreach $dir (@T2H_INCLUDE_DIRS) { 728 1278 $file = "$dir/$1"; 729 1279 last if -e $file; … … 732 1282 if (-e $file) { 733 1283 &open($file); 734 print "# including $file\n" if $ verbose;1284 print "# including $file\n" if $T2H_VERBOSE; 735 1285 } else { 736 1286 warn "$ERROR Can't find $file, skipping"; … … 757 1307 next; 758 1308 } elsif ($tag eq 'menu') { 759 unless ($ show_menu) {1309 unless ($T2H_SHOW_MENU) { 760 1310 &skip_until($tag); 761 1311 next; … … 768 1318 push(@lines, &html_debug("\n", __LINE__)); 769 1319 $in_list++ if $format_map{$tag} eq 'UL' || $format_map{$tag} eq 'OL' ; 1320 push(@lines, &debug('<FONT size="-1">'."\n", __LINE__)) 1321 if $tag =~ /smallexample/i; 1322 push(@lines, &debug("<BLOCKQUOTE>\n", __LINE__)) 1323 if $tag =~ /example/i; 770 1324 push(@lines, &debug("<$format_map{$tag}>\n", __LINE__)); 771 1325 next; 772 1326 } elsif ($tag eq 'table') { 773 if (/^\ @[fv]?table\s+\@(\w+)\s*$/) {774 $in_table = $ 1;1327 if (/^\s*\@(|f|v|multi)table\s+\@(\w+)/) { 1328 $in_table = $2; 775 1329 unshift(@tables, join($;, $table_type, $in_table)); 776 push(@lines, &debug("<DL COMPACT>\n", __LINE__)); 777 &html_push_if('DL'); 778 push(@lines, &html_debug("\n", __LINE__)); 779 } elsif (/^\@multitable\s+/) { 780 # Note descent to HTML 3.2 necessary for multitable. 781 $in_table = ' '; 782 unshift(@tables, join($;, $table_type, $in_table)); 783 push(@lines, &debug("<TABLE>\n", __LINE__)); 784 &html_push_if('TABLE'); 1330 if ($table_type eq "multi") { 1331 # don't use borders -- gets confused by empty cells 1332 push(@lines, &debug("<TABLE>\n", __LINE__)); 1333 &html_push_if('TABLE'); 1334 } else { 1335 push(@lines, &debug("<DL COMPACT>\n", __LINE__)); 1336 &html_push_if('DL'); 1337 } 785 1338 push(@lines, &html_debug("\n", __LINE__)); 786 1339 } else { … … 798 1351 push(@lines, &debug("<P>\n", __LINE__)); 799 1352 next; 1353 } elsif ($tag eq 'center') { 1354 push(@lines, &debug("<center>\n", __LINE__)); 1355 s/\@center//; 800 1356 } elsif ($tag eq 'setref') { 801 1357 &protect_html; # if setref contains '&' for instance … … 805 1361 $setref =~ s/ $//; 806 1362 $node2sec{$setref} = $name; 1363 $sec2node{$name} = $setref; 807 1364 $node2href{$setref} = "$docu_doc#$docid"; 808 1365 } else { … … 817 1374 } 818 1375 next; 819 } elsif ($tag eq 'direntry') { 820 &skip_until ($tag); 1376 } elsif ($tag eq 'lowersections') { 1377 local ($sec, $level); 1378 while (($sec, $level) = each %sec2level) { 1379 $sec2level{$sec} = $level + 1; 1380 } 1381 next; 1382 } elsif ($tag eq 'raisesections') { 1383 local ($sec, $level); 1384 while (($sec, $level) = each %sec2level) { 1385 $sec2level{$sec} = $level - 1; 1386 } 821 1387 next; 822 1388 } elsif (defined($def_map{$tag})) { … … 830 1396 s/^\@$tag\s+//; 831 1397 $sub = $user_sub{$tag}; 832 print "# user $tag = $sub, arg: $_" if $ debug& $DEBUG_USER;1398 print "# user $tag = $sub, arg: $_" if $T2H_DEBUG & $DEBUG_USER; 833 1399 if (defined(&$sub)) { 834 1400 chop($_); … … 865 1431 $type =~ s/^\{(.*)\}$/$1/; 866 1432 print "# def ($tag): {$type} ", join(', ', @args), "\n" 867 if $ debug& $DEBUG_DEF;1433 if $T2H_DEBUG & $DEBUG_DEF; 868 1434 $type .= ':'; # it's nicer like this 869 1435 $name = shift(@args); … … 909 1475 &html_pop_if(); 910 1476 push(@lines, &debug("</$format_map{$end_tag}>\n", __LINE__)); 1477 push(@lines, &debug("</BLOCKQUOTE>\n", __LINE__)) 1478 if $end_tag =~ /example/i; 1479 push(@lines, &debug("</FONT>\n", __LINE__)) 1480 if $end_tag =~ /smallexample/i; 911 1481 push(@lines, &html_debug("\n", __LINE__)); 912 } elsif ($end_tag eq 'table' || 913 $end_tag eq 'ftable' || 914 $end_tag eq 'vtable' || 915 $end_tag eq 'multitable') { 916 shift(@tables); 1482 } elsif ($end_tag =~ /^(|f|v|multi)table$/) { 1483 unless (@tables) { 1484 warn "$ERROR \@end $end_tag without \@*table\n"; 1485 next; 1486 } 1487 ($table_type, $in_table) = split($;, shift(@tables)); 1488 unless ($1 eq $table_type) { 1489 warn "$ERROR \@end $end_tag without matching \@$end_tag\n"; 1490 next; 1491 } 1492 if ($table_type eq "multi") { 1493 push(@lines, "</TR></TABLE>\n"); 1494 &html_pop_if('TR'); 1495 } else { 1496 push(@lines, "</DL>\n"); 1497 &html_pop_if('DD'); 1498 } 1499 &html_pop_if(); 917 1500 if (@tables) { 918 1501 ($table_type, $in_table) = split($;, $tables[0]); … … 920 1503 $in_table = 0; 921 1504 } 922 if ($end_tag eq 'multitable') {923 push(@lines, "</TABLE>\n");924 &html_pop_if('TABLE');925 } else {926 push(@lines, "</DL>\n");927 &html_pop_if('DD');928 }929 &html_pop_if();930 1505 } elsif (defined($def_map{$end_tag})) { 931 1506 push(@lines, &debug("</DL>\n", __LINE__)); … … 933 1508 &html_pop_if(); 934 1509 push(@lines, $_); # must keep it for pass 2 935 } 1510 } 936 1511 next; 937 1512 } … … 944 1519 $dont_html = 0; 945 1520 # substitution (unsupported things) 946 # s/^\@center\s+//g; # fixme: use <center> or <div align=center>?947 1521 s/^\@exdent\s+//g; 948 1522 s/\@noindent\s+//g; … … 956 1530 # 957 1531 if ($tag) { 958 1532 if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) { 959 1533 if (/^\@$tag\s+(.+)$/) { 960 1534 $name = $1; 961 1535 $name =~ s/\s+$//; 962 1536 $level = $sec2level{$tag}; 963 # print "+++==>$tag<\n";964 if ($number_sections && $tag !~ /heading$/) {965 $name = &update_sec_num($tag, $level) . " $name";966 push(@left_index, $name);967 }968 # $name = &update_sec_num($tag, $level) . " $name"969 # if $number_sections && $tag !~ /heading$/;970 # if $number_sections && $tag !~ /^unnumbered/;971 1537 if ($tag =~ /heading$/) { 972 1538 push(@lines, &html_debug("\n", __LINE__)); … … 975 1541 # even though we are not in the body level. So, we convert it to a 976 1542 # nice, bold, line by itself. 977 $_ = &debug("\n\n<P><STRONG>$name</STRONG> </P>\n\n", __LINE__);1543 $_ = &debug("\n\n<P><STRONG>$name</STRONG>\n\n", __LINE__); 978 1544 } else { 979 1545 $_ = &debug("<H$level>$name</H$level>\n", __LINE__); … … 981 1547 } 982 1548 print "# heading, section $name, level $level\n" 983 if $ debug& $DEBUG_TOC;1549 if $T2H_DEBUG & $DEBUG_TOC; 984 1550 } else { 985 if ($split_chapter) { 986 unless ($toplevel) { 987 # first time we see a "section" 988 unless ($level == 1) { 989 warn "$ERROR The first section found is not of level 1: $_"; 990 warn "$ERROR I'll split on sections of level $level...\n"; 991 } 992 $toplevel = $level; 993 } 994 if ($level == $toplevel) { 995 &next_doc; 996 push(@lines, $SPLITTAG) if $split_num++; 997 push(@sections, $name); 998 } 1551 $node = $name unless $node; 1552 $name = &update_sec_num($tag, $level) . " $name" 1553 if $T2H_NUMBER_SECTIONS && $tag !~ /^unnumbered/; 1554 if (defined($toplevel)) 1555 { 1556 push @lines, ($level==$toplevel ? $CHAPTEREND : $SECTIONEND); 1557 } 1558 else 1559 { 1560 # first time we see a "section" 1561 unless ($level == 1) 1562 { 1563 warn "$ERROR The first section found is not of level 1: $_"; 999 1564 } 1000 $sec_num++; 1001 $docid = "SEC$sec_num"; 1002 $tocid = "TOC$sec_num"; 1565 $toplevel = $level; 1566 } 1567 push(@sections, $name); 1568 next_doc() if ($T2H_SPLIT eq 'section' || 1569 ($T2H_SPLIT && $level == $toplevel)); 1570 $sec_num++; 1571 $docid = "SEC$sec_num"; 1572 $tocid = "TOC$sec_num"; 1003 1573 # check biblio and glossary 1004 1005 1574 $in_bibliography = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i); 1575 $in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i); 1006 1576 # check node 1007 if ($node) { 1008 if ($node2sec{$node}) { 1009 warn "$ERROR Duplicate node found: $node\n"; 1010 } else { 1577 if ($node2sec{$node}) { 1578 warn "$ERROR Duplicate node found: $node\n"; 1579 } else { 1011 1580 $node2sec{$node} = $name; 1581 warn "$ERROR Duplicate section found: $name\n" 1582 if ($sec2node{$name}); 1583 $sec2node{$name} = $node; 1012 1584 $node2href{$node} = "$docu_doc#$docid"; 1585 $node2next{$node} = $node_next; 1586 $node2prev{$node} = $node_prev; 1587 $node2up{$node} = $node_up; 1013 1588 print "# node $node, section $name, level $level\n" 1014 if $ debug& $DEBUG_TOC;1589 if $T2H_DEBUG & $DEBUG_TOC; 1015 1590 } 1016 1591 $node = ''; 1017 } else { 1018 print "# no node, section $name, level $level\n" 1019 if $debug & $DEBUG_TOC; 1020 } 1592 $node_next = ''; 1593 $node_prev = ''; 1594 $node_next = ''; 1021 1595 # update TOC 1022 1596 while ($level > $curlevel) { … … 1028 1602 push(@toc_lines, "</UL>\n"); 1029 1603 } 1030 $_ = "<LI>" . &anchor($tocid, "$docu_doc#$docid", '', $name, 1); 1031 push(@toc_lines, &substitute_style($_)); 1604 $_ = &t2h_anchor($tocid, "$docu_doc#$docid", $name, 1); 1605 $_ = &substitute_style($_); 1606 push(@stoc_lines, "$_<BR>\n") if ($level == 1); 1607 push(@toc_lines, "<LI>" . $_ ."</LI>"); 1032 1608 # update DOC 1033 1609 push(@lines, &html_debug("\n", __LINE__)); 1034 1610 &html_reset; 1035 $_ = "<H$level>".&anchor($docid, "$docu_toc#$tocid", '', $name)."</H$level>\n"; 1611 # $_ = "<H$level>".&t2h_anchor($docid, '', $name)."</H$level>\n"; 1612 $_ = "<H$level> $name </H$level>\n"; 1036 1613 $_ = &debug($_, __LINE__); 1037 1614 push(@lines, &html_debug("\n", __LINE__)); … … 1061 1638 next; 1062 1639 } 1063 $id = 'IDX' . ++$idx_num;1640 $id = ($T2H_SECTION_IDX ? $docid : 'IDX' . ++$idx_num); 1064 1641 $index = $1 . 'index'; 1065 1642 $what = &substitute_style($'); 1066 1643 $what =~ s/\s+$//; 1067 1644 print "# found $index for '$what' id $id\n" 1068 if $ debug& $DEBUG_INDEX;1645 if $T2H_DEBUG & $DEBUG_INDEX; 1069 1646 eval(<<EOC); 1070 1647 if (defined(\$$index\{\$what\})) { … … 1077 1654 # dirty hack to see if I can put an invisible anchor... 1078 1655 # 1079 if ($html_element eq 'P' || 1656 unless ($T2H_SECTION_IDX) { 1657 if ( 1658 $html_element eq 'P' || 1080 1659 $html_element eq 'LI' || 1081 1660 $html_element eq 'DT' || … … 1086 1665 $html_element eq 'PRE' || 1087 1666 $html_element eq 'SAMP') { 1088 push(@lines, & anchor($id, '', '', $invisible_mark, !$in_pre));1667 push(@lines, &t2h_anchor($id, '', $T2H_INVISIBLE_MARK, !$in_pre)); 1089 1668 } elsif ($html_element eq 'body') { 1090 1669 push(@lines, &debug("<P>\n", __LINE__)); 1091 push(@lines, & anchor($id, '', '', $invisible_mark, !$in_pre));1670 push(@lines, &t2h_anchor($id, '', $T2H_INVISIBLE_MARK, !$in_pre)); 1092 1671 &html_push('P'); 1093 1672 } elsif ($html_element eq 'DL' || 1094 1673 $html_element eq 'UL' || 1095 1674 $html_element eq 'OL' ) { 1096 $deferred_ref .= & anchor($id, '', '', $invisible_mark, !$in_pre) . " ";1675 $deferred_ref .= &t2h_anchor($id, '', $T2H_INVISIBLE_MARK, !$in_pre) . " "; 1097 1676 } 1677 } 1098 1678 next; 1099 1679 } 1100 1680 # list item 1101 if (/^\ @itemx?\s+/) {1681 if (/^\s*\@itemx?\s+/) { 1102 1682 $what = $'; 1103 1683 $what =~ s/\s+$//; … … 1107 1687 $bib2href{$what} = "$docu_doc#$id"; 1108 1688 print "# found bibliography for '$what' id $id\n" 1109 if $ debug& $DEBUG_BIB;1110 $what = & anchor($id, '', '', $what);1689 if $T2H_DEBUG & $DEBUG_BIB; 1690 $what = &t2h_anchor($id, '', $what); 1111 1691 } 1112 } elsif ($in_glossary && $ use_glossary) {1692 } elsif ($in_glossary && $T2H_USE_GLOSSARY) { 1113 1693 $id = 'GLOSS' . ++$gloss_num; 1114 1694 $entry = $what; … … 1116 1696 $gloss2href{$entry} = "$docu_doc#$id"; 1117 1697 print "# found glossary for '$entry' id $id\n" 1118 if $ debug& $DEBUG_GLOSS;1119 $what = & anchor($id, '', '', $what);1698 if $T2H_DEBUG & $DEBUG_GLOSS; 1699 $what = &t2h_anchor($id, '', $what); 1120 1700 } 1121 1701 &html_pop_if('P'); … … 1132 1712 unshift(@input_spool, "\@${table_type}index $what\n"); 1133 1713 } 1134 } elsif ($html_element eq 'TABLE' || $html_element eq 'TR') { 1135 # Add <br> at ends of rows for non-tables browsers. 1136 push(@lines, "<BR>\n") if $html_element eq 'TR'; 1137 push(@lines, "<TR>$what"); 1138 &html_push('TR') unless $html_element eq 'TR'; 1714 } elsif ($html_element eq 'TABLE') { 1715 push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__)); 1716 &html_push('TR'); 1717 } elsif ($html_element eq 'TR') { 1718 push(@lines, &debug("</TR>\n", __LINE__)); 1719 push(@lines, &debug("<TR><TD>$what</TD>\n", __LINE__)); 1139 1720 } else { 1140 1721 push(@lines, &debug("<LI>$what\n", __LINE__)); … … 1147 1728 } 1148 1729 next; 1730 } elsif (/^\@tab\s+(.*)$/) { 1731 push(@lines, "<TD>$1</TD>\n"); 1732 next; 1149 1733 } 1150 1734 } … … 1154 1738 next if $#lines >= 0 && $lines[$#lines] eq "\n"; 1155 1739 if ($html_element eq 'P') { 1156 push(@lines, "\n"); 1157 $_ = &debug("</P>\n", __LINE__); 1158 &html_pop; 1159 } 1160 } elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE') { 1161 push(@lines, "<P>\n"); 1162 &html_push('P'); 1163 $_ = &debug($_, __LINE__); 1164 } 1740 push (@lines, &debug("</P><P>\n", __LINE__)); 1741 } 1742 # else 1743 # { 1744 # push(@lines, "<P></P>\n"); 1745 # $_ = &debug("<P></P>\n", __LINE__); 1746 # } 1747 elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE' || $html_element eq 'DD') 1748 { 1749 &html_push('P'); 1750 push(@lines, &debug("<P>\n", __LINE__)); 1751 } 1752 } 1165 1753 # otherwise 1166 1754 push(@lines, $_); 1755 1756 push(@lines, &debug("</center>\n", __LINE__)) if ($tag eq 'center'); 1167 1757 } 1168 1758 … … 1174 1764 } 1175 1765 1176 print "# end of pass 1\n" if $ verbose;1766 print "# end of pass 1\n" if $T2H_VERBOSE; 1177 1767 1178 1768 #+++############################################################################ … … 1185 1775 @lines3 = (); # whole document (3rd pass) 1186 1776 $in_menu = 0; # am I inside a menu 1187 $in_top = 1;1188 1777 1189 1778 while (@lines) { … … 1196 1785 next; 1197 1786 } 1198 if ($in_top && $_ eq "$TOPTAG") {1199 $in_top = 0;1200 while(@lines2) {1201 $_ = shift(@lines2);1202 if (/\@(\w+)\ /) {1203 ($before, $style, $after) = ($`, $1, $');1204 if (defined($style_l_map{$style})) {1205 $_ = $after;1206 $text = '';1207 $after = '';1208 $failed = 1;1209 while (@lines2) {1210 if (/\n/) {1211 $text .= $`;1212 $after = $';1213 $failed = 0;1214 last;1215 } else {1216 $text .= $_;1217 $_ = shift(@lines2);1218 }1219 }1220 if ($failed) {1221 die "* Bad syntax (\@$style) after: $before\n";1222 } else {1223 $text = &apply_l_style($style, $text);1224 $_ = "$before$text$after\n";1225 }1226 }1227 }1228 push(@top_lines, $_);1229 }1230 #@top_lines = @lines2; # Contents of the top node.1231 @lines2 = (); # Don't use them in place.1232 next;1233 }1234 1787 # 1235 1788 # menu 1236 1789 # 1237 $in_menu = 1, push(@lines2, &debug("<UL>\n", __LINE__)), next if /^\@menu\b/; 1238 $in_menu = 0, push(@lines2, &debug("</UL>\n", __LINE__)), next if /^\@end\s+menu\b/; 1790 if (/^\@menu\b/) 1791 { 1792 $in_menu = 1; 1793 $T2H_NUMBER_SECTIONS ? 1794 push(@lines2, &debug("<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> \n", __LINE__)) : 1795 push(@lines2, &debug("<UL>\n", __LINE__)); 1796 next; 1797 } 1798 if (/^\@end\s+menu\b/) 1799 { 1800 $in_menu = 0; 1801 $T2H_NUMBER_SECTIONS ? 1802 push(@lines2, &debug("</TABLE></BLOCKQUOTE>\n", __LINE__)) : 1803 push(@lines2, &debug("</UL>\n", __LINE__)); 1804 next; 1805 } 1239 1806 if ($in_menu) { 1240 1807 if (/^\*\s+($NODERE)::/o) { … … 1256 1823 # printindex 1257 1824 # 1258 if (/^\@printindex\s+(\w\w)\b/) { 1259 local($index, *ary, @keys, $key, $letter, $last_letter, @refs); 1825 # obachman: replace ^\@printindex by \@printindex, otherwise 1826 # generation in debug mode fails 1827 if (/\@printindex\s+(\w\w)\b/) { 1828 local($index, *ary, @keys, $key, $letter, $last_letter, @refs, $fhidx); 1260 1829 if ($predefined_index{$1}) { 1261 1830 $index = $predefined_index{$1} . 'index'; 1262 1831 } else { 1263 1832 $index = $1 . 'index'; 1833 } 1834 # check for index summary 1835 $letter = $1; 1836 if ($letter =~ /$T2H_IDX_SUMMARY/) 1837 { 1838 open(FHIDX, "> $docu_rdir$docu_name" . "_$letter.idx") 1839 || die "Can't open > $docu_rdir$docu_name" . "_$letter.idx for writing: $!\n"; 1840 $fhidx = \*FHIDX; 1841 print "# writing index summary in $docu_rdir$docu_name" . "_$letter.idx..." if $T2H_VERBOSE; 1264 1842 } 1265 1843 eval("*ary = *$index"); … … 1274 1852 $key2alpha{$key} = $_; 1275 1853 print "# index $key sorted as $_\n" 1276 if $key ne $_ && $debug & $DEBUG_INDEX; 1277 } 1854 if $key ne $_ && $T2H_DEBUG & $DEBUG_INDEX; 1855 } 1856 push(@lines2, "Jump to:\n"); 1857 $last_letter = undef; 1858 foreach $key (sort byalpha @keys) { 1859 $letter = substr($key2alpha{$key}, 0, 1); 1860 $letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;; 1861 if (!defined($last_letter) || $letter ne $last_letter) { 1862 push(@lines2, "-\n") if defined($last_letter); 1863 push(@lines2, "<A HREF=\"#$index\_$letter\">" . &protect_html($letter) . "</A>\n"); 1864 $last_letter = $letter; 1865 } 1866 } 1867 push(@lines2, "<P>\n"); 1278 1868 $last_letter = undef; 1279 1869 foreach $key (sort byalpha @keys) { … … 1282 1872 if (!defined($last_letter) || $letter ne $last_letter) { 1283 1873 push(@lines2, "</DIR>\n") if defined($last_letter); 1284 push(@lines2, "<H2> " . &protect_html($letter) . "</H2>\n");1874 push(@lines2, "<H2><A NAME=\"$index\_$letter\">" . &protect_html($letter) . "</A></H2>\n"); 1285 1875 push(@lines2, "<DIR>\n"); 1286 1876 $last_letter = $letter; … … 1288 1878 @refs = (); 1289 1879 foreach (split(/$;/, $ary{$key})) { 1290 push(@refs, & anchor('', $_, '', $key, 0));1880 push(@refs, &t2h_anchor('', $_, $key, 0)); 1291 1881 } 1292 1882 push(@lines2, "<LI>" . join(", ", @refs) . "\n"); 1883 if ($fhidx) 1884 { 1885 ($letter) = split(/$;/, $ary{$key}); 1886 $key = unprotect_html($key); 1887 print $fhidx "$key\t$letter\n"; 1888 } 1293 1889 } 1294 1890 push(@lines2, "</DIR>\n") if defined($last_letter); 1891 if ($fhidx) 1892 { 1893 print "\n" if $T2H_VERBOSE; 1894 close($fhidx); 1895 } 1295 1896 next; 1296 1897 } … … 1306 1907 ($type, $nodes, $full) = ($1, $2, $3); 1307 1908 ($before, $after) = ($`, $'); 1308 $ref_where = "Section";1309 1909 if (! $full && $after) { 1310 1910 warn "$ERROR Bad xref (no ending } on line): $_"; … … 1349 1949 &normalise_node($node); 1350 1950 $sec = $node2sec{$node}; 1351 $_ = $sec; 1352 if (/^[A-Z]/) { 1353 $ref_where = "Appendix"; 1354 } 1951 $href = $node2href{$node}; 1355 1952 if (@args == 5) { # reference to another manual 1356 1953 $sec = $args[2] || $node; 1357 1954 $man = $args[4] || $args[3]; 1358 $_ = "${before}${type} $ref_where`$sec' in \@cite{$man}$after";1955 $_ = "${before}${type}section `$sec' in \@cite{$man}$after"; 1359 1956 } elsif ($type =~ /Info/) { # inforef 1360 1957 warn "$ERROR Wrong number of arguments: $_" unless @args == 3; 1361 1958 ($nn, $_, $in) = @args; 1362 1959 $_ = "${before}${type} file `$in', node `$nn'$after"; 1363 } elsif ($sec) { 1364 $href = $node2href{$node}; 1365 $_ = "${before}${type}" . &anchor('', $href, '', "$ref_where $sec") . $after; 1366 } else { 1960 } elsif ($sec && $href && ! $T2H_SHORT_REF) { 1961 $_ = "${before}${type}section " . 1962 &t2h_anchor('', $href, $sec) . $after; 1963 } 1964 elsif ($href && $T2H_SHORT_REF) 1965 { 1966 $_ = "${before}${type} " . &t2h_anchor('', $href, $node) . $after; 1967 } 1968 else { 1367 1969 warn "$ERROR Undefined node ($node): $_"; 1368 1970 $_ = "$before$;0xref{$nodes}$after"; 1369 1971 } 1370 1972 } 1973 1974 if (/^\@image\s*{/) { 1975 s/\@image\s*{//; 1976 my (@args) = split (/,/); 1977 my $base = $args[0]; 1978 my $image; 1979 if (-r "$base.jpg") { 1980 $image = "$base.jpg"; 1981 } elsif (-r "$base.png") { 1982 $image = "$base.png"; 1983 } elsif (-r "$base.gif") { 1984 $image = "$base.gif"; 1985 } else { 1986 warn "$ERROR no image file for $base: $_"; 1987 } 1988 $_ = "<IMG SRC=\"$image\" ALT=\"$base\">"; 1989 } 1990 1371 1991 # 1372 1992 # try to guess bibliography references or glossary terms … … 1379 1999 $href = $bib2href{$what}; 1380 2000 if (defined($href) && $post !~ /^[^<]*<\/A>/) { 1381 $done .= $pre . & anchor('', $href, '', $what);2001 $done .= $pre . &t2h_anchor('', $href, $what); 1382 2002 } else { 1383 2003 $done .= "$pre$what"; … … 1387 2007 $_ = $done . $_; 1388 2008 } 1389 if ($ use_glossary) {2009 if ($T2H_USE_GLOSSARY) { 1390 2010 $done = ''; 1391 2011 while (/\b\w+\b/) { … … 1395 2015 $href = $gloss2href{$entry}; 1396 2016 if (defined($href) && $post !~ /^[^<]*<\/A>/) { 1397 $done .= $pre . & anchor('', $href, '', $what);2017 $done .= $pre . &t2h_anchor('', $href, $what); 1398 2018 } else { 1399 2019 $done .= "$pre$what"; … … 1407 2027 push(@lines2, $_); 1408 2028 } 1409 print "# end of pass 2\n" if $ verbose;2029 print "# end of pass 2\n" if $T2H_VERBOSE; 1410 2030 1411 2031 # … … 1453 2073 } 1454 2074 } 1455 if (/\@(\w+)\ /) {1456 ($before, $style, $after) = ($`, $1, $');1457 if (defined($style_l_map{$style})) {1458 $_ = $after;1459 $text = '';1460 $after = '';1461 $failed = 1;1462 while (@lines2) {1463 if (/\n/) {1464 $text .= $`;1465 $after = $';1466 $failed = 0;1467 last;1468 } else {1469 $text .= $_;1470 $_ = shift(@lines2);1471 }1472 }1473 if ($failed) {1474 die "* Bad syntax (\@$style) after: $before\n";1475 } else {1476 $text = &apply_l_style($style, $text);1477 $_ = "$before$text$after";1478 }1479 }1480 }1481 2075 } 1482 2076 # otherwise 1483 2077 push(@lines3, $_); 1484 2078 } 1485 print "# end of pass 3\n" if $ verbose;1486 2079 print "# end of pass 3\n" if $T2H_VERBOSE; 2080 1487 2081 #+++############################################################################ 1488 2082 # # … … 1494 2088 @doc_lines = (); # final document 1495 2089 $end_of_para = 0; # true if last line is <P> 1496 2090 1497 2091 while (@lines3) { 1498 2092 $_ = shift(@lines3); … … 1532 2126 $footid = "FOOT$foot_num"; 1533 2127 $foot = "($foot_num)"; 1534 push(@foot_lines, "<H3>" . & anchor($footid, "$d#$docid", '', $foot) . "</H3>\n");2128 push(@foot_lines, "<H3>" . &t2h_anchor($footid, "$d#$docid", $foot) . "</H3>\n"); 1535 2129 $text = "<P>$text" unless $text =~ /^\s*<P>/; 1536 2130 push(@foot_lines, "$text\n"); 1537 $_ = $before . & anchor($docid, "$docu_foot#$footid", '', $foot) . $after;2131 $_ = $before . &t2h_anchor($docid, "$docu_foot#$footid", $foot) . $after; 1538 2132 } 1539 2133 } … … 1549 2143 push(@doc_lines, $_); 1550 2144 } 1551 print "# end of pass 4\n" if $verbose; 1552 1553 push(@menu_lines, "<BODY BACKGROUND=\"$IMG_LEFT\">\n"); 1554 push(@menu_lines, "<A HREF=\"http://www.mathematik.uni-kl.de/~zca/Singular\" TARGET=\"_parent\">"); 1555 push(@menu_lines, "<IMG SRC=\"images/singular-small.jpg\"></A><P>\n"); 1556 #push(@menu_lines, "<BODY BACKGROUND=\"/rock.gif\" TEXT=\"yellow\""); 1557 #push(@menu_lines, " LINK=#FFFFFF ALINK=#FF00FF VLINK=\"#00FF00\">\n"); 1558 #push(@menu_lines, "<NOBR>\n"); 1559 push(@menu_lines, "<OL>\n"); 1560 foreach (@left_index) { 1561 $entry = $_; 1562 @part = split(/\ /); 1563 $name = join(' ', @part[1..$#part]); 1564 if (!/^[A-Z0-9]\./) { 1565 &left_menu_entry($part[0], $name); 1566 } 1567 } 1568 push(@menu_lines, "</OL>\n"); 1569 print "# end of pass 5\n" if $verbose; 2145 2146 print "# end of pass 4\n" if $T2H_VERBOSE; 1570 2147 1571 2148 #+++############################################################################ 1572 2149 # # 1573 # Pass 6: print things #2150 # Pass 5: print things # 1574 2151 # # 1575 2152 #---############################################################################ 1576 2153 1577 $header = <<EOT; 1578 <!-- This HTML file has been created by $THISPROG 1579 from $docu on $TODAY --> 1580 EOT 1581 1582 $full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; 1583 $title = $value{'_settitle'} || $full_title; 1584 $_ = &substitute_style($full_title); 1585 &unprotect_texi; 1586 s/\n$//; # rmv last \n (if any) 1587 $full_title = "<H1>" . join("</H1>\n<H1>", split(/\n/, $_)) . "</H1>\n"; 1588 1589 # 1590 # print ToC 1591 # 1592 # ... unless using menus instead. Make the TOC lines empty rather than 1593 # null so we get a ToC page with the top node (including menu). 1594 @toc_lines = ("") if $show_menu; 1595 1596 if (!$monolithic && @toc_lines) { 1597 if (open(FILE, "> $docu_toc")) { 1598 print "# creating $docu_toc...\n" if $verbose; 1599 &print_header("$title - Table of Contents", "", 0); 1600 # &print_toplevel_header("$title - Table of Contents"); 1601 &print_ruler; 1602 &print (*top_lines, FILE); # Contents of the top node before the TOC. 1603 &print(*toc_lines, FILE); 1604 &print_toplevel_footer; 1605 close(FILE); 1606 } else { 1607 warn "$ERROR Can't write to $docu_toc: $!\n"; 1608 } 1609 } 1610 1611 # 1612 # print footnotes 1613 # 1614 if (!$monolithic && @foot_lines) { 1615 if (open(FILE, "> $docu_foot")) { 1616 print "# creating $docu_foot...\n" if $verbose; 1617 &print_toplevel_header("$title - Footnotes"); 1618 &print_ruler; 1619 &print(*foot_lines, FILE); 1620 &print_toplevel_footer; 1621 close(FILE); 1622 } else { 1623 warn "$ERROR Can't write to $docu_foot: $!\n"; 1624 } 1625 } 1626 1627 # 1628 # 1629 # 1630 if (!$monolithic && $make_entry_page) { 1631 if(open(FILE, "> $docu_main")) { 1632 &print_header("$title - $docu_name", "", 1); 1633 print "# creating $docu_main...\n" if $verbose; 1634 #&print_frame($docu_name . "_1.html"); 1635 &print_frame($docu_toc); 1636 &print_toplevel_footer; 1637 close(FILE); 1638 } else { 1639 warn "$ERROR Can't write to $docu_main: $!\n"; 1640 } 1641 } 1642 1643 # 1644 # 1645 # 1646 if (!$monolithic && $make_menu_page && @menu_lines) { 1647 if(open(FILE, "> $docu_left")) { 1648 &print_header("$title - $docu_left", "", 1); 1649 print "# creating $docu_left...\n" if $verbose; 1650 &print(*menu_lines, FILE); 1651 &print_footer; 1652 close(FILE); 1653 } else { 1654 warn "$ERROR Can't write to $docu_main: $!\n"; 1655 } 1656 } 1657 1658 # 1659 # print document 1660 # 1661 if ($split_chapter || $split_node) { # split 1662 $doc_num = 0; 1663 $last_num = scalar(@sections); 1664 $first_doc = &doc_name(1); 1665 $last_doc = &doc_name($last_num); 1666 while (@sections) { 1667 $section = shift(@sections); 1668 &next_doc; 1669 if (open(FILE, "> $docu_doc")) { 1670 print "# creating $docu_doc...\n" if $verbose; 1671 $prev_doc = ($doc_num == 1 ? undef : &doc_name($doc_num - 1)); 1672 $next_doc = ($doc_num == $last_num ? undef : &doc_name($doc_num + 1)); 1673 $links = ($next_doc ? "<link href=\"$next_doc\" rel=Next>\n" : ""); 1674 $links .= ($prev_doc ? "<link href=\"$prev_doc\" rel=Previous>\n" : ""); 1675 $links .= "<link href=\"$docu_toc\" rel=ToC>\n"; 1676 # fixme: try rel=Index too? 1677 &print_header("$title - $section", $links, 0); 1678 1679 #$navigation = "<p>Go to the "; 1680 $navigation = "<p>"; 1681 if ($IMG_FIRST_ACTIVE ne "") { 1682 $navigation .= ($prev_doc ? &anchor('', $first_doc, '', 1683 $IMG_FIRST_ACTIVE) : $IMG_FIRST_PASSIVE); 1684 $navigation .= " "; 1685 } 1686 $navigation .= ($prev_doc ? &anchor('', $prev_doc, '', $IMG_PREV_ACTIVE) : $IMG_PREV_PASSIVE); 1687 $navigation .= " "; 1688 $navigation .= ($next_doc ? &anchor('', $next_doc, '', $IMG_NEXT_ACTIVE) : $IMG_NEXT_PASSIVE); 1689 if ($IMG_LAST_ACTIVE ne "") { 1690 $navigation .= " "; 1691 $navigation .= ($next_doc ? &anchor('', $last_doc, '', 1692 $IMG_LAST_ACTIVE) : $IMG_LAST_PASSIVE); 1693 } 1694 #$navigation .= " section, " . &anchor('', $docu_toc, '', "<IMG SRC=\"toc-b.gif\">") . ".\n"; 1695 $navigation .= " " . &anchor('', $docu_toc, '', $IMG_TOC) . "\n"; 1696 print FILE $navigation; 1697 &print_ruler; 1698 # find corresponding lines 1699 @tmp_lines = (); 1700 while (@doc_lines) { 1701 $_ = shift(@doc_lines); 1702 last if ($_ eq $SPLITTAG); 1703 push(@tmp_lines, $_); 1704 } 1705 &print(*tmp_lines, FILE); 1706 &print_ruler; 1707 print FILE $navigation; 1708 &print_footer; 1709 close(FILE); 1710 } else { 1711 warn "$ERROR Can't write to $docu_doc: $!\n"; 1712 } 1713 } 1714 } else { # not split 1715 if (open(FILE, "> $docu_doc")) { 1716 print "# creating $docu_doc...\n" if $verbose; 1717 if ($monolithic || !@toc_lines) { 1718 &print_toplevel_header($title); 1719 } else { 1720 &print_header($title, "", 0); 1721 print FILE $full_title; 1722 } 1723 if ($monolithic && @toc_lines) { 1724 &print_ruler; 1725 print FILE "<H1>Table of Contents</H1>\n"; 1726 &print(*toc_lines, FILE); 1727 } 1728 &print_ruler; 1729 &print(*doc_lines, FILE); 1730 if ($monolithic && @foot_lines) { 1731 &print_ruler; 1732 print FILE "<H1>Footnotes</H1>\n"; 1733 &print(*foot_lines, FILE); 1734 } 1735 if ($monolithic || !@toc_lines) { 1736 &print_toplevel_footer; 1737 } else { 1738 &print_footer; 1739 } 1740 close(FILE); 1741 } else { 1742 warn "$ERROR Can't write to $docu_doc: $!\n"; 1743 } 1744 } 1745 1746 print "# that's all folks\n" if $verbose; 2154 $T2H_L2H = &l2h_FinishToLatex if ($T2H_L2H); 2155 $T2H_L2H = &l2h_ToHtml if ($T2H_L2H); 2156 $T2H_L2H = &l2h_InitFromHtml if ($T2H_L2H); 2157 2158 # prepare %T2H_THISDOC 2159 $T2H_THISDOC{fulltitle} = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; 2160 $T2H_THISDOC{title} = $value{'_settitle'} || $T2H_THISDOC{fulltitle}; 2161 $T2H_THISDOC{author} = $value{'_author'}; 2162 $T2H_THISDOC{subtitle} = $value{'_subtitle'}; 2163 for $key (keys %T2H_THISDOC) 2164 { 2165 $_ = &substitute_style($T2H_THISDOC{$key}); 2166 &unprotect_texi; 2167 s/\s*$//; 2168 $T2H_THISDOC{$key} = $_; 2169 } 2170 2171 # if no sections, then simply print docuemnt as is 2172 unless (@sections) 2173 { 2174 print "# Writing content into $docu_top_file \n" if $T2H_VERBOSE; 2175 open(FILE, "> $docu_doc_file") 2176 || die "$ERROR: Can't open $docu_doc_file for writing: $!\n"; 2177 2178 t2h_print_page_head(\*FILE); 2179 $T2H_THIS_SECTION = \@doc_lines; 2180 t2h_print_lines(\*FILE); 2181 t2h_print_page_foot(\*FILE); 2182 close(FILE); 2183 goto Finish; 2184 } 2185 2186 # initialize $T2H_HREF, $T2H_NAME 2187 %T2H_HREF = 2188 ( 2189 'First' , sec_href($sections[0]), 2190 'Last', sec_href($sections[$#sections]), 2191 'About', $docu_about. '#SEC_About', 2192 ); 2193 2194 # prepare TOC, OVERVIEW, TOP 2195 $T2H_TOC = \@toc_lines; 2196 $T2H_OVERVIEW = \@stoc_lines; 2197 if ($has_top) 2198 { 2199 while (1) 2200 { 2201 $_ = shift @doc_lines; 2202 last if /$TOPEND/; 2203 push @$T2H_TOP, $_; 2204 } 2205 $T2H_HREF{'Top'} = $docu_top . '#SEC_Top'; 2206 } 2207 else 2208 { 2209 $T2H_HREF{'Top'} = $T2H_HREF{First}; 2210 } 2211 2212 $node2href{Top} = $T2H_HREF{Top}; 2213 $T2H_HREF{Contents} = $docu_toc.'#SEC_Contents' if @toc_lines; 2214 $T2H_HREF{Overview} = $docu_stoc.'#SEC_OVERVIEW' if @stoc_lines; 2215 $T2H_HREF{Index} = $node2href{'Index'}; 2216 2217 %T2H_NAME = 2218 ( 2219 'First', clean_name($sec2node{$sections[0]}), 2220 'Last', clean_name($sec2node{$sections[$#sections]}), 2221 'About', 'About this document', 2222 'Contents', 'Table of Contents', 2223 'Overview', 'Overview (Short Table of Contents)', 2224 'Index' , '', 2225 'Top', '' 2226 ); 2227 2228 ############################################################################# 2229 # print Top 2230 # 2231 open(FILE, "> $docu_top_file") 2232 || die "$ERROR: Can't open $docu_top_file for writing: $!\n"; 2233 if ($T2H_TOP) 2234 { 2235 print "# Creating Top in $docu_top_file ...\n" if $T2H_VERBOSE; 2236 t2h_print_page_head(\*FILE) unless ($T2H_SPLIT); 2237 $T2H_THIS_SECTION = $T2H_TOP; 2238 $T2H_HREF{This} = $T2H_HREF{Top}; 2239 $T2H_NAME{This} = $T2H_NAME{Top}; 2240 t2h_print_Top(\*FILE); 2241 2242 } 2243 close(FILE) if $T2H_SPLIT; 2244 2245 ############################################################################# 2246 # Print sections 2247 # 2248 $T2H_NODE{Forward} = $sec2node{$sections[0]}; 2249 $T2H_NAME{Forward} = &clean_name($sec2node{$sections[0]}); 2250 $T2H_HREF{Forward} = sec_href($sections[0]); 2251 $T2H_NODE{This} = 'Top'; 2252 $T2H_NAME{This} = $T2H_NAME{Top}; 2253 $T2H_HREF{This} = $T2H_HREF{Top}; 2254 if ($T2H_SPLIT) 2255 { 2256 print "# writing " . scalar(@sections) . 2257 " sections in $docu_rdir$docu_name"."_[1.." . 2258 ($T2H_SPLIT eq 'section' ? scalar(@sections) : scalar(@$T2H_OVERVIEW) ) . 2259 "]" 2260 if $T2H_VERBOSE; 2261 $previous = ($T2H_SPLIT eq 'chapter' ? $CHAPTEREND : $SECTIONEND); 2262 undef $FH; 2263 $doc_num = 0; 2264 } 2265 else 2266 { 2267 print "# writing " . scalar(@sections) . " sections in $docu_top_file ..." 2268 if $T2H_VERBOSE; 2269 $FH = \*FILE; 2270 $previous = ''; 2271 } 2272 2273 $counter = 0; 2274 # loop through sections 2275 while ($section = shift(@sections)) 2276 { 2277 if ($T2H_SPLIT && ($T2H_SPLIT eq 'section' || $previous eq $CHAPTEREND)) 2278 { # open new page 2279 if ($FH) 2280 { #close previous page 2281 t2h_print_page_foot($FH); 2282 close($FH); 2283 } 2284 &next_doc; 2285 open(FILE, "> $docu_rdir$docu_doc") || 2286 die "$ERROR: Can't open $docu_rdir$docu_doc for writing: $!\n"; 2287 $FH = \*FILE; 2288 t2h_print_page_head($FH); 2289 } 2290 $T2H_NAME{Back} = $T2H_NAME{This}; 2291 $T2H_HREF{Back} = $T2H_HREF{This}; 2292 $T2H_NODE{Back} = $T2H_NODE{This}; 2293 $T2H_NAME{This} = $T2H_NAME{Forward}; 2294 $T2H_HREF{This} = $T2H_HREF{Forward}; 2295 $T2H_NODE{This} = $T2H_NODE{Forward}; 2296 if ($sections[0]) 2297 { 2298 $T2H_NODE{Forward} = $sec2node{$sections[0]}; 2299 $T2H_NAME{Forward} = &clean_name($T2H_NODE{Forward}); 2300 $T2H_HREF{Forward} = sec_href($sections[0]); 2301 } 2302 else 2303 { 2304 undef $T2H_HREF{Forward}, $T2H_NODE{Forward}, $T2H_NAME{Forward}; 2305 } 2306 2307 $node = $node2up{$T2H_NODE{This}}; 2308 $T2H_HREF{Up} = $node2href{$node}; 2309 if ($T2H_HREF{Up} eq $T2H_HREF{This} || ! $T2H_HREF{Up}) 2310 { 2311 $T2H_NAME{Up} = $T2H_NAME{Top}; 2312 $T2H_HREF{Up} = $T2H_HREF{Top}; 2313 $T2H_NODE{Up} = 'Up'; 2314 } 2315 else 2316 { 2317 $T2H_NAME{Up} = &clean_name($node); 2318 $T2H_NODE{Up} = $node; 2319 } 2320 2321 $node = $T2H_NODE{This}; 2322 $node = $node2prev{$node}; 2323 $T2H_NAME{Prev} = &clean_name($node); 2324 $T2H_HREF{Prev} = $node2href{$node}; 2325 $T2H_NODE{Prev} = $node; 2326 2327 $node = $T2H_NODE{This}; 2328 if ($node2up{$node} && $node2up{$node} ne 'Top'&& 2329 ($node2prev{$node} eq $T2H_NODE{Back} || ! $node2prev{$node})) 2330 { 2331 $node = $node2up{$node}; 2332 while ($node && $node ne $node2up{$node} && ! $node2prev{$node}) 2333 { 2334 $node = $node2up{$node}; 2335 } 2336 $node = $node2prev{$node} 2337 unless $node2up{$node} eq 'Top' || ! $node2up{$node}; 2338 } 2339 else 2340 { 2341 $node = $node2prev{$node}; 2342 } 2343 $T2H_NAME{FastBack} = &clean_name($node); 2344 $T2H_HREF{FastBack} = $node2href{$node}; 2345 $T2H_NODE{FastBack} = $node; 2346 2347 $node = $T2H_NODE{This}; 2348 $node = $node2next{$node}; 2349 $T2H_NAME{Next} = &clean_name($node); 2350 $T2H_HREF{Next} = $node2href{$node}; 2351 $T2H_NODE{Next} = $node; 2352 2353 $node = $T2H_NODE{This}; 2354 if ($node2up{$node} && $node2up{$node} ne 'Top'&& 2355 ($node2next{$node} eq $T2H_NODE{Forward} || ! $node2next{$node})) 2356 { 2357 $node = $node2up{$node}; 2358 while ($node && $node ne $node2up{$node} && ! $node2next{$node}) 2359 { 2360 $node = $node2up{$node}; 2361 } 2362 } 2363 $node = $node2next{$node}; 2364 $T2H_NAME{FastForward} = &clean_name($node); 2365 $T2H_HREF{FastForward} = $node2href{$node}; 2366 $T2H_NODE{FastForward} = $node; 2367 2368 $T2H_THIS_SECTION = []; 2369 while (@doc_lines) { 2370 $_ = shift(@doc_lines); 2371 last if ($_ eq $SECTIONEND || $_ eq $CHAPTEREND); 2372 push(@$T2H_THIS_SECTION, $_); 2373 } 2374 $previous = $_; 2375 t2h_print_label($FH); 2376 t2h_print_section($FH); 2377 2378 if ($T2H_VERBOSE) 2379 { 2380 $counter++; 2381 print "." if $counter =~ /00$/; 2382 } 2383 } 2384 if ($T2H_SPLIT) 2385 { 2386 t2h_print_page_foot($FH); 2387 close($FH); 2388 } 2389 print "\n" if $T2H_VERBOSE; 2390 2391 ############################################################################# 2392 # Print ToC, Overview, Footnotes 2393 # 2394 undef $T2H_HREF{Prev}; 2395 undef $T2H_HREF{Next}; 2396 undef $T2H_HREF{Back}; 2397 undef $T2H_HREF{Forward}; 2398 undef $T2H_HREF{Up}; 2399 2400 if (@foot_lines) 2401 { 2402 print "# writing Footnotes in $docu_foot_file...\n" if $T2H_VERBOSE; 2403 open (FILE, "> $docu_foot_file") || die "$ERROR: Can't open $docu_foot_file for writing: $!\n" 2404 if $T2H_SPLIT; 2405 $T2H_HREF{This} = $docu_foot; 2406 $T2H_NAME{This} = 'Footnotes'; 2407 $T2H_THIS_SECTION = \@foot_lines; 2408 t2h_print_footnotes(\*FILE); 2409 close(FILE) if $T2H_SPLIT; 2410 } 2411 2412 if (@toc_lines) 2413 { 2414 print "# writing Toc in $docu_toc_file...\n" if $T2H_VERBOSE; 2415 open (FILE, "> $docu_toc_file") || die "$ERROR: Can't open $docu_toc_file for writing: $!\n" 2416 if $T2H_SPLIT; 2417 $T2H_HREF{This} = $T2H_HREF{Contents}; 2418 $T2H_NAME{This} = $T2H_NAME{Contents}; 2419 $T2H_THIS_SECTION = \@toc_lines; 2420 t2h_print_Toc(\*FILE); 2421 close(FILE) if $T2H_SPLIT; 2422 } 2423 2424 if (@stoc_lines) 2425 { 2426 print "# writing Overview in $docu_stoc_file...\n" if $T2H_VERBOSE; 2427 open (FILE, "> $docu_stoc_file") || die "$ERROR: Can't open $docu_stoc_file for writing: $!\n" 2428 if $T2H_SPLIT; 2429 2430 $T2H_HREF{This} = $T2H_HREF{Overview}; 2431 $T2H_NAME{This} = $T2H_NAME{Overview}; 2432 $T2H_THIS_SECTION = \@stoc_lines; 2433 t2h_print_Overview(\*FILE); 2434 close(FILE) if $T2H_SPLIT; 2435 } 2436 2437 if ($about_body = t2h_about_body()) 2438 { 2439 print "# writing About in $docu_about_file...\n" if $T2H_VERBOSE; 2440 open (FILE, "> $docu_about_file") || die "$ERROR: Can't open $docu_about_file for writing: $!\n" 2441 if $T2H_SPLIT; 2442 2443 $T2H_HREF{This} = $T2H_HREF{About}; 2444 $T2H_NAME{This} = $T2H_NAME{About}; 2445 $T2H_THIS_SECTION = [$about_body]; 2446 t2h_print_About(\*FILE); 2447 close(FILE) if $T2H_SPLIT; 2448 } 2449 2450 unless ($T2H_SPLIT) 2451 { 2452 t2h_print_page_foot(\*FILE); 2453 close (FILE); 2454 } 2455 2456 Finish: 2457 &l2h_FinishFromHtml if ($T2H_L2H); 2458 &l2h_Finish if($T2H_L2H); 2459 print "# that's all folks\n" if $T2H_VERBOSE; 2460 2461 exit(0); 1747 2462 1748 2463 #+++############################################################################ … … 1752 2467 #---############################################################################ 1753 2468 2469 sub clean_name 2470 { 2471 local ($_); 2472 $_ = &remove_style($_[0]); 2473 &unprotect_texi; 2474 return $_; 2475 } 2476 1754 2477 sub update_sec_num { 1755 2478 local($name, $level) = @_; 2479 my $ret; 1756 2480 1757 2481 $level--; # here we start at 0 1758 if ( ($name =~ /^appendix/) || ($section_type)) {2482 if ($name =~ /^appendix/ || defined(@appendix_sec_num)) { 1759 2483 # appendix style 1760 $section_type = 1;1761 2484 if (defined(@appendix_sec_num)) { 1762 2485 &incr_sec_num($level, @appendix_sec_num); … … 1764 2487 @appendix_sec_num = ('A', 0, 0, 0); 1765 2488 } 1766 return(join('.', @appendix_sec_num[0..$level]));2489 $ret = join('.', @appendix_sec_num[0..$level]); 1767 2490 } else { 1768 2491 # normal style 1769 $section_type = 0; 1770 if (defined(@normal_sec_num)) { 1771 &incr_sec_num($level, @normal_sec_num); 1772 } else { 1773 @normal_sec_num = (1, 0, 0, 0); 1774 } 1775 return(join('.', @normal_sec_num[0..$level])); 1776 } 2492 if (defined(@normal_sec_num)) 2493 { 2494 &incr_sec_num($level, @normal_sec_num); 2495 } 2496 else 2497 { 2498 @normal_sec_num = (1, 0, 0, 0); 2499 } 2500 $ret = join('.', @normal_sec_num[0..$level]); 2501 } 2502 2503 $ret .= "." if $level == 0; 2504 return $ret; 1777 2505 } 1778 2506 … … 1792 2520 if (/\@(\*|\.|\:|\@|\{|\})/) { 1793 2521 $seen{$&}++; 1794 $context{$&} .= "> $_" if $ verbose;2522 $context{$&} .= "> $_" if $T2H_VERBOSE; 1795 2523 $_ = "$`XX$'"; 1796 2524 redo; … … 1800 2528 if ($before =~ /\b[\w-]+$/ && $after =~ /^[\w-.]*\b/) { # e-mail address 1801 2529 $seen{'e-mail address'}++; 1802 $context{'e-mail address'} .= "> $_" if $ verbose;2530 $context{'e-mail address'} .= "> $_" if $T2H_VERBOSE; 1803 2531 } else { 1804 2532 $seen{$match}++; 1805 $context{$match} .= "> $_" if $ verbose;2533 $context{$match} .= "> $_" if $T2H_VERBOSE; 1806 2534 } 1807 2535 $match =~ s/^\@/X/; … … 1812 2540 1813 2541 foreach (sort(keys(%seen))) { 1814 if ($ verbose) {2542 if ($T2H_VERBOSE) { 1815 2543 print "$_\n"; 1816 2544 print $context{$_}; … … 1867 2595 } 1868 2596 2597 # used in pass 1 for l2h use &next_line 2598 sub string_until { 2599 local($tag) = @_; 2600 local($_, $string); 2601 2602 while ($_ = &next_line) { 2603 return $string if /^\@end\s+$tag\s*$/; 2604 # $_ =~ s/hbox/mbox/g; 2605 $string = $string.$_; 2606 } 2607 die "* Failed to find '$tag' after: " . $lines[$#lines]; 2608 } 2609 1869 2610 # 1870 2611 # HTML stacking to have a better HTML output … … 1911 2652 local($what, $line) = @_; 1912 2653 return("<!-- $line @html_stack, $html_element -->$what") 1913 if $ debug& $DEBUG_HTML;2654 if $T2H_DEBUG & $DEBUG_HTML; 1914 2655 return($what); 1915 2656 } … … 1919 2660 local($what, $line) = @_; 1920 2661 return("<!-- $line -->$what") 1921 if $ debug& $DEBUG_HTML;2662 if $T2H_DEBUG & $DEBUG_HTML; 1922 2663 return($what); 1923 2664 } … … 1929 2670 } 1930 2671 1931 sub left_menu_entry {1932 local($secnum, $entry) = @_;1933 local($_);1934 local($href, $descr, $oltype,$value);1935 1936 $_ = $secnum;1937 $value = $secnum;1938 if (/[A-Z]/) {1939 $oltype = "<LI TYPE=A";1940 $value = $append2num{$secnum};1941 } else {1942 $oltype = "<LI";1943 }1944 $_ = $entry;1945 print "===>($secnum): $entry\n";1946 #s/^[0-9A-Z.]+ //;1947 $_ = $entry;1948 &normalise_node($_);1949 $href = $node2href{$_};1950 if ($href) {1951 $descr =~ s/^\s+//;1952 $descr = ": $descr" if $descr;1953 push(@menu_lines, "$oltype VALUE=$value>" . &anchor('', $href, "Main", $entry) . "$descr\n");1954 push(@menu_lines, "<P>\n");1955 } else {1956 warn "$ERROR Undefined node ($node): $_";1957 }1958 }1959 1960 2672 sub menu_entry { 1961 2673 local($entry, $node, $descr) = @_; … … 1966 2678 if ($href) { 1967 2679 $descr =~ s/^\s+//; 1968 $descr = ": $descr" if $descr; 1969 push(@lines2, "<LI>" . &anchor('', $href, '', $entry) . "$descr\n"); 2680 if ($T2H_NUMBER_SECTIONS) 2681 { 2682 $entry = $node2sec{$entry} if ! $descr && $node2sec{$entry}; 2683 push(@lines2, 2684 '<TR><TD ALIGN="left">' . 2685 &t2h_anchor('', $href, $entry) . 2686 '</TD><TD ALIGN="left">' . $descr . "</TD><TR>\n"); 2687 } 2688 else 2689 { 2690 push(@lines2, "<LI>" . &t2h_anchor('', $href, $entry) . ": $descr\n"); 2691 } 1970 2692 } else { 1971 2693 warn "$ERROR Undefined node ($node): $_"; … … 1973 2695 } 1974 2696 2697 sub do_ctrl { "^$_[0]" } 2698 1975 2699 sub do_email { 1976 my($address,$text); 1977 ($address,$text) = split(/,/, "$_[0]"); 1978 $text =~ s/(^\s+)|(\s+$)//; # trim leading and trailing white space 1979 $text = $address unless $text; 1980 &anchor('', "mailto:${address}", '', "<TT>${text}</TT>") 1981 } 1982 1983 sub do_image { 1984 my($base,$width,$height,$image); 1985 ($base,$width,$height) = split(/,/,"$_[0]"); 1986 if ( -f "${base}.jpg" ) { 1987 $image = "${base}.jpg"; 1988 } elsif ( -f "${base}.gif" ) { 1989 $image = "${base}.gif"; 1990 } else { 1991 $image = $base; 1992 warn "$ERROR image not found for ($base): $_"; 1993 } 1994 "<BR><IMG SRC=\"${image}\"><BR>"; 2700 local($addr, $text) = split(/,\s*/, $_[0]); 2701 2702 $text = $addr unless $text; 2703 &t2h_anchor('', "mailto:$addr", $text); 2704 } 2705 2706 sub do_sc 2707 { 2708 # l2h does this much better 2709 return &l2h_ToLatex("{\\sc ".&unprotect_html($_[0])."}") if ($T2H_L2H); 2710 return "\U$_[0]\E"; 2711 } 2712 2713 sub do_math 2714 { 2715 return &l2h_ToLatex("\$".&unprotect_html($_[0])."\$") if ($T2H_L2H); 2716 return "<EM>".$text."</EM>"; 1995 2717 } 1996 2718 1997 2719 sub do_uref { 1998 my($href,$text); 1999 ($href,$text) = split(/,/,"$_[0]"); 2000 $text =~ s/(^\s+)|(\s+$)//; # trim leading and trailing white space 2001 $text = $href unless $text; 2002 # args to anchor() are: ($name, $href, $text, $newline) 2003 &anchor('', "$href", '', "<TT>$text</TT>") 2004 } 2005 2006 sub do_url { 2007 my($address,$text); 2008 ($address,$text) = split(/,/, "$_[0]"); 2009 $text =~ s/(^\s+)|(\s+$)//; # trim leading and trailing white space 2010 $text = $address unless $text; 2011 $address =~ s/­//g; 2012 &anchor('', "${address}", '_parent', "<TT>${text}</TT>") 2013 } 2014 2015 sub do_ctrl { "^$_[0]" } 2016 2017 sub do_sc { "\U$_[0]\E" } 2720 local($url, $text, $only_text) = split(/,\s*/, $_[0]); 2721 2722 $text = $only_text if $only_text; 2723 $text = $url unless $text; 2724 &t2h_anchor('', $url, $text); 2725 } 2726 2727 sub do_url { &t2h_anchor('', $_[0], $_[0]) } 2018 2728 2019 2729 sub apply_style { … … 2022 2732 2023 2733 $style = $style_map{$texi_style}; 2024 if (defined($style)) { # known style2025 if ($style =~ /^\"/) { # add quotes2026 $style = $';2027 $text = "\`$text\'";2028 }2029 if ($style =~ /^\&/) { # custom2030 $style = $';2031 $text = &$style($text);2032 } elsif ($style) { # good style2033 $text = "<$style>$text</$style>";2034 } else { # no style2035 }2036 } else { # unknown style2037 $text = undef;2038 }2039 return($text);2040 }2041 2042 sub apply_l_style {2043 local($texi_style, $text) = @_;2044 local($style);2045 2046 $style = $style_l_map{$texi_style};2047 2734 if (defined($style)) { # known style 2048 2735 if ($style =~ /^\"/) { # add quotes … … 2093 2780 } 2094 2781 2095 sub anchor {2096 local($name, $href, $t arget, $text, $newline) = @_;2782 sub t2h_anchor { 2783 local($name, $href, $text, $newline) = @_; 2097 2784 local($result); 2098 2785 … … 2100 2787 $result .= " NAME=\"$name\"" if $name; 2101 2788 $result .= " HREF=\"$href\"" if $href; 2102 $result .= " TARGET=\"$target\"" if $target;2103 2789 $result .= ">$text</A>"; 2104 2790 $result .= "\n" if $newline; … … 2109 2795 local(@MoY, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); 2110 2796 2111 @MoY = ('January', 'Feb uary', 'March', 'April', 'May', 'June',2797 @MoY = ('January', 'February', 'March', 'April', 'May', 'June', 2112 2798 'July', 'August', 'September', 'October', 'November', 'December'); 2113 2799 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); 2114 2800 $year += ($year < 70) ? 2000 : 1900; 2115 return("$mday $MoY[$mon] $year"); 2116 } 2117 2118 sub doc_name { 2801 # obachman: Let's do it as the Americans do 2802 return("$MoY[$mon], $mday $year"); 2803 } 2804 2805 sub doc_href { 2119 2806 local($num) = @_; 2120 2807 2121 return("${docu_name}_$num.html"); 2808 return("${docu_name}_$num.$docu_ext"); 2809 } 2810 2811 sub sec_href 2812 { 2813 return $node2href{$sec2node{$_[0]}}; 2122 2814 } 2123 2815 2124 2816 sub next_doc { 2125 $docu_doc = &doc_ name(++$doc_num);2126 } 2127 2128 sub print{2129 local(*lines, $fh) = @_;2817 $docu_doc = &doc_href(++$doc_num); 2818 } 2819 2820 sub t2h_print_lines { 2821 my ($fh, $lines) = @_; 2130 2822 local($_); 2131 2132 while (@lines) { 2133 $_ = shift(@lines); 2823 $lines = $T2H_THIS_SECTION unless $lines; 2824 my $cnt = 0; 2825 for (@$lines) 2826 { 2827 $_ = l2h_FromHtml($_) if ($T2H_L2H); 2134 2828 if (/^$PROTECTTAG/o) { 2135 2829 $_ = $tag2pro{$_}; … … 2138 2832 } 2139 2833 print $fh $_; 2140 } 2141 } 2142 2143 sub print_ruler { 2144 print FILE "<P><HR><P>\n"; 2145 } 2146 2147 sub print_frame { 2148 print FILE <<EOT; 2149 <FRAMESET COLS="20%,*" BORDER=0> 2150 <FRAME SRC="$docu_left" NAME="Links"> 2151 <FRAME SRC="$_[0]" NAME="Main"> 2152 </FRAMESET> 2153 2154 EOT 2155 } 2156 2157 sub print_header { 2158 local($_); 2159 2160 $links = $_[1]; 2161 $is_frame = $_[2]; 2162 # clean the title 2163 $_ = &remove_style($_[0]); 2164 &unprotect_texi; 2165 # print the header 2166 if ($doctype eq 'html2') { 2167 print FILE $html2_doctype; # Wrong if any multitable used 2168 } elsif ($doctype) { 2169 print FILE $doctype; 2170 } 2171 print FILE <<EOT; 2172 <HTML> 2173 <HEAD> 2174 $header 2175 <TITLE>$_</TITLE> 2176 $links 2177 </HEAD> 2178 EOT 2179 if(!$is_frame) { print FILE "<BODY background=\"$IMG_RIGHT\">\n"; } 2180 } 2181 2182 sub print_toplevel_header { 2183 local($_); 2184 2185 &print_header ($_[0], "", 0); 2186 print FILE $full_title; 2187 if ($value{'_subtitle'}) { 2188 $value{'_subtitle'} =~ s/\n+$//; 2189 foreach (split(/\n/, $value{'_subtitle'})) { 2190 $_ = &substitute_style($_); 2191 &unprotect_texi; 2192 print FILE "<H2>$_</H2>\n"; 2193 } 2194 } 2195 if ($value{'_author'}) { 2196 $value{'_author'} =~ s/\n+$//; 2197 foreach (split(/\n/, $value{'_author'})) { 2198 $_ = &substitute_style($_); 2199 &unprotect_texi; 2200 # s/[\w.-]+\@[\w.-]+/<A HREF="mailto:$&">$&<\/A>/g; 2201 print FILE "<ADDRESS>$_</ADDRESS>\n"; 2202 } 2203 } 2204 print FILE "<P>\n"; 2205 } 2206 2207 sub print_footer { 2208 print FILE <<EOT; 2209 </BODY> 2210 </HTML> 2211 EOT 2212 } 2213 2214 sub print_toplevel_footer { 2215 &print_ruler; 2216 print FILE <<EOT; 2217 <H6>This document was generated on $TODAY using the 2218 <A HREF=\"$HOMEPAGE\" TARGET=\"_parent\">texi2html</A> 2219 translator version 1.51a.</H6> 2220 <H6>Modified by the Singular-Team 19.6.1998</H6> 2221 EOT 2222 &print_footer; 2834 $cnt += split(/\W*\s+\W*/); 2835 } 2836 return $cnt; 2223 2837 } 2224 2838 … … 2265 2879 } 2266 2880 2881 sub t2h_print_label 2882 { 2883 my $fh = shift; 2884 my $href = shift || $T2H_HREF{This}; 2885 $href =~ s/.*#(.*)$/$1/; 2886 print $fh qq{<A NAME="$href"></A>\n}; 2887 } 2888 2267 2889 ############################################################################## 2268 2890 … … 2275 2897 .nr % 0 \" start at page 1 2276 2898 '; __END__ ############# From here on it's a standard manual page ############ 2277 .TH TEXI2HTML 1 "0 8/12/97"2899 .TH TEXI2HTML 1 "01/05/98" 2278 2900 .AT 3 2279 2901 .SH NAME 2280 2902 texi2html \- a Texinfo to HTML converter 2281 2903 .SH SYNOPSIS 2282 .B texi2html [ OPTION]... FILE2904 .B texi2html [options] file 2283 2905 .PP 2284 .B texi2html -check [-verbose] FILE...2906 .B texi2html -check [-verbose] files 2285 2907 .SH DESCRIPTION 2286 2908 .I Texi2html … … 2295 2917 .PP 2296 2918 .I Texi2html 2919 may furthermore use latex2html to generate HTML (code and/or images) for @math 2920 and @iftex tags (see the 2921 .B \-l2h 2922 option). 2923 .PP 2924 .I Texi2html 2297 2925 creates several files depending on the contents of the Texinfo file and on 2298 2926 the chosen options (see FILES). … … 2301 2929 .I texi2html 2302 2930 are closer to TeX than to Info, that's why 2303 .I texi2html2304 converts @iftex sections and not @ifinfo ones by default. You can reverse2305 this with the \-expandinfo option.2306 2931 .SH OPTIONS 2307 2932 .TP 12 … … 2312 2937 to find the Texinfo commands that have been left in the HTML file. 2313 2938 .TP 2314 .B \-expand info2315 Expand @ifinfo sections, not @iftex ones.2939 .B \-expand info|tex|none 2940 Expand @ifinfo, or @iftex, or sections (default: info) 2316 2941 .TP 2317 2942 .B \-glossary … … 2320 2945 .TP 2321 2946 .B \-invisible \fIname\fP 2322 Use \fIname\fP to create invisible destination anchors for index links. This is a workaround 2323 for a known bug of many WWW browsers, including xmosaic. 2947 Use \fIname\fP to create invisible destination anchors for index links 2948 (you can for instance use the invisible.xbm file shipped with this program). 2949 This is a workaround for a known bug of many WWW browsers, including netscape. 2324 2950 .TP 2325 2951 .B \-I \fIdir\fP … … 2341 2967 .B \-split_node 2342 2968 Split the output into several HTML files (one per node). 2969 .TP 2970 .B \-l2h 2971 Use latex2html for content of @math and @tex tags. Content must be such that 2972 both, latex and tex, can translate it correctly. I.e., no tex-only constructs 2973 must be used. 2974 .TP 2975 .B \-l2h_latex2html \fIprog\fP 2976 Use \fIprog\fP as latex2html program (default \fIlatex2html\fP). 2977 Program must be executable. 2978 .TP 2979 .B \-l2h_init \fIfile\fP 2980 Use \fIfile\fP as latex2html init file. \fIfile\fP should be used to specify in which way latex2html handles mathematical expressions and formulas. 2981 2982 Note that latex2html locates 2983 (and uses) init-files in the following order (provided they exist): 2984 (1) global init file (usually in latex2html source dir) 2985 (2) $HOME/.latex2html_init 2986 (3) ./.latex2html_init 2987 (4) init file given on command line. 2988 .TP 2989 .B \-l2h_dir \fIdir\fP 2990 Use \fIdir\fP as tmp dir for latex2html. This directory (resp. its path) 2991 must not contain a dot (i.e., a "."). 2992 .TP 2993 .B \-l2h_clean 2994 remove all intermediate files generated by latex2html (prevents caching!) 2995 .TP 2996 .B \-l2h_skip 2997 Do not really run latex2html. Use (kept) files of previous runs, instead. 2343 2998 .TP 2344 2999 .B \-usage … … 2363 3018 .B foo_foot.html 2364 3019 The footnotes (if any). 3020 .TP 3021 .B foo_l2h_img* 3022 Images generated by latex2html (if any). 2365 3023 .PP 2366 3024 When used with the … … 2368 3026 option, it creates several files (one per chapter or node), named 2369 3027 .B foo_n.html 2370 (n being the ind iceof the chapter or node), instead of the single3028 (n being the index of the chapter or node), instead of the single 2371 3029 .B foo.html 2372 3030 file. … … 2381 3039 .SH ADDITIONAL COMMANDS 2382 3040 .I texi2html 2383 implements the following non-Texinfo commands :3041 implements the following non-Texinfo commands (maybe they are in Texinfo now...): 2384 3042 .TP 16 2385 .B @ ifhtml3043 .B @html 2386 3044 This indicates the start of an HTML section, this section will passed through 2387 without any mod ofication.3045 without any modification. 2388 3046 .TP 2389 .B @end ifhtml2390 This ind cates the end of an HTML section.3047 .B @end html 3048 This indicates the end of an HTML section. 2391 3049 .SH VERSION 2392 This is \fItexi2html\fP version 1.5 4, 1998-01-173050 This is \fItexi2html\fP version 1.56k, 1999-02-20. 2393 3051 .PP 2394 The latest version of \fItexi2html\fP can be found at 2395 ftp://ftp.cs.umb.edu/pub/tex/texi2html 3052 The latest version of \fItexi2html\fP and \fIlatex22html\fPcan be found in WWW, cf. URLs 3053 http://wwwinfo.cern.ch/dis/texi2html/ 3054 .br 3055 http://texinfo.org/texi2html/ 3056 .br 3057 http://www-dsed.llnl.gov/files/programs/unix/latex2html 3058 .br 2396 3059 .SH AUTHOR 2397 The main author is Lionel Cons, CERN CN/DCI/UWS. 2398 This version is maintained at ftp://ftp.cs.umb.edu/pub/tex/texi2html 2399 by kb@cs.umb.edu. 3060 The main author is Lionel Cons, CERN IT/DIS/OSE, Lionel.Cons@cern.ch. 2400 3061 Many other people around the net contributed to this program. 2401 3062 .SH COPYRIGHT … … 2412 3073 World Wide Web (WWW). 2413 3074 .SH BUGS 2414 This program does not understand all Texinfo commands (yet). 3075 This program does not understand all Texinfo commands (yet). A row of 3076 a mutlicolumn table has to be in one line. 2415 3077 .PP 2416 3078 TeX specific commands (normally enclosed in @iftex) will be 2417 passed u 3079 passed over unmodified, unless latex2html is enabled. 3080 .ex
Note: See TracChangeset
for help on using the changeset viewer.