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