1# $Id: frame.pl,v 1.12 2001/04/13 22:30:25 RRM Exp $ 2# frame.pl - Ross Moore (ross@mpce.mq.edu.au) 30.11.98 3# 4# developed for the W3C HTML 4.0 Frameset DTD, 5# $FRAME_DOCTYPE = '-//W3C//DTD HTML 4.0 Frameset'; 6# $PUBLIC_REF = 'http://www.w3.org/TR/REC-html40/frameset.dtd'; 7# 8# extending work done earlier, as: 9# 10# frames.perl - Martin Wilck (martin@tropos.de) 22.5.96 11# 12# Extension to the LaTeX2HTML program by Nikos Drakos 13# 14# Enable LaTeX2HTML to build pages using frames 15# (HTML extension for browsers that understand frames) 16# 17# Change Log: 18# jcl = Jens Lippmann <lippmann@rgb.informatik.tu-darmstadt.de> 19# mwk = Martin Wilck 20# rrm = Ross Moore <ross@maths.mq.edu.au> 21# 22# $Log: frame.pl,v $ 23# Revision 1.12 2001/04/13 22:30:25 RRM 24# -- wrong color on Index page; thanks Ingo de Boer, for the report 25# 26# Revision 1.11 2000/09/01 09:43:38 RRM 27# -- include an easier call to &make_frame_help for the Help frame. 28# -- changed default of 'TEXT' to 'MAIN' for \framecolor and \frameoptions 29# 30# Revision 1.10 1999/11/03 10:14:21 RRM 31# -- changed "Refresh" button to be "Expand", as more indicative 32# of the action performed 33# 34# Revision 1.9 1999/09/16 08:43:27 RRM 35# -- fixed incorrect use of undef 36# thanks to Jarkko Hietaniemi for reporting those errors. 37# 38# Revision 1.8 1999/09/09 00:30:59 MRO 39# 40# 41# -- removed all *_ where possible 42# 43# Revision 1.7 1999/07/10 12:39:06 RRM 44# -- fixed the target frame for links from the mini-toc. 45# -- removed redundant definition of &add_frame_toc 46# 47# Revision 1.6 1999/06/03 03:45:57 RRM 48# -- changed email address: ross@maths.mq.edu.au 49# -- set $NO_FRAME_HELP when there are no special views needed. 50# 51# Revision 1.5 1999/04/09 18:19:36 JCL 52# changed my e-Mail address 53# 54# Revision 1.4 1999/03/26 11:34:14 RRM 55# -- updated to recover the missing 'Next' buttons 56# 57# Revision 1.3 1999/03/03 10:51:40 RRM 58# -- use variables $MAIN_VMARGIN and $MAIN_HMARGIN for the values of 59# attributes MARGINHEIGHT and MARGINWIDTH of the main <FRAME> tag. 60# -- when $NOFRAMES is set, prevent the navigation buttons from appearing 61# in more than one frame. Thanks Uli, for noticing this. 62# Also stop <HEAD> and <LINK> tags being repeated. 63# 64# Revision 1.2 1999/02/24 11:02:36 RRM 65# -- include a margin with the main body frame 66# -- define a style name 'TOC' for easy application of styles in the 67# contents frame 68# -- get correct target for links to images within the contents frame 69# 70# Revision 1.1 1998/12/02 10:26:35 RRM 71# new extension: frame.pl by RRM 72# 73# replaces the frames.perl package 74# -- implements frames, via the W3C's DTD: "HTML 4.0 Frameset" 75# -- makes minimal use of the Netscape <FRAME border=...> attribute 76# -- rebinds many subroutines from latex2html and other modules 77# uses an extra indirection, to minimize recoding 78# 79 80 81# Different frames are used for the navigation panel buttons, 82# the main text field and the footnotes (if any). 83# 84# The package redefines the following subroutines of LaTeX2HTML: 85# - process_footnote 86# - post_process 87# - make_footnotes 88# - make_file 89# - make_head_and_body 90# 91# This file should be put in your LATEX2HTMLVERSIONS directory. 92# 93# The package will be loaded if the following perl code: 94############################################################################### 95# if ($FRAMES) { 96# foreach $dir (split(/:/,$LATEX2HTMLVERSIONS)) { 97# print $dir; 98# if (-f ($_ = "$dir/frame.pl")) { 99# print "Loading $_...\n"; 100# require ($_); 101# }; 102# } ; 103# }; 104############################################################################### 105# is inserted into the latex2html script (uncommented, of course) 106# (I insert it directly before the call to &driver) 107# and $FRAMES is set to 1 in one of your configuration files. 108 109package main; 110 111$html_frame_version = 3.0 ; 112$FRAME_DOCTYPE = '-//W3C//DTD HTML 4.0 Frameset' 113 unless ($FRAME_DOCTYPE); 114 115if ($HTML_VERSION >= 4.0) { 116# $FRAME_DOCTYPE = '-//W3C//DTD HTML 4.0 Frameset'; 117# $PUBLIC_REF = 'http://www.w3.org/TR/REC-html40/frameset.dtd'; 118 $frame_implementation = "W3C"; 119 $html_frame_version = 4.0 ; 120} else { 121 $frame_implementation = "Netscape" 122 unless ($frame_implementation); 123} 124if ($NO_BORDER) { $NO_BORDER = '' } 125else { 126 $NO_BORDER = (($HTML_STRICT || !$NETSCAPE_HTML) ? '' : ' BORDER=0') 127} 128$HELP_BORDER = ' BORDER=0' unless (defined $HELP_BORDER); 129$FHELP_SIZE = 20 unless $FHELP_SIZE; 130 131$NO_ROBOTS = "\n<META NAME=\"Robots\" CONTENT=\"nofollow\">" 132 unless (defined $NO_ROBOTS); 133 134$REFRESH_BUTTON = '<SUP>Expand</SUP>' unless $REFRESH_BUTTON; 135 136$BACKGROUND_DIR = "http://home.netscape.com/assist/net_sites/bg/"; 137$BACKGROUND_IMAGE = "stucco/yellow_stucco.gif"; 138 139@Netscape_colorset = ("main",'1',"alink",'1',"link",'2',"vlink",'3',"bgcolor",'4'); 140@Netscape_colorset_star = ("main",'4',"alink",'4',"link",'3',"vlink",'2',"bgcolor",'1'); 141@Netscape_colorset_star_star = ("main",'4',"alink",'1',"link",'4',"vlink",'3',"bgcolor",'2'); 142 143############################################################################### 144# PACKAGE OPTIONS - set these in one of your init files ! 145############################################################################### 146# Set $NOFRAMES=1 if you want a <noframes>...</noframes> section to be 147# inserted in your HTML documents, making the contents accessible 148# also for browsers that can't handle frames. 149# If $NOFRAMES is not set, these browsers will only find a short message 150# informing the user that he should use another browser. 151$NOFRAMES = 0 unless defined ($NOFRAMES); 152#$NOFRAMES = 1; 153 154# The height of the top frame containing the navigation buttons 155$NAVIGATION_HEIGHT = 36 unless $NAVIGATION_HEIGHT; 156 157# The height of the bottom frame containing footnotes (if there are any 158# on the current page) 159$FOOTNOTE_HEIGHT = 60 unless $FOOTNOTE_HEIGHT; 160 161$TOC_WIDTH = 150 unless $TOC_WIDTH; 162$IDX_WIDTH = 200 unless $IDX_WIDTH; 163 164# These are optional widths 165#$CONTENTS_TABLE_WIDTH = 300 unless $CONTENTS_TABLE_WIDTH; 166#$INDEX_TABLE_WIDTH = 350 unless $INDEX_TABLE_WIDTH; 167 168# protect special characters in user-supplied code 169if ($CONTENTS_BANNER =~ /[%~\$]/) { 170 $CONTENTS_BANNER =~ s/\%/;SPMpct;/g; 171 $CONTENTS_BANNER =~ s/~/;SPMtilde;/g; 172 $CONTENTS_BANNER =~ s/\$/;SPMdollar;/g; 173} 174if ($CONTENTS_FOOTER =~ /[%~\$]/) { 175 $CONTENTS_FOOTER =~ s/\%/;SPMpct;/g; 176 $CONTENTS_FOOTER =~ s/~/;SPMtilde;/g; 177 $CONTENTS_FOOTER =~ s/\$/;SPMdollar;/g; 178} 179if ($INDEX_BANNER =~ /[%~\$]/) { 180 $INDEX_BANNER =~ s/\%/;SPMpct;/g; 181 $INDEX_BANNER =~ s/~/;SPMtilde;/g; 182 $INDEX_BANNER =~ s/\$/;SPMdollar;/g; 183} 184if ($INDEX_FOOTER =~ /[%~\$]/) { 185 $INDEX_FOOTER =~ s/\%/;SPMpct;/g; 186 $INDEX_FOOTER =~ s/~/;SPMtilde;/g; 187 $INDEX_FOOTER =~ s/\$/;SPMdollar;/g; 188} 189 190# Additional feature: Choose colors and other options for the different 191# frames. The layout strings will be inserted into the <BODY ...> declaration 192# of the HTML files. 193# WARNING: The default colors set here may not be what you expect or like! 194# 195# Main Body window 196$MAIN_VMARGIN = 3 unless (defined $MAIN_VMARGIN); 197$MAIN_HMARGIN = 5 unless (defined $MAIN_HMARGIN); 198 199$MAIN_COLOR = "bgcolor=\"#ffffff\" text=\"#000000\" link=\"#9944EE\" vlink=\"#0000ff\" alink=\"#00ff00\"" 200 unless $MAIN_COLOR; 201# 202## Main window (seems to have no effect in Netscape) 203#if (!$NOFRAMES) { $MAIN_COLOR = "bgcolor=\"#000000\" text=\"#ffffff\"" unless $MAIN_COLOR;} 204#else { $MAIN_COLOR = "bgcolor=\"#ffffff\" text=\"#000000\"" unless $MAIN_COLOR; } 205# 206# Navigation window 207$NAVIG_COLOR = "bgcolor=\"#ffeee0\" text=\"#000000\" link=\"#9944EE\" vlink=\"#FF0000\" alink=\"#00ff00\"" 208 unless $NAVIG_COLOR; 209# 210# Footnote window 211$FOOT_COLOR = "bgcolor=\"#eeeee0\" text=\"#000000\" link=\"#9944EE\" vlink=\"#0000ff\" alink=\"#00ff00\"" 212 unless $FOOT_COLOR; 213 214# Table-of-Contents window # D0F000 215$TOC_COLOR = "bgcolor=\"#8080C0\" text=\"#ffeee0\" link=\"#eeeee0\" vlink=\"#eeeee0\" alink=\"#00ff00\"" 216 unless $TOC_COLOR; 217 218# Index window, same as Text window 219$IDX_COLOR = $MAIN_COLOR; 220 221 222# extra help-frame, above the navigation panel, unless $NO_FRAME_HELP 223if ($NO_FRAME_HELP) { $FRAME_HELP = $FHELP_FILE = '' } 224else { $FHELP_FILE = "fhelp".$EXTN unless ($FHELP_FILE) } 225 226sub make_frame_help { 227 print "\n *** making frame-help file $NO_FRAME_HELP ..."; 228 if (!($idxfile || $tocfile)||$NO_FRAME_HELP) { 229 print " ... cancelled ***\n"; 230 $help_file_done = 1; 231 $NO_FRAME_HELP = 1; 232 return(); 233 } 234 $FRAME_HELP = join('', "Click " 235 , ($tocfile ? "<STRONG>Contents</STRONG>" : '') 236 , (($idxfile && $tocfile) ? " or " : '') 237 , ($idxfile ? "<STRONG>Index</STRONG>" : '') 238 , " for extra navigation, hidden by <STRONG>Expand</STRONG>." 239 ) unless ($FRAME_HELP); 240 if (!(-f $FHELP_FILE)) { 241 open(FHELP, ">$FHELP_FILE"); 242 local($fhelp_string) = join("\n" 243 , '<HTML>', '<HEAD>', '<TITLE>'.$fhelp_title.'</TITLE>' 244 , '</HEAD>', '<BODY '.$NAVIG_COLOR.'>' 245 , '<DIV ALIGN="RIGHT"><SMALL><SMALL>'.$FRAME_HELP.'</SMALL></SMALL>' 246 , '</DIV></BODY>', '</HTML>', '' 247 ); 248 &lowercase_tags($fhelp_string) if $LOWER_CASE_TAGS; 249 print FHELP $fhelp_string; 250 undef $fhelp_string; 251 close FHELP; 252 print " ... done: $FHELP_FILE ***\n"; 253 } 254 $help_file_done = 1; 255} 256 257 258 259sub replace_frame_markers { 260 # Modifies $_ 261 local($frame,$frame_data)=("none","none"); 262 s/$frame_mark<#(.*)#><#(.*)#>/&set_frame_data("$1","$2")/geo; 263 @_[0]; 264} 265 266sub set_frame_data { 267 local($frame,$frame_data) = @_; 268 $frame_data =~ s/,$//o; $frame_data =~ s/,/ /g; 269 ${$frame} = "$frame_data"; 270 ''; 271} 272 273 274# Implement some use-macros. 275# The background can be set only by \frameoptions 276# Colors can be set by \framecolor or \frameoptions 277 278sub do_cmd_frameoptions { 279 local($_) = @_; 280 local($frame_data,$bkgrnd_str)=('',''); 281 local ($frame,$dum)=&get_next_optional_argument; 282 if (!($dum)) {$frame = "MAIN";} 283 $frame_data = &missing_braces() unless ( 284 (s/$next_pair_pr_rx/$frame_data = $2;''/eo) 285 ||(s/$next_pair_rx/$frame_data = $2;''/eo)); 286 local($rest) = $_; 287 $frame_data =~ s/background[\s\t]*\=[\s\t]*([\w\W]*)/ 288 if (!($1)) { "background=$BACKGROUND_DIR$BACKGROUND_IMAGE"} 289 else { "background=${BACKGROUND_DIR}$1" }/eo; 290 if (!($frame_data)) 291 { print STDERR "\nno frame options, $frame unchanged\n"; return $_;} 292 join('',&apply_frame_options(1,$frame,$frame_data),$rest); 293} 294 295sub do_cmd_framecolor { 296 local($_) = @_; 297 local($frame,$frame_data,$frame_test); 298 $frame = &missing_braces() unless ( 299 (s/$next_pair_pr_rx/$frame = $2;''/eo) 300 ||(s/$next_pair_rx/$frame = $2;''/eo)); 301 if (!$frame) 302 { print STDERR "\nno FRAME specified\n"; return $_;} 303 eval { $frame_test = ${$frame."_COLOR"} }; 304 if (!$frame_test) 305 { print STDERR "\nthere is no frame $frame\n"; 306 (s/$next_pair_pr_rx//o)||(s/$next_pair_rx//o); 307 return $_; 308 } 309 $frame_data = &missing_braces() unless ( 310 (s/$next_pair_pr_rx/$frame_data = $2;''/eo) 311 ||(s/$next_pair_rx/$frame_data = $2;''/eo)); 312 local($rest) = $_; 313 if (!$frame_data) 314 { print STDERR "\nno frame options, $frame unchanged\n"; return $_;} 315 join('',&apply_frame_options(0,$frame,$frame_data),$rest); 316} 317 318 319# These are user-macros for imposing complete colorsets. 320 321sub do_cmd_frameColorSet { 322 &check_frame_colorset(0,$frame_implementation,$_[0]); 323} 324 325sub do_cmd_frameColorSetstar { 326 local($_)=@_; 327 if (s/^\*//o) { 328 &check_frame_colorset(2,$frame_implementation,$'); 329 } else { 330 &check_frame_colorset(1,$frame_implementation,$_[0]); 331 } 332} 333 334sub do_cmd_frameColorSetstarstar { 335 &check_frame_colorset(2,$frame_implementation,$_[0]); 336} 337 338sub check_frame_colorset { 339 local($reverse, $which, $_) = @_; 340 local($frame_data,$frame_test); 341 local($frame,$dum)=&get_next_optional_argument; 342 if (!($dum)) {$frame = 'MAIN';} 343 $frame_data = &missing_braces() unless ( 344 (s/$next_pair_pr_rx/$frame_data = $2;''/eo) 345 ||(s/$next_pair_rx/$frame_data = $2;''/eo)); 346 local($rest) = $'; 347 eval { $frame_test = ${$frame."_COLOR"} }; 348 if (!($frame_test)) 349 { print STDERR "\nthere is no frame $frame\n"; return($rest);} 350 if (!($frame_data)) 351 { print STDERR "\nno colorset specified, $frame unchanged\n"; return($rest);} 352 local($colorset); 353 if ($reverse == 0) {$colorset="${which}_colorset"} 354 elsif ($reverse == 1) {$colorset="${which}_colorset_star"} 355 elsif ($reverse == 2) {$colorset="${which}_colorset_star_star"} 356 else {$colorset="${which}_colorset"} 357 if (!(defined @$colorset)) 358 { print STDERR "\nframes for $which are not supported\n"; return($rest);} 359 local($frame_tmp)=$frame_data; 360 local($key, @values); 361 local($num) = $frame_tmp =~ s/,/,/g; 362 if (!($num > 0)) { 363 $framedata =~ s/^[\s\t\n]*//o; $framedata =~ s/[\s\t\n]*$//o; 364 local($cnt) = true; 365 $frame_str = ''; 366 foreach $key (@$colorset) { 367 if ($cnt) { $frame_str .= "$key="; } 368 else {$frame_str .= "$frame_data$key".","} 369 $cnt = !($cnt); 370 } 371 $frame_str =~ s/,$//o; 372 } else { 373 @values = split (',',$frame_tmp); 374 } 375 join('',&apply_frame_options(0,$frame,$frame_str),$rest); 376} 377 378 379sub apply_frame_options { 380 local($replace,$frame,$frame_data) = @_ ; 381 local($frame_tmp,$option_str, $option) = ('','',''); 382 local(@previous, @options, @settings, @keys, @done); 383 local(%options); 384 if (!($frame_mark)) { &initialise_frames() }; 385 $frame = $frame."_COLOR"; 386 $frame_tmp = $frame."_TMP"; 387 # if $replace=0, impose just the new values, 388 # else use existing settings, but replacing with the new values 389 if ($replace) { 390 $option_str = $${frame_tmp}; 391 if (!($option_str)) { 392 $option_str = $$frame; 393 $option_str =~ s/[\s\t\n]*$//o; 394 @previous = split(' ',$option_str); 395 } else { 396 $option_str =~ s/[\s\t\n]*$//o; 397 @previous = split(' ',$option_str); 398 } 399 # recover the existing settings; store in @options hash 400 foreach $option (@previous) { 401 $option =~ s/^[\s\t\n]*//o; $option =~ s/[\s\t\n]*$//o; 402 $_ = $option; s/[\s\t\n]*\=[\s\t\n]*//o; 403 if ($&) { $options{$`}=$'; } 404 } 405 @options = sort keysort @options; 406 } 407 # process the new values; storing directly into $option_str 408 @settings = split(',',$frame_data); 409 foreach $option (@settings) { 410 $option =~ s/^[\s\t\n]*//o; $option =~ s/[\s\t\n]*$//o; 411 $option =~ s/[\s\t\n]*\=[\s\t\n]*//o; 412 if ($&) { 413 if ($` eq "background") { 414 $options{$`}="\"$'\""; 415 } 416 elsif (defined &get_named_color) { 417 $options{$`}= "\"\#".&get_named_color($')."\""; 418 } else { 419 $options{$`}="\"$'\""; 420 } 421 } else {print STDERR "\nno value specifed for $frame option: $option\n";} 422 }; 423 # recover the new values from the @options hash 424 @keys = keys %options; # @keys = sort keysort @keys; 425 $option_str = ''; 426 foreach $option (@keys) { 427 $option_str .= "$option\=@options{$option} "; 428 } 429 # reassign to the $<frame>_COLOR_TMP variable 430 if ($STARTFRAMES) { 431 ${$frame_tmp} = $option_str; 432 } else { 433 ${$frame} = $option_str ; 434 } 435# Uncomment next line, for a diagnostic check: 436# print STDERR "\n$frame : $option_str\n"; 437 "$frame_mark<#$frame#><#$option_str#>"; 438} 439 440 441 442sub apply_framebody_options { 443 local($frame,$which,$value) = @_; 444 local($body,$option,%previous); 445 $frame = "${frame}_COLOR"; 446 $body = $$frame; 447 study $body; 448 $body =~ s/^\s*//o; $body =~ s/\s*$//o; 449 $body =~ s/\s*\=\s*/\=/g; $body =~ s/\s+/ /g; 450 @previous = split(' ',$body); 451 $body = ''; 452 foreach $option (@previous) { 453 $option =~ s/\=/\=/o; 454 if (lc($`) eq $which) { $body .= " $which=\#$value" } 455 else { $body .= " $`=$'" } 456 } 457 $$frame = $body; 458} 459 460# These override definitions in color.perl 461 462sub apply_frame_body_options{ 463 local($which,$value)=@_; 464 if ($which eq "background") { $which="bgcolor" }; 465 &apply_framebody_options("MAIN",$which,$value); 466} 467 468sub set_frame_section_color { 469 if ($next_section_color) { 470 &apply_framebody_options("MAIN","text","$next_section_color"); 471 } 472 if ($next_section_bkgnd_color) { 473 &apply_body_options("MAIN","bgcolor","$next_section_bkgnd_color"); 474 } 475} 476 477# frame-navigation string constants 478$frame_main_suffix = '_mn' unless $frame_main_suffix; 479$frame_body_suffix = '_ct' unless $frame_body_suffix; 480$frame_idx_suffix = '_id' unless $frame_idx_suffix; 481$frame_head_suffix = '_hd' unless $frame_head_suffix; 482$frame_toc_suffix = '_tf' unless $frame_toc_suffix; 483$frame_top_name = '_top'; 484$frame_main_name = 'main' unless $frame_main_name; 485$frame_body_name = 'contents' unless $frame_body_name; 486$frame_foot_name = 'footer' unless $frame_foot_name; 487$frame_toc_name = 'toc' unless $frame_toc_name; 488$frame_idx_name = 'index' unless $frame_idx_name; 489 490$FRAME_TOP = ' TARGET="'.$frame_top_name.'"'; 491$EXTN = $frame_main_suffix.$EXTN; 492 493$indexframe_mark = '<index_frame_mark>'; 494 495# Define the subroutine &frame_navigation_panel in your configuration files 496# if you don't like this definition (puts all the buttons, but only the 497# buttons, in the navigation frame). 498 499if (! defined &frame_navigation_panel) { 500 sub frame_navigation_panel { 501 "$NEXT $UP $PREVIOUS $CONTENTS $INDEX $CUSTOM_BUTTONS";};}; 502 503# HINT: You may want to comment out the buttons line ("$NEXT $UP ...") 504# in the definitions of &top_navigation_panel and &bot_navigation_panel 505# in your latex2html.config file if you use this package in order to 506# avoid the buttons showing up in the text window as well. If you do that, 507# the textual links will still be there. Alternatively, you can just set 508# $NO_NAVIGATION; in that case, no textual links will be there, but the 509# navigation window will remain. 510 511# Here comes the main routine of the package. It is invoked by the (changed) 512# subroutine post_process. It takes over the file handling that that 513# routine usually performed. Note that the implementation of frames takes 514# place just before the final versions of the files are written, so that 515# everything else LaTeX2html does will be preserved. 516 517sub make_frame_header { 518# Arguments: Title of the page, filename, and the whole contents of the file 519 local ($title,$file,$contents) = @_; 520# Get the contents of the navigation frame 521# (customizable subroutine &frame_navigation_panel !). 522 local ($navig) = &frame_navigation_panel; 523# This is the same as usual. Note that the navigation panels defined by 524# $top_navigation and $bot_navigation go into the text frame, 525# not into the navigation frame (see HINT above)! 526 local ($top_navigation) = &top_navigation_panel unless $NO_NAVIGATION; 527 local ($bot_navigation) = &bot_navigation_panel unless $NO_NAVIGATION; 528# Check if there is a reference to $footfile in the text (usually, a footnote 529# reference). 530# Besides, insert a "target="footer" tag into these references in order to 531# make them point to the footnote window. 532 local ($has_footref) = $contents =~ s/target="footer"/$&/iog; 533# if (($has_footref)&&(!$NO_FOOTNODE)) { 534 if (!$NO_FOOTNODE) { 535 local($footheight) = ($has_footref ? $FOOTNOTE_HEIGHT : '15pt'); 536 # If there are footnote refs: 3 frames 537 $frameset 538 = "<FRAMESET ROWS=\"$NAVIGATION_HEIGHT,*,$footheight\"" 539 . $NO_BORDER . '>'; 540 # The footnote frame is called "footer"; its contents come from $footfile. 541 $footframe = 542 "<FRAME SRC=\"$footfile\" NAME=\"footer\" SCROLLING=\"auto\">" 543 } else { 544 # Otherwise: no footnote frame required -> only 2 frames. 545 $frameset = "<FRAMESET ROWS=\"$NAVIGATION_HEIGHT,*\"" 546 . $NO_BORDER . '>'; 547 $footframe = ""; 548 } 549 550# 551# Construct filenames from main/help name "NAME.html": 552# Text page: "NAME_ct.html", 553# Navigation page: "NAME_hd.html". 554# Index frame page: "NAME_id.html". 555# Main page: "NAME_mn.html". 556# Help frame page: "NAME.html". 557# Contents frame page: "NAME_tf.html". 558 local ($navigfile,$mainfile,$mainfile,$contfile,$indexfile,$toc_framefile,$frame_def); 559 ($navigfile = $file) =~ s/($frame_main_suffix)?\.htm(l?)$/$frame_head_suffix.htm$2/; 560 ($contfile = $file) =~ s/($frame_main_suffix)?\.htm(l?)$/$frame_body_suffix.htm$2/; 561 ($indexfile = $file) =~ s/($frame_main_suffix)?\.htm(l?)$/$frame_idx_suffix.htm$2/; 562# ($mainfile = $file) =~ s/($frame_main_suffix)?\.htm(l?)$/.htm$2/; 563 ($mainfile = $file) =~ s/($frame_main_suffix)?\.htm(l?)$/.htm$2/; 564 ($toc_framefile = $file) =~ s/($frame_main_suffix)?\.htm(l?)$/$frame_toc_suffix.htm$2/; 565# This is more or less obsolete 566# (normally these titles will never be displayed). 567 local ($navigtitle)="Header of $title"; 568 local ($conttitle)="Contents of $title"; 569 570 local($idxfile) = $idxfile; 571# $idxfile =~ s/\Q$EXTN\E/$frame_body_suffix$&/ if ($idxfile); 572 $idxfile =~ s/($frame_main_suffix)?(\.html?)$/$frame_body_suffix$2/ if ($idxfile); 573 local($tocfile) = $tocfile; 574# $tocfile =~ s/\Q$EXTN\E/$frame_body_suffix$&/ if ($tocfile); 575 $tocfile =~ s/($frame_main_suffix)?(\.html?)$/$frame_body_suffix$2/ if ($tocfile); 576# 577# Try to open the four files 578 open (OUTFILE, ">$file") || die "Cannot open file $file $!"; 579 open (NAVIG,">$navigfile") || die "Cannot open file $navigfile $!"; 580 open (CONT,">$contfile") || die "Cannot open file $contfile $!"; 581 open (ENTRY,">$mainfile") || die "Cannot open file $mainfile $!"; 582# 583 local($main_frames) = join("\n", 584 , "<FRAME SRC=\"$navigfile\" SCROLLING=\"no\"" 585 . " FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0>", 586 , "<FRAME SRC=\"$contfile\" NAME=\"contents\" SCROLLING=\"auto\"" 587 . " FRAMEBORDER=1 MARGINHEIGHT=$MAIN_VMARGIN MARGINWIDTH=$MAIN_HMARGIN>" 588 ); 589 &make_frame_help() unless $help_file_done; 590 local($help_frames) = join('', "\n" 591 , '<FRAMESET ROWS="'.($NO_FRAME_HELP ? '100%' : $FHELP_SIZE).',*"' 592 . "$HELP_BORDER" .'>' 593 , ($NO_FRAME_HELP ? '' : "\n<FRAME SRC=\"$FHELP_FILE\" SCROLLING=\"no\"" 594 ."\n FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0>") 595 , "\n<FRAME SRC=\"$file\" NAME=\"$frame_main_name\" SCROLLING=\"no\"" 596 ." FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0>\n" 597 ); 598 local($refresh_link); 599 $refresh_link = join('', '<SMALL><A HREF="', $mainfile, '"' 600 , $FRAME_TOP . '>', $REFRESH_BUTTON, '</A></SMALL>') 601 unless $NO_FRAME_HELP ; 602 $helpframe_def = $help_frames.'<NOFRAMES>'; 603 604# Construct the "<framedef>...</framedef>" section for the top file. 605 $frame_def=join ("\n", $frameset, $main_frames, $footframe, '<NOFRAMES>'); 606 $_ = $contents; 607 &replace_frame_markers; 608 $contents = $_; 609# If $NOFRAMES is set, insert the whole text in the "<noframes>...</noframes>" 610# section. 611 local($noframe_contents, $noframe_flag); 612 if ($NOFRAMES) { 613 $noframes_flag = 1; 614 local ($flag) = (($BOTTOM_NAVIGATION || &auto_navigation) && 615 $bot_navigation); 616 if ($flag) { 617 $noframe_contents = join ("\n", 618 &make_head_and_body($title,$MAIN_COLOR,$frame_def) 619 , $top_navigation, $contents , $bot_navigation) 620 } else { 621 $noframe_contents = join ("\n", 622 &make_head_and_body($title,$MAIN_COLOR,$frame_def) 623 , $top_navigation, $contents ) 624 }; 625 $noframe_contents =~ /\s*<BODY[^>]*>/s; 626 $noframe_contents = $'; 627 } 628 local($no_frames) = ($NOFRAMES 629 ? $noframe_contents 630 : '<P>Sorry, this requires a browser that supports frames!<BR>'."\n" 631 .'Try <A HREF="'.$contfile.'">'.$contfile.'</A> instead.</P>' ); 632 undef $noframe_contents; undef $noframes_flag; 633# 634# Make the text page first. Note that &make_head_and_body has been altered 635# such that it accounts for the layout string; the last argument 636# (definitions that go between head and body) is empty. 637 638 local($after_contents) = "\n</BODY>\n</HTML>\n"; 639 if ($contfile eq $idxfile) { 640 $_ = &make_head_and_body($conttitle,$IDX_COLOR," "); 641 } elsif ($contfile eq $tocfile) { 642 $_ = &make_head_and_body($conttitle,$TOC_COLOR," "); 643 } else { 644 $_ = &make_head_and_body($conttitle,$MAIN_COLOR," "); 645 $after_contents = &make_address; 646 } 647# $_ = join ("\n", $_, $top_navigation, $contents); 648 $_ = join ("\n", $_, $contents); 649## local ($flag) = (($BOTTOM_NAVIGATION || &auto_navigation) && 650## $bot_navigation); 651## ... and bottom navigation panel. --- no need for this RRM. 652## $_ = join ("\n", $_, $bot_navigation) if $flag; 653# Do the usual post-processing. 654 &replace_markers; 655 &post_post_process if (defined &post_post_process); 656 $_ = join ("\n", $_, "<HR>", $after_contents); 657 &lowercase_tags($_) if $LOWER_CASE_TAGS; 658 print CONT $_; 659 close CONT; 660# 661# Now go on with the navigation file. 662 $navig =~ s/(TARGET=")$frame_top_name("><tex2html_(next|up|prev))(\w+)/$1$frame_main_name$2$4/g; 663 $_ = &make_head_and_body($navigtitle,$NAVIG_COLOR," "); 664 &reduce_frame_header($_); 665 if ($refresh_link) { 666 $_ = join ("\n", $_ 667 , '<TABLE WIDTH="100%">', '<TR><TD>'.$navig 668 , '</TD><TD ALIGN="RIGHT">' 669 , $refresh_link , '</TD></TR>' 670 , '</TABLE>' , "</BODY>\n</HTML>\n" ); 671 } else { 672 $_ .= "\n".$navig."</BODY>\n</HTML>\n"; 673 } 674 &replace_markers; 675 &post_post_process if (defined &post_post_process); 676 &lowercase_tags($_) if $LOWER_CASE_TAGS; 677 print NAVIG $_; 678 close NAVIG; 679# 680# Next, the main frame-set. 681# $frame_def goes between head and body 682# (third argument of &make_head_and_body). 683 $_ = join ("\n", &make_head_and_body($title,$MAIN_COLOR,$frame_def) 684 , $no_frames); 685 &reduce_frame_header($_); 686 # adjust the DOCTYPE of the Frameset page 687 local($savedRS) = $/; $/ = ''; 688 $_ =~ s/\Q$DOCTYPE\E/$FRAME_DOCTYPE/; 689 $/ = $savedRS; 690 &replace_markers; 691 &post_post_process if (defined &post_post_process); 692 $_ = join ("\n", $_, "<HR>", &make_noframe_address); 693 &lowercase_tags($_) if $LOWER_CASE_TAGS; 694 print OUTFILE $_; 695 close OUTFILE; 696 697# Now make the ENTRY frame file. 698 &make_frame_help() unless $help_file_done; 699 local ($flag) = (($BOTTOM_NAVIGATION || &auto_navigation) && 700 $bot_navigation); 701 $_ = join ("\n", 702 , &make_head_and_body($title,$NAVIG_COLOR, $helpframe_def) 703 , $top_navigation, $no_frames); 704 &reduce_frame_header($_); 705 # adjust the DOCTYPE of the Frameset page 706 local($savedRS) = $/; $/ = ''; 707 $_ =~ s/\Q$DOCTYPE\E/$FRAME_DOCTYPE/; 708 $/ = $savedRS; 709 &replace_markers; 710 &post_post_process if (defined &post_post_process); 711 $_ = join ("\n", $_, "<HR>", &make_noframe_address); 712 &lowercase_tags($_) if $LOWER_CASE_TAGS; 713 print ENTRY $_; 714 close ENTRY; 715 716# Now go on with the index-frame file. 717 local ($index_frameset, $indexframe); 718 if ($idxfile) { 719 open (INDX,">$indexfile") || die "Cannot open file $indexfile $!"; 720 $index_frameset = "<FRAMESET COLS=\"*,$IDX_WIDTH\"" 721 . (($STRICT_HTML || 722 ($INDEX_TABLE_WIDTH && $INDEX_TABLE_WIDTH > $IDX_WIDTH)) 723 ? '' : $NO_BORDER ) . '>'; 724 $indexframe = join("\n",'' 725 , "<FRAME SRC=\"$file\" NAME=\"$frame_main_name\" SCROLLING=\"no\">" 726 , "<FRAME SRC=\"$idxfile\" NAME=\"$frame_idx_name\" SCROLLING=\"auto\">" 727 , '<NOFRAMES>' 728 ); 729 730 $_ = &make_head_and_body($indexname, $IDX_COLOR, $index_frameset . $indexframe); 731 &reduce_frame_header($_); 732 # adjust the DOCTYPE of the Frameset page 733 local($savedRS) = $/; $/ = ''; 734 $_ =~ s/\Q$DOCTYPE\E/$FRAME_DOCTYPE/; 735 $/ = $savedRS; 736 $_ = join ("\n", $_ ,$no_frames, "</BODY>\n</NOFRAMES>\n</FRAMESET>\n</HTML>\n"); 737 &replace_markers; 738 &post_post_process if (defined &post_post_process); 739 &lowercase_tags($_) if $LOWER_CASE_TAGS; 740 print INDX $_; 741 close INDX; 742 } 743# Now go on with the toc-frame file. 744 local ($toc_frameset, $tocframe); 745 if ($tocfile) { 746 open (TOC,">$toc_framefile") || die "Cannot open file $toc_framefile $!"; 747 $toc_frameset = "<FRAMESET COLS=\"$TOC_WIDTH,*\"" 748 . (($STRICT_HTML || 749 ($CONTENTS_TABLE_WIDTH && $CONTENTS_TABLE_WIDTH > $TOC_WIDTH)) 750 ? '' : $NO_BORDER ) . '>'; 751 $tocframe = join("\n", '' 752 , "<FRAME SRC=\"$tocfile\" NAME=\"$frame_toc_name\" SCROLLING=\"auto\">" 753 , "<FRAME SRC=\"$file\" NAME=\"$frame_main_name\" SCROLLING=\"no\">" 754 , '<NOFRAMES>' 755 ); 756 757 $_ = &make_head_and_body($indexname, $MAIN_COLOR, $toc_frameset . $tocframe); 758 &reduce_frame_header($_); 759 # adjust the DOCTYPE of the Frameset page 760 local($savedRS) = $/; $/ = ''; 761 $_ =~ s/\Q$DOCTYPE\E/$FRAME_DOCTYPE/; 762 $/ = $savedRS; 763 $_ = join ("\n", $_ ,$no_frames, "</BODY>\n</NOFRAMES>\n</FRAMESET>\n</HTML>\n"); 764 &replace_markers; 765 &post_post_process if (defined &post_post_process); 766 &lowercase_tags($_) if $LOWER_CASE_TAGS; 767 print TOC $_; 768 close TOC; 769 } 770} 771 772sub reduce_frame_header { 773 # MRO: Use $_[0] instead of: local(*header) = @_; 774 $_[0] =~ s/<(META NAME|LINK)[^>]*>\s*//g; 775 $_[0] =~ s/$more_links_mark/$NO_ROBOTS\n$LATEX2HTML_META/g; 776 local($savedRS)=$/; $/ = ''; 777 $_[0] =~ s/\n{2;}/\n/sg; 778 $_[0] =~ s/\s$//s; 779 $_[0] =~ s!\s*(\n</HEAD>\n)\s*!$1!s; 780 $/ = $savedRS; 781} 782 783sub make_noframe_address { 784 local ($addr) = join("\n", &make_real_address(@_) 785 , '</NOFRAMES></FRAMESET>', '</HTML>', '' ); 786 &lowercase_tags($addr) if $LOWER_CASE_TAGS; 787 $addr; 788} 789 790# Altered: &make_href 791sub make_frame_href { 792 local($link, $text) = @_; 793 local($target) = $target; 794 $href_name++; 795 $text =~ s/<A .*><\/A>//go; 796 if ($text eq $link) { $text =~ s/~/~/g; } 797 $link =~ s/~/~/g; 798 # catch \url or \htmlurl 799 $link =~ s/\\(html)?url\s*(($O|$OP)\d+($C|$CP))([^<]*)\2/$5/; 800 $link =~ s:(<TT>)?<A [^>]*>([^<]*)</A>(</TT>)?(([^<]*)|$):$2$4:; 801 $text = &simplify($text); 802 if ($target eq $frame_body_name) { 803 $link =~ s/_..(\.html?)(\#[^#]*)?$/$frame_body_suffix$1$2/; 804# } elsif (!$target ||($target =~ /^notarget$/)) { 805 } elsif ($target =~ /^$frame_main_name$/) { 806 $link =~ s/_..(\.html?)(\#[^#]+)$/$frame_main_suffix$1$2/; 807 } 808 809 # show links to images within the 'contents' frame 810 if (($link =~ /\.(gif|jpe?g|png)$/i)&&(!$target)) { 811 $target = $frame_body_name; 812 } 813 814 if ($target) { 815 if ($target eq "notarget") { 816 "<A NAME=\"tex2html$href_name\" HREF=\"$link\">$text</A>"; 817 } else { 818 # use smaller text on the Contents page 819 $text = join('','<SMALL>',$text,'</SMALL>') if ($target =~ /^$frame_main_name$/); 820 "<A NAME=\"tex2html$href_name\" HREF=\"$link\" TARGET=\"$target\">$text</A>"; 821 } 822 } elsif (((defined $base_file)&&($link =~ /^\Q$base_file\E/)) 823 || ($CURRENT_FILE && ($link =~ /^\Q$CURRENT_FILE\E/))) { 824 #child-links to the same HTML page 825 $link =~ s/_..(\.html?)(\#[^#]*)?$/$frame_body_suffix$1$2/; 826 "<A NAME=\"tex2html$href_name\" HREF=\"$link\">$text</A>"; 827 } else { 828 "<A NAME=\"tex2html$href_name\" HREF=\"$link\"$FRAME_TOP>$text</A>"; 829 } 830} 831 832# Altered: &make_href_noexpand 833sub make_frame_href_noexpand { 834 local($link, $name, $text) = @_; 835 do {$name = "tex2html". $href_name++} unless $name; 836 $text =~ s/<A .*><\/A>//go; 837 #$link =~ s/~/$percent_mark . "7E"/geo; 838 if ($text eq $link) { $text =~ s/~/~/g; } 839 $link =~ s/~/~/g; 840 # catch \url or \htmlurl 841 $link =~ s/\\(html)?url\s*(($O|$OP)\d+($C|$CP))([^<]*)\2/$5/; 842 $link =~ s:(<TT>)?<A [^>]*>([^<]*)</A>(</TT>)?(([^<]*)|$):$2$4:; 843 if ($target) { 844 if ($target eq "notarget") { 845 "<A NAME=\"tex2html$href_name\" HREF=\"$link\">$text</A>"; 846 } else { 847 "<A NAME=\"tex2html$href_name\" HREF=\"$link\" TARGET=\"$target\">$text</A>"; 848 } 849 } else { 850 "<A NAME=\"tex2html$href_name\" HREF=\"$link\"$FRAME_TOP>$text</A>"; 851 } 852} 853 854# Altered: &make_named_href 855sub make_frame_named_href { 856 local($name, $link, $text) = @_; 857 local($namestr) = ''; 858 if ($name) { $namestr = " NAME=\"$name\"\n"; } 859 $text =~ s/<A .*><\/A>//go; 860 $text = &simplify($text); 861 if ($text eq $link) { $text =~ s/~/~/g; } 862 $link =~ s/~/~/g; 863 # catch \url or \htmlurl 864 $link =~ s/\\(html)?url\s*(($O|$OP)\d+($C|$CP))([^<]*)\2/$5/; 865 $link =~ s:(<TT>)?<A [^>]*>([^<]*)</A>(</TT>)?(([^<]*)|$):$2$4:; 866 if ($target eq $frame_body_name) { 867 $link =~ s/_..(\.html?)(\#[^#]*)?$/$frame_body_suffix$1$2/; 868 } elsif ($target =~ /^$frame_main_name$/) { 869 $link =~ s/_..(\.html?)(\#[^#]+)$/$frame_main_suffix$1$2/; 870 } 871 if ($target) { 872 if ($target eq "notarget") { 873 "<A$namestr HREF=\"$link\">$text</A>"; 874 } else { 875 "<A$namestr HREF=\"$link\" TARGET=\"$target\">$text</A>"; 876 } 877 } else { 878 "<A$namestr HREF=\"$link\"$FRAME_TOP>$text</A>"; 879 } 880} 881 882# Altered: &make_half_href 883sub make_frame_half_href { 884 local($link) = $_[0]; 885 $href_name++; 886 if ($target) { 887 if ($target eq "notarget") { 888 "<A NAME=\"tex2html$name\" HREF=\"$link\">"; 889 } else { 890 "<A NAME=\"tex2html$name\" HREF=\"$link\" TARGET=\"$target\">"; 891 } 892 } else { 893 "<A NAME=\"tex2html$name\" HREF=\"$link\"$FRAME_TOP>"; 894 } 895} 896 897# should use footnote frame, but allow alternative if $NO_FOOTNODE is high enough 898$NO_FOOTNODE = '' unless ($NO_FOOTNODE > 1); 899# Altered: &do_cmd_footnote # RRM 900sub do_frame_footnote { 901 local($target) = ($NO_FOOTNODE ? $frame_body_name : $frame_foot_name); 902 &do_real_cmd_footnote(@_) } 903sub do_frame_footnotemark { 904 local($target) = ($NO_FOOTNODE ? $frame_body_name : $frame_foot_name); 905 &do_real_cmd_footnotemark(@_) } 906sub do_frame_thanks { 907 local($target) = ($NO_FOOTNODE ? $frame_body_name : $frame_foot_name); 908 &do_real_cmd_footnote(@_) } 909 910 911## Index adaptations 912$INDEX_STYLES = "STRONG,SMALL"; 913# Altered: &make_index_entry # RRM 914sub make_frame_index_entry { 915 local($target) = $frame_main_name; 916 &make_real_index_entry(@_); 917} 918# Altered: &do_cmd_index # RRM 919sub do_frame_index { 920 local($target) = $frame_body_name; 921 local($CURRENT_FILE) = $CURRENT_FILE; 922 $CURRENT_FILE =~ s/(\Q$frame_main_suffix\E)(\.html?)$/$frame_body_suffix$2/; 923 &do_real_index(@_); 924} 925# Altered: &make_preindex # RRM 926sub make_frame_preindex { 927 local($target) = $frame_body_name; 928 &make_real_preindex 929} 930 931## Bibliography adaptations 932# Altered: &do_cmd_bibitem # RRM 933sub do_frame_bibitem { 934 # Modifies $filename 935 local($filename) = $CURRENT_FILE; 936 $filename =~ s/$frame_main_suffix(\.html?)$/$frame_body_suffix$1/; 937 &do_real_bibitem($filename,@_); 938} 939# Altered: &do_cmd_harvarditem # RRM 940sub do_frame_harvarditem { 941 # Modifies $filename 942 local($filename) = $CURRENT_FILE; 943 $filename =~ s/$frame_main_suffix(\.html?)$/$frame_body_suffix$1/; 944 &do_real_harvarditem($filename,@_); 945} 946# Altered: &do_cmd_bibitem # RRM 947sub do_frame_bibliography { 948 # Modifies $filename 949 local($filename) = $CURRENT_FILE; 950 $filename =~ s/$frame_main_suffix(\.html?)$/$frame_body_suffix$1/; 951 &do_real_bibliography($filename,@_); 952} 953 954# Altered: &anchor_label # RRM 955sub anchor_frame_label { 956 # Modifies $filename 957 local($label,$filename,$context) = @_; 958 $filename =~ s/$frame_main_suffix(\.html?)$/$frame_body_suffix$1/; 959 &real_anchor_label($label,$filename,$context); 960} 961 962# Altered: &replace_cross_ref_marks 963sub replace_frame_cross_ref_marks { 964 # Modifies $_ 965 local($label,$id,$ref_label,$ref_mark,$after,$name,$target); 966 local($invis) = "<tex2html_anchor_invisible_mark></A>"; 967# s/$cross_ref_mark#([^#]+)#([^>]+)>$cross_ref_mark/ 968 s/$cross_ref_mark#([^#]+)#([^>]+)>$cross_ref_mark<\/A>(\s*<A( NAME=\"\d+)\">$invis)?/ 969 do {($label,$id) = ($1,$2); $name = $4; 970 if ($ref_label = $ref_files{$label}) { 971 $ref_label =~ s!$frame_main_suffix(\.html?)$!$frame_body_suffix$1!o; 972 $target = ''; 973 } else { 974 $ref_label = $external_labels{$label}; 975 $target = $FRAME_TOP; 976 } 977 print "\nXLINK<: $label : $id :$name " if ($VERBOSITY > 3); 978 $ref_mark = &get_ref_mark($label,$id); 979 &extend_ref if ($name); $name = ''; 980 print "\nXLINK: $label : $ref_label : $ref_mark " if ($VERBOSITY > 3); 981 '"' . "$ref_label#$label\"".$target.'>' . $ref_mark . '<\/A>' 982 }/geo; 983 984 # This is for pagerefs which cannot have symbolic labels ??? 985# s/$cross_ref_mark#(\w+)#\w+>/ 986 s/$cross_ref_mark#([^#]+)#[^>]+>/ 987 do {$label = $1; 988 if ($ref_label = $ref_files{$label}) { 989 $ref_label =~ s!$frame_main_suffix(\.html?)$!$frame_body_suffix$1!o; 990 $target = ''; 991 } else { 992 $ref_label = $external_labels{$label}; 993 $target = $FRAME_TOP; 994 } 995 print "\nXLINKP: $label : $ref_label" if ($VERBOSITY > 3); 996 '"' . "$ref_files{$label}#$label\"".$target.'>' 997 }/geo; 998} 999 1000 1001# Altered: &replace_external_ref_marks # RRM 1002sub replace_frame_external_ref_marks { 1003 # Modifies $_ 1004 local($label, $link); 1005 s/$external_ref_mark#([^#]+)#([^>]+)>$external_ref_mark/ 1006 do {($label,$id) = ($1,$2); 1007 $link = $external_labels{$label}; 1008 print "\nLINK: $label : $link" if ($VERBOSITY > 3); 1009 '"'. "$link#$label\"".$FRAME_TOP.">\n" 1010 . &get_ref_mark("userdefined$label",$id) 1011 } 1012 /geo; 1013} 1014 1015 1016# Altered: &post_process. 1017# The main routine that handles section links etc. 1018sub frame_post_process { 1019 # Put hyperlinks between sections, add HTML headers and addresses, 1020 # do cross references and citations. 1021 # Uses the %section_info array created in sub translate. 1022 # Binds the global variables 1023 # $PREVIOUS, $PREVIOUS_TITLE 1024 # $NEXT, $NEXT_TITLE 1025 # $UP, $UP_TITLE 1026 # $CONTENTS 1027 # $INDEX 1028 # $NEXT_GROUP, $NEXT_GROUP_TITLE 1029 # $PREVIOUS_GROUP, $PREVIOUS_GROUP_TITLE 1030 # Converting to and from lists and strings is very inefficient. 1031 # Maybe proper lists of lists should be used (or wait for Perl5?) 1032 # JKR: Now using top_navigation and bot_navigation instead of navigation 1033 local($_, $key, $depth, $file, $title, $header, @link, @old_link, 1034 $top_navigation, $bot_navigation, @keys, 1035 @tmp_keys, $flag, $child_links, $body, $more_links); 1036 1037 $CURRENT_FILE = ''; 1038 @tmp_keys = @keys = sort numerically keys %section_info; 1039 print "\nDoing section links ..."; 1040 &adjust_segment_links if ($SEGMENT || $SEGMENTED); 1041 while (@tmp_keys) { 1042 $key = shift @tmp_keys; 1043 next if ($MULTIPLE_FILES &&!($key =~ /^$THIS_FILE/)); 1044 print "."; 1045 $more_links = ""; 1046 ($depth, $file, $title) = split($delim,$section_info{$key}); 1047 print STDOUT "\n$key $file $title" if ($VERBOSITY > 3); 1048 $PREVIOUS = $PREVIOUS_TITLE = $NEXT = $NEXT_TITLE = $UP = $UP_TITLE 1049 = $CONTENTS = $CONTENTS_TITLE = $INDEX = $INDEX_TITLE 1050 = $NEXT_GROUP = $NEXT_GROUP_TITLE 1051 = $PREVIOUS_GROUP = $PREVIOUS_GROUP_TITLE 1052 = $_ = $top_navigation = $bot_navigation = undef; 1053 @link = split(' ',$key); 1054 ($PREVIOUS, $PREVIOUS_TITLE) = 1055 &add_link($previous_page_visible_mark,$file,@old_link); 1056 @old_link = @link; 1057 1058 unless ($done{$file}) { 1059 $link[$depth]++; 1060 ($NEXT_GROUP, $NEXT_GROUP_TITLE) 1061 = &add_link($next_visible_mark, $file, @link); 1062 &add_link_tag('next', $file, @link); 1063 1064 $link[$depth]--;$link[$depth]--; 1065 if ($MULTIPLE_FILES && !$depth ) { 1066 } else { 1067 ($PREVIOUS_GROUP, $PREVIOUS_GROUP_TITLE) = 1068 &add_link($previous_visible_mark, $file,@link); 1069 &add_link_tag('previous', $file,@link); 1070 } 1071 1072 $link[$depth] = 0; 1073 ($UP, $UP_TITLE) = 1074 &add_link($up_visible_mark, $file, @link); 1075 &add_link_tag('up', $file, @link); 1076 1077 if ($CONTENTS_IN_NAVIGATION && $tocfile) { 1078 ($CONTENTS, $CONTENTS_LINK) = 1079 &add_special_link($contents_visible_mark, $tocfile, $file); 1080 &add_link_tag($frame_body_name, $file, $delim.$tocfile); 1081 } 1082 1083 if ($INDEX_IN_NAVIGATION && $idxfile) { 1084 ($INDEX, $INDEX_LINK) = 1085 &add_special_link($index_visible_mark, $idxfile, $file); 1086 &add_link_tag('index', $file, $delim.$idxfile,); 1087 } 1088 1089 @link = split(' ',$tmp_keys[0]); 1090 # the required `next' link may be several sub-sections along 1091 local($nextdepth,$nextfile,$nextkey)=($depth,$file,$key); 1092 $nextkey = shift @tmp_keys; 1093 ($nextdepth, $nextfile, $nexttitle,$nextbody) = split($delim,$section_info{$nextkey}); 1094 if (($nextdepth<$MAX_SPLIT_DEPTH)&&(!($nextbody=~/external/))) { 1095 ($NEXT, $NEXT_TITLE) = 1096 &add_link($next_page_visible_mark, $file, @link); 1097 &add_link_tag('next', $file, @link); 1098 } else { 1099 ($NEXT, $NEXT_TITLE) = ('',''); 1100 $nextfile = $file; 1101 } 1102 1103# if (($NEXT =~ /next_page_inactive_visible_mark/)&&(@tmp_keys)) { 1104 if ((!$NEXT || $NEXT =~ /next_page_inactive_visible_mark/)&&(@tmp_keys)) { 1105 # the required `next' link may be several sub-sections along 1106 while ((@tmp_keys)&&(($MAX_SPLIT_DEPTH < $nextdepth+1)||($nextfile eq $file))) { 1107 $nextkey = shift @tmp_keys; 1108 ($nextdepth, $nextfile,$nexttitle,$nextbody) = split($delim,$section_info{$nextkey}); 1109 if ($nextbody =~ /external/) { 1110 $nextfile = $file; 1111 next; 1112 }; 1113 print ","; 1114 print STDOUT "\n$nextkey" if ($VERBOSITY > 3); 1115 } 1116 @link = split(' ',$nextkey); 1117 if (($nextkey)&&($nextdepth<$MAX_SPLIT_DEPTH)) { 1118 ($NEXT, $NEXT_TITLE) = 1119 &add_link($next_page_visible_mark, $file, @link); 1120 &add_link_tag('next', $file, @link); 1121 } else { 1122 ($NEXT, $NEXT_TITLE) = ($NEXT_GROUP, $NEXT_GROUP_TITLE); 1123 $NEXT =~ s/next_page_(inactive_)?visible_mark/next_page_$1visible_mark/; 1124 ($PREVIOUS, $PREVIOUS_TITLE) = ($PREVIOUS_GROUP, $PREVIOUS_GROUP_TITLE); 1125 $PREVIOUS =~ s/previous_(inactive_)?visible_mark/previous_page_$1visible_mark/; 1126 } 1127 } 1128 unshift (@tmp_keys,$nextkey) if ($nextkey); 1129 1130 local($this_file) = $file; 1131 if ($MULTIPLE_FILES && $ROOTED) { 1132 if ($this_file =~ /\Q$dd\E([^$dd$dd]+)$/) { $this_file = $1 } 1133 } 1134 1135 rename($this_file, "TMP.$this_file"); 1136# open(INPUT, "<TMP.$this_file") || die "Cannot open file TMP.$this_file $!"; 1137 &slurp_input("TMP.$this_file"); 1138# open(OUTFILE, ">$this_file") || die "Cannot open file $this_file $!"; 1139 1140 if (($INDEX) && ($SHORT_INDEX) && ($SEGMENT eq 1)) { 1141 &make_index_segment($title,$file); } 1142 1143 local($child_star,$child_links); 1144 if (/$childlinks_on_mark\#(\d)\#/) { $child_star = $1 } 1145 $child_links = &add_child_links('',$file, $depth, $child_star,$key, @keys) 1146 unless (/$childlinks_null_mark\#(\d)\#/); 1147 if (($child_links)&&(!/$childlinks_mark/)&&($MAX_SPLIT_DEPTH > 1)) { 1148 if ($depth < $MAX_SPLIT_DEPTH -1) { 1149 $_ = join('', $header, $_, &child_line(), $childlinks_mark, "\#0\#" ); 1150 } else { 1151 $_ = join('', $header, "\n$childlinks_mark\#0\#", &upper_child_line(), $_ ); 1152 } 1153 } else { 1154 $_ = join('', $header, $_ ); 1155 } 1156 1157# File operations are carried out by &make_frame_header. 1158 &make_frame_header ($title,$file,$_); 1159 $done{$file}++; 1160 } 1161 } 1162 &post_process_footnotes if ($footfile); 1163} 1164 1165sub adjust_segment_links { 1166 $EXTERNAL_UP_LINK = &adjust_segment_link($EXTERNAL_UP_LINK) if ($EXTERNAL_UP_LINK); 1167 $EXTERNAL_PREV_LINK = &adjust_segment_link($EXTERNAL_PREV_LINK) if ($EXTERNAL_PREV_LINK); 1168 $EXTERNAL_DOWN_LINK = &adjust_segment_link($EXTERNAL_DOWN_LINK) if ($EXTERNAL_DOWN_LINK); 1169} 1170 1171sub adjust_segment_link { 1172 local($orig) = @_; 1173 local($link) = $orig; 1174 $link =~ s/(\Q$frame_main_suffix\E)?(\.html?)$/$frame_main_suffix$2/; 1175 if (-f $link) { return $link } else { return $orig } 1176} 1177 1178# Altered: &make_footnotes. 1179# The only change is the call to &make_file. 1180sub make_frame_footnotes { 1181 # Uses $footnotes defined in translate and set in do_cmd_footnote 1182 # Also uses $footfile 1183 local($_) = "<DL>$footnotes<\/DL>\n"; 1184 print "\nDoing footnotes ..."; 1185 &replace_frame_markers; 1186 &replace_markers; 1187 if ($footfile) { 1188 &make_file($footfile, "Footnotes", $FOOT_COLOR); # Modifies $_; 1189 $_ = "" 1190 } 1191 $_; 1192} 1193 1194# Altered: &make_file. 1195# It now takes a third argument specifying the layout (colors etc.) 1196sub make_frame_file { 1197 # Uses and modifies $_ defined in the caller 1198 local($filename, $title, $layout) = @_; 1199 $_ = join('', &make_head_and_body($title,$layout," "), $_ 1200 , (($filename =~ /^\Q$footfile\E$/) ? '' : &make_address ) 1201 , (($filename =~ /^\Q$footfile\E$/) ? "\n</BODY>\n</HTML>\n" : '') 1202 ); 1203 &text_cleanup; 1204 open(FILE,">$filename") || print "Cannot open $filename $!\n"; 1205 print FILE $_; 1206 close(FILE); 1207} 1208 1209sub add_frame_special_link { 1210 local($icon, $file, $current_file) = @_; 1211 local($text); 1212 if ($icon eq $index_visible_mark) { 1213 $text = $idx_title; 1214# $current_file =~ s/$EXTN$/$frame_idx_suffix$&/; 1215 $current_file =~ s/($frame_main_suffix)?(\.html?)$/$frame_idx_suffix$2/; 1216 local($target) = $frame_top_name; 1217 ("\n" . &make_href($current_file, $icon) 1218 , ($text ? " ". &make_href($current_file, $text) : undef) ) 1219 } elsif ($icon eq $contents_visible_mark) { 1220 $text = $toc_title; 1221# $current_file =~ s/$EXTN$/$frame_toc_suffix$&/; 1222 $current_file =~ s/($frame_main_suffix)?(\.html?)$/$frame_toc_suffix$2/; 1223 local($target) = $frame_top_name; 1224 ("\n" . &make_href($current_file, $icon) 1225 , ($text ? " ". &make_href($current_file, $text) : undef) ) 1226 } else { 1227 &add_real_special_link(@_) 1228 } 1229} 1230 1231sub add_frame_child_links { 1232 local($target) = $target; 1233 local($split_depth) = $FALSE_SPLIT_DEPTH||$MAX_SPLIT_DEPTH; 1234 $target = ($depth < $split_depth-1 ? $frame_main_name : $frame_body_name) 1235 unless ($doing_toc); 1236 &add_real_child_links(@_); 1237} 1238 1239# Place navigation lists within fixed-width <TABLE>s, 1240# ... only when an appropriate width has been provided. 1241# Use this to prevent wrapping of moderately long titles; scroll instead 1242 1243sub add_idx_hook { 1244 if ($INDEX_TABLE_WIDTH) { 1245 s!$idx_mark! 1246 join('' 1247 , ($INDEX_BANNER ? $INDEX_BANNER."\n" : '') 1248 , '<TABLE WIDTH=',$INDEX_TABLE_WIDTH , '>' 1249 , "\n<TR><TD>$idx_mark</TD></TR>" 1250 , "\n</TABLE>\n" 1251 , ($INDEX_FOOTER ? $INDEX_FOOTER."\n" : '') 1252 ) 1253 !eo; 1254 } 1255 # call the real &add_idx indirectly, to catch overrides 1256 eval "&add_idx"; 1257} 1258 1259sub add_frame_toc { 1260 local($target) = $frame_main_name; 1261 local($use_description_list) = 1; 1262 local($doing_toc) = 1; 1263 if ($CONTENTS_TABLE_WIDTH) { 1264 # put into a <TABLE> of fixed size 1265 s!$toc_mark! 1266 join('','<TABLE WIDTH=',$CONTENTS_TABLE_WIDTH,'>' 1267 , "\n<TR><TD>$toc_mark</TD></TR>" 1268 , "\n</TABLE>\n" ) 1269 !eo; 1270 } 1271 # call the real &add_toc 1272 &add_real_toc; 1273} 1274 1275sub do_frame_tableofcontents { 1276 local($toc_style) = 'TOC' if ($USING_STYLES); 1277 join("\n", $CONTENTS_BANNER , &do_real_tableofcontents(@_), $CONTENTS_FOOTER ); 1278} 1279 1280 1281# Modified &replace_general_markers 1282sub replace_frame_general_markers { 1283 local($target) = $frame_body_name; 1284 1285 if (defined &replace_infopage_hook) {&replace_infopage_hook if (/$info_page_mark/);} 1286 else { &replace_infopage if (/$info_page_mark/); } 1287 1288 $target = $frame_body_name; 1289 if (defined &add_idx_hook) {&add_idx_hook if (/$idx_mark/);} 1290 else {&add_idx if (/$idx_mark/);} 1291 1292 if ($segment_figure_captions) { 1293# s/$lof_mark/<UL>$segment_figure_captions<\/UL>/o 1294# } else { s/$lof_mark/<UL>$figure_captions<\/UL>/o } 1295 s/$lof_mark/$segment_figure_captions/o 1296 } else { s/$lof_mark/$figure_captions/o } 1297 if ($segment_table_captions) { 1298# s/$lot_mark/<UL>$segment_table_captions<\/UL>/o 1299# } else { s/$lot_mark/<UL>$table_captions<\/UL>/o } 1300 s/$lot_mark/$segment_table_captions/o 1301 } else { s/$lot_mark/$table_captions/o } 1302 &replace_morelinks(); 1303 if (defined &replace_citations_hook) {&replace_citations_hook if /$bbl_mark/;} 1304 else {&replace_bbl_marks if /$bbl_mark/;} 1305 1306 $target = $frame_main_name; 1307 if (defined &add_toc_hook) {&add_toc_hook if (/$toc_mark/);} 1308 else {&add_toc if (/$toc_mark/);} 1309 if (defined &add_childs_hook) {&add_childs_hook if (/$childlinks_on_mark/);} 1310 else {&add_childlinks if (/$childlinks_on_mark/);} 1311 &remove_child_marks; 1312 1313 $target = $frame_body_name; 1314 if (defined &replace_cross_references_hook) {&replace_cross_references_hook;} 1315 else {&replace_cross_ref_marks if /$cross_ref_mark||$cross_ref_visible_mark/;} 1316 1317 $target = 'notarget'; 1318 if (defined &replace_external_references_hook) {&replace_external_references_hook;} 1319 else {&replace_external_ref_marks if /$external_ref_mark/;} 1320 1321 $target = $frame_body_name; 1322 if (defined &replace_cite_references_hook) {&replace_cite_references_hook;} 1323 else { &replace_cite_marks if /$cite_mark/; } 1324 1325 if (defined &replace_user_references) { 1326 &replace_user_references if /$user_ref_mark/; } 1327} 1328 1329# Settings requested in the preamble take effect immediately; 1330# for those in the text a frame_marker is inserted, followed 1331# by the frame_data, which must be applied later. 1332# To control this, the value of $STARTFRAMES must be changed 1333# when the preamble ends. 1334 1335sub initialise_frames { 1336 print "\n *** initialising Netscape frames ***" 1337 if ($frame_implementation =~ /Netscape/); 1338 $frame_mark = '<tex2html_frame_mark>'; 1339 &do_require_package(color); 1340 do { # bind existing subroutines to the `frame' versions 1341 sub do_cmd_bibitem { &do_frame_bibitem(@_); } 1342 sub do_cmd_bibliography { &do_frame_bibliography(@_); } 1343 sub do_cmd_harvarditem { &do_frame_harvarditem(@_); } 1344 sub do_cmd_thanks { &do_frame_thanks(@_); } 1345 sub do_cmd_index { &do_frame_index(@_); } 1346 sub make_preindex { &make_frame_preindex; } 1347 sub do_cmd_footnote { &do_frame_footnote(@_); } 1348 sub do_cmd_footnotemark { &do_frame_footnotemark(@_); } 1349 sub do_cmd_tableofcontents { &do_frame_tableofcontents(@_); } 1350 sub add_toc { &add_frame_toc; } 1351 sub add_child_links { &add_frame_child_links(@_); } 1352# sub process_footnote { &process_frame_footnote(@_); } 1353# sub make_footnotes { &make_frame_footnotes(@_); } 1354# sub make_file { &make_frame_file(@_); } 1355 sub anchor_label { &anchor_frame_label(@_); } 1356 sub make_index_entry { &make_frame_index_entry(@_); } 1357 sub add_special_link { &add_frame_special_link(@_); } 1358 sub make_half_href { &make_frame_half_href(@_); } 1359 sub make_named_href { &make_frame_named_href(@_); } 1360 sub make_href { &make_frame_href(@_); } 1361 sub make_href_noexpand { &make_frame_href_noexpand(@_); } 1362 1363 sub replace_general_markers { &replace_frame_general_markers(@_); } 1364 sub replace_cross_ref_marks { &replace_frame_cross_ref_marks(@_); } 1365 sub replace_external_ref_marks { &replace_frame_external_ref_marks(@_); } 1366 sub post_process { &frame_post_process(@_); } 1367 sub apply_body_options { &apply_frame_body_options(@_); } 1368 sub set_section_color { &set_frame_section_color(@_); } 1369 ${AtBeginDocument_hook} .= "\$STARTFRAMES = 1;"; 1370 } 1371} 1372 1373if ($HTML_VERSION lt "$html_frame_version" ) { do { 1374 print STDERR "\n*** frames are not supported with HTML version: $HTML_VERSION ***\n"; 1375 &ignore_commands( <<_IGNORED_CMDS_); 1376frameoptions # [] # {} 1377framecolor # {} # {} 1378frameColorSet # [] # {} 1379frameColorSetstar # [] # {} 1380frameColorSetstarstar # [] # {} 1381_IGNORED_CMDS_ 1382}} else { &initialise_frames(); } 1383 13841; # This must be the last line. 1385 1386