This commit was manufactured by cvs2svn to create tag 'r234c1'.
[python/dscho.git] / Doc / perl / l2hinit.perl
blobebf63533e75832f4053e4161047b0c410eb6cc75
1 # LaTeX2HTML support base for use with Python documentation.
3 package main;
5 use L2hos;
7 $HTML_VERSION = 4.0;
9 $MAX_LINK_DEPTH = 2;
10 $ADDRESS = '';
12 $NO_FOOTNODE = 1;
13 $NUMBERED_FOOTNOTES = 1;
15 # Python documentation uses section numbers to support references to match
16 # in the printed and online versions.
18 $SHOW_SECTION_NUMBERS = 1;
20 $ICONSERVER = '.';
21 $IMAGE_TYPE = 'gif';
23 # Control where the navigation bars should show up:
24 $TOP_NAVIGATION = 1;
25 $BOTTOM_NAVIGATION = 1;
26 $AUTO_NAVIGATION = 0;
28 $BODYTEXT = '';
29 $CHILDLINE = "\n<p><hr>\n";
30 $VERBOSITY = 0;
32 # default # of columns for the indexes
33 $INDEX_COLUMNS = 2;
34 $MODULE_INDEX_COLUMNS = 4;
36 $HAVE_MODULE_INDEX = 0;
37 $HAVE_GENERAL_INDEX = 0;
38 $HAVE_TABLE_OF_CONTENTS = 0;
40 $AESOP_META_TYPE = 'information';
43 # A little painful, but lets us clean up the top level directory a little,
44 # and not be tied to the current directory (as far as I can tell). Testing
45 # an existing definition of $mydir is needed since it cannot be computed when
46 # run under mkhowto with recent versions of LaTeX2HTML, since this file is
47 # not read directly by LaTeX2HTML any more. mkhowto is required to prepend
48 # the required definition at the top of the actual input file.
50 if (!defined $mydir) {
51 use Cwd;
52 use File::Basename;
53 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
54 chop $mydir; # remove trailing '/'
55 $mydir = getcwd() . "$dd$mydir"
56 unless $mydir =~ s|^/|/|;
58 $LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES";
59 push (@INC, $mydir);
61 ($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*');
62 chop $myrootdir;
65 # Hackish way to get the appropriate paper-*/ directory into $TEXINPUTS;
66 # pass in the paper size (a4 or letter) as the environment variable PAPER
67 # to add the right directory. If not given, the current directory is
68 # added instead for use with HOWTO processing.
70 if (defined $ENV{'PAPER'}) {
71 $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey";
73 else {
74 $mytexinputs = getcwd() . $envkey;
76 $mytexinputs .= "$myrootdir${dd}texinputs";
79 # Change this variable to change the text added in "About this document...";
80 # this should be an absolute pathname to get it right.
82 $ABOUT_FILE = "$myrootdir${dd}html${dd}stdabout.dat";
85 sub custom_driver_hook {
87 # This adds the directory of the main input file to $TEXINPUTS; it
88 # seems to be sufficiently general that it should be fine for HOWTO
89 # processing.
91 # XXX This still isn't quite right; we should actually be inserting
92 # $mytexinputs just before any empty entry in TEXINPUTS is one
93 # exists instead of just concatenating the pieces like we do here.
95 my $file = $_[0];
96 my($jobname, $dir, $ext) = fileparse($file, '\..*');
97 $dir = L2hos->Make_directory_absolute($dir);
98 $dir =~ s/$dd$//;
99 $TEXINPUTS = "$dir$envkey$mytexinputs";
100 # Push everything into $TEXINPUTS since LaTeX2HTML doesn't pick
101 # this up on it's own; we clear $ENV{'TEXINPUTS'} so the value set
102 # for this by the main LaTeX2HTML script doesn't contain duplicate
103 # directories.
104 if ($ENV{'TEXINPUTS'}) {
105 $TEXINPUTS .= "$envkey$ENV{'TEXINPUTS'}";
106 $ENV{'TEXINPUTS'} = undef;
108 print "\nSetting \$TEXINPUTS to $TEXINPUTS\n";
112 $CUSTOM_BUTTONS = '';
114 sub make_nav_sectref($$$) {
115 my($label, $linktype, $title) = @_;
116 if ($title) {
117 if ($title =~ /\<[aA] /) {
118 $title =~ s/\<[aA] /<a class="sectref" rel="$linktype" /;
120 else {
121 $title = "<span class=\"sectref\">$title</span>";
123 return "<b class=\"navlabel\">$label:</b>\n$title\n";
125 return '';
128 @my_icon_tags = ();
129 $my_icon_tags{'next'} = 'Next Page';
130 $my_icon_tags{'next_page'} = 'Next Page';
131 $my_icon_tags{'previous'} = 'Previous Page';
132 $my_icon_tags{'previous_page'} = 'Previous Page';
133 $my_icon_tags{'up'} = 'Up One Level';
134 $my_icon_tags{'contents'} = 'Contents';
135 $my_icon_tags{'index'} = 'Index';
136 $my_icon_tags{'modules'} = 'Module Index';
138 @my_icon_names = ();
139 $my_icon_names{'previous_page'} = 'previous';
140 $my_icon_names{'next_page'} = 'next';
142 sub get_my_icon($) {
143 my $name = $_[0];
144 my $text = $my_icon_tags{$name};
145 if ($my_icon_names{$name}) {
146 $name = $my_icon_names{$name};
148 if ($text eq '') {
149 $name = 'blank';
151 my $iconserver = ($ICONSERVER eq '.') ? '' : "$ICONSERVER/";
152 return "<img src='$iconserver$name.$IMAGE_TYPE'\n border='0'"
153 . " height='32' alt='$text' width='32'>";
156 sub unlinkify($) {
157 my $text = "$_[0]";
158 $text =~ s|</[aA]>||;
159 $text =~ s|<a\s+[^>]*>||i;
160 return $text;
163 sub use_icon($$$) {
164 my($rel,$str,$title) = @_;
165 if ($title) {
166 my $s = "$str";
167 if ($s =~ /\<tex2html_([a-z_]+)_visible_mark\>/) {
168 my $r = get_my_icon($1);
169 $s =~ s/\<tex2html_[a-z_]+_visible_mark\>/$r/;
171 $s =~ s/<[aA] /<a rel="$rel" title="$title" \n /;
172 return $s;
174 else {
175 return get_my_icon('blank');
179 sub make_nav_panel() {
180 my $s;
181 # new iconic rel iconic page title
182 $NEXT = use_icon('next', $NEXT, unlinkify($NEXT_TITLE));
183 $UP = use_icon('parent', $UP, unlinkify($UP_TITLE));
184 $PREVIOUS = use_icon('prev', $PREVIOUS, unlinkify($PREVIOUS_TITLE));
185 $CONTENTS = use_icon('contents', $CONTENTS, 'Table of Contents');
186 $INDEX = use_icon('index', $INDEX, 'Index');
187 if (!$CUSTOM_BUTTONS) {
188 $CUSTOM_BUTTONS = get_my_icon('blank');
190 $s = ('<table align="center" width="100%" cellpadding="0" cellspacing="2">'
191 . "\n<tr>"
192 # left-hand side
193 . "\n<td>$PREVIOUS</td>"
194 . "\n<td>$UP</td>"
195 . "\n<td>$NEXT</td>"
196 # title box
197 . "\n<td align=\"center\" width=\"100%\">$t_title</td>"
198 # right-hand side
199 . "\n<td>$CONTENTS</td>"
200 . "\n<td>$CUSTOM_BUTTONS</td>" # module index
201 . "\n<td>$INDEX</td>"
202 . "\n</tr></table>\n"
203 # textual navigation
204 . make_nav_sectref("Previous", "prev", $PREVIOUS_TITLE)
205 . make_nav_sectref("Up", "parent", $UP_TITLE)
206 . make_nav_sectref("Next", "next", $NEXT_TITLE)
208 # remove these; they are unnecessary and cause errors from validation
209 $s =~ s/ NAME="tex2html\d+"\n */ /g;
210 return $s;
213 sub add_child_links {
214 my $toc = add_real_child_links(@_);
215 $toc =~ s|\s*</[aA]>|</a>|g;
216 $toc =~ s/ NAME=\"tex2html\d+\"\s*href=/ href=/gi;
217 $toc =~ s|</UL>(\s*<BR>)?|</ul>|gi;
218 return $toc;
221 sub get_version_text() {
222 if ($PACKAGE_VERSION ne '' && $t_date) {
223 return ("<span class=\"release-info\">"
224 . "Release $PACKAGE_VERSION$RELEASE_INFO,"
225 . " documentation updated on $t_date.</span>");
227 if ($PACKAGE_VERSION ne '') {
228 return ("<span class=\"release-info\">"
229 . "Release $PACKAGE_VERSION$RELEASE_INFO.</span>");
231 if ($t_date) {
232 return ("<span class=\"release-info\">Documentation released on "
233 . "$t_date.</span>");
235 return '';
239 sub top_navigation_panel() {
240 return "\n"
241 . make_nav_panel()
242 . "<br><hr>\n";
245 sub bot_navigation_panel() {
246 return "\n<p><hr>\n"
247 . make_nav_panel()
248 . "<hr>\n"
249 . get_version_text()
250 . "\n";
253 sub add_link {
254 # Returns a pair (iconic link, textual link)
255 my($icon, $current_file, @link) = @_;
256 my($dummy, $file, $title) = split($delim,
257 $section_info{join(' ',@link)});
258 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
259 my $r = get_my_icon($1);
260 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
262 if ($title && ($file ne $current_file)) {
263 $title = purify($title);
264 $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
265 return (make_href($file, $icon), make_href($file, "$title"))
267 elsif ($icon eq get_my_icon('up') && $EXTERNAL_UP_LINK) {
268 return (make_href($EXTERNAL_UP_LINK, $icon),
269 make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
271 elsif ($icon eq get_my_icon('previous')
272 && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
273 return (make_href($EXTERNAL_PREV_LINK, $icon),
274 make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
276 elsif ($icon eq get_my_icon('next')
277 && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
278 return (make_href($EXTERNAL_DOWN_LINK, $icon),
279 make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
281 return (&inactive_img($icon), "");
284 sub add_special_link($$$) {
285 my($icon, $file, $current_file) = @_;
286 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
287 my $r = get_my_icon($1);
288 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
290 return (($file && ($file ne $current_file))
291 ? make_href($file, $icon)
292 : undef)
295 # The img_tag() function seems only to be called with the parameter
296 # 'anchor_invisible_mark', which we want to turn into ''. Since
297 # replace_icon_marks() is the only interesting caller, and all it really
298 # does is call img_tag(), we can just define the hook alternative to be
299 # a no-op instead.
301 sub replace_icons_hook {}
303 sub do_cmd_arabic {
304 # get rid of that nasty <SPAN CLASS="arabic">...</SPAN>
305 my($ctr, $val, $id, $text) = &read_counter_value($_[0]);
306 return ($val ? farabic($val) : "0") . $text;
310 sub gen_index_id($$) {
311 # this is used to ensure common index key generation and a stable sort
312 my($str, $extra) = @_;
313 sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
316 sub insert_index($$$$$) {
317 my($mark, $datafile, $columns, $letters, $prefix) = @_;
318 my $prog = "$myrootdir/tools/buildindex.py";
319 my $index;
320 if ($letters) {
321 $index = `$prog --columns $columns --letters $datafile`;
323 else {
324 $index = `$prog --columns $columns $datafile`;
326 if (!s/$mark/$prefix$index/) {
327 print "\nCould not locate index mark: $mark";
331 sub add_idx() {
332 print "\nBuilding HTML for the index ...";
333 close(IDXFILE);
334 insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
338 $idx_module_mark = '<tex2html_idx_module_mark>';
339 $idx_module_title = 'Module Index';
341 sub add_module_idx() {
342 print "\nBuilding HTML for the module index ...";
343 my $key;
344 my $first = 1;
345 my $prevplat = '';
346 my $allthesame = 1;
347 my $prefix = '';
348 foreach $key (keys %Modules) {
349 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
350 my $plat = "$ModulePlatforms{$key}";
351 $plat = ''
352 if ($plat eq $IGNORE_PLATFORM_ANNOTATION);
353 if (!$first) {
354 $allthesame = 0
355 if ($prevplat ne $plat);
357 else { $first = 0; }
358 $prevplat = $plat;
360 open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
361 foreach $key (keys %Modules) {
362 # dump the line in the data file; just use a dummy seqno field
363 my $nkey = $1;
364 my $moditem = "$Modules{$key}";
365 my $plat = '';
366 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
367 if ($ModulePlatforms{$key} && !$allthesame) {
368 $plat = (" <em>(<span class=\"platform\">$ModulePlatforms{$key}"
369 . '</span>)</em>');
371 print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP
372 . "<tt class=\"module\">$key</tt>$plat###\n";
374 close(MODIDXFILE);
376 if ($GLOBAL_MODULE_INDEX) {
377 $prefix = <<MODULE_INDEX_PREFIX;
379 <p> This index only lists modules documented in this manual.
380 The <em class="citetitle"><a href="$GLOBAL_MODULE_INDEX">Global Module
381 Index</a></em> lists all modules that are documented in this set
382 of manuals.</p>
383 MODULE_INDEX_PREFIX
385 if (!$allthesame) {
386 $prefix .= <<PLAT_DISCUSS;
388 <p> Some module names are followed by an annotation indicating what
389 platform they are available on.</p>
391 PLAT_DISCUSS
393 insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
394 $prefix);
397 # replace both indexes as needed:
398 sub add_idx_hook {
399 add_idx() if (/$idx_mark/);
400 process_python_state();
401 if ($MODULE_INDEX_FILE) {
402 local ($_);
403 open(MYFILE, "<$MODULE_INDEX_FILE");
404 sysread(MYFILE, $_, 1024*1024);
405 close(MYFILE);
406 add_module_idx();
407 open(MYFILE,">$MODULE_INDEX_FILE");
408 print MYFILE $_;
409 close(MYFILE);
414 # In addition to the standard stuff, add label to allow named node files and
415 # support suppression of the page complete (for HTML Help use).
416 $MY_CONTENTS_PAGE = '';
417 sub do_cmd_tableofcontents {
418 local($_) = @_;
419 $TITLE = $toc_title;
420 $tocfile = $CURRENT_FILE;
421 my($closures, $reopens) = preserve_open_tags();
422 anchor_label('contents', $CURRENT_FILE, $_); # this is added
423 $MY_CONTENTS_PAGE = "$CURRENT_FILE";
424 join('', "<BR>\n\\tableofchildlinks[off]", $closures
425 , make_section_heading($toc_title, 'H2'), $toc_mark
426 , $reopens, $_);
428 # In addition to the standard stuff, add label to allow named node files.
429 sub do_cmd_listoffigures {
430 local($_) = @_;
431 $TITLE = $lof_title;
432 $loffile = $CURRENT_FILE;
433 my($closures, $reopens) = preserve_open_tags();
434 anchor_label('lof', $CURRENT_FILE, $_); # this is added
435 join('', "<BR>\n", $closures
436 , make_section_heading($lof_title, 'H2'), $lof_mark
437 , $reopens, $_);
439 # In addition to the standard stuff, add label to allow named node files.
440 sub do_cmd_listoftables {
441 local($_) = @_;
442 $TITLE = $lot_title;
443 $lotfile = $CURRENT_FILE;
444 my($closures, $reopens) = preserve_open_tags();
445 anchor_label('lot', $CURRENT_FILE, $_); # this is added
446 join('', "<BR>\n", $closures
447 , make_section_heading($lot_title, 'H2'), $lot_mark
448 , $reopens, $_);
450 # In addition to the standard stuff, add label to allow named node files.
451 sub do_cmd_textohtmlinfopage {
452 local($_) = @_;
453 if ($INFO) { #
454 anchor_label("about",$CURRENT_FILE,$_); # this is added
456 my $the_version = ''; # and the rest is
457 if ($t_date) { # mostly ours
458 $the_version = ",\n$t_date";
459 if ($PACKAGE_VERSION) {
460 $the_version .= ", Release $PACKAGE_VERSION$RELEASE_INFO";
463 my $about;
464 open(ABOUT, "<$ABOUT_FILE") || die "\n$!\n";
465 sysread(ABOUT, $about, 1024*1024);
466 close(ABOUT);
467 $_ = (($INFO == 1)
468 ? join('',
469 $close_all,
470 "<strong>$t_title</strong>$the_version\n",
471 $about,
472 $open_all, $_)
473 : join('', $close_all, $INFO,"\n", $open_all, $_));
477 # $idx_mark will be replaced with the real index at the end
478 sub do_cmd_textohtmlindex {
479 local($_) = @_;
480 $TITLE = $idx_title;
481 $idxfile = $CURRENT_FILE;
482 if (%index_labels) { make_index_labels(); }
483 if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); }
484 else { $preindex = ''; }
485 my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
486 my($pre, $post) = minimize_open_tags($heading);
487 anchor_label('genindex',$CURRENT_FILE,$_); # this is added
488 return "<br>\n" . $pre . $_;
491 $MODULE_INDEX_FILE = '';
493 # $idx_module_mark will be replaced with the real index at the end
494 sub do_cmd_textohtmlmoduleindex {
495 local($_) = @_;
496 $TITLE = $idx_module_title;
497 anchor_label('modindex', $CURRENT_FILE, $_);
498 $MODULE_INDEX_FILE = "$CURRENT_FILE";
499 $_ = ('<p>' . make_section_heading($idx_module_title, 'h2')
500 . $idx_module_mark . $_);
501 return $_;
504 # The bibliography and the index should be treated as separate
505 # sections in their own HTML files. The \bibliography{} command acts
506 # as a sectioning command that has the desired effect. But when the
507 # bibliography is constructed manually using the thebibliography
508 # environment, or when using the theindex environment it is not
509 # possible to use the normal sectioning mechanism. This subroutine
510 # inserts a \bibliography{} or a dummy \textohtmlindex command just
511 # before the appropriate environments to force sectioning.
513 # XXX This *assumes* that if there are two {theindex} environments,
514 # the first is the module index and the second is the standard
515 # index. This is sufficient for the current Python documentation,
516 # but that's about it.
518 sub add_bbl_and_idx_dummy_commands {
519 my $id = $global{'max_id'};
521 if (/[\\]tableofcontents/) {
522 $HAVE_TABLE_OF_CONTENTS = 1;
524 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
525 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo;
526 my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/);
527 if (scalar(@parts) == 3) {
528 # Be careful to re-write the string in place, since $_ is *not*
529 # returned explicity; *** nasty side-effect dependency! ***
530 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
531 print "\nadd_bbl_and_idx_dummy_commands ==> adding module index";
532 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)"
533 . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
534 s/$rx/\\textohtmlmoduleindex $1 \\textohtmlindex $2/o;
535 # Add a button to the navigation areas:
536 $CUSTOM_BUTTONS .= ('<a href="modindex.html" title="Module Index">'
537 . get_my_icon('modules')
538 . '</a>');
539 $HAVE_MODULE_INDEX = 1;
540 $HAVE_GENERAL_INDEX = 1;
542 elsif (scalar(@parts) == 2) {
543 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
544 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
545 s/$rx/\\textohtmlindex $1/o;
546 $HAVE_GENERAL_INDEX = 1;
548 elsif (scalar(@parts) == 1) {
549 print "\nadd_bbl_and_idx_dummy_commands ==> no index found";
550 $CUSTOM_BUTTONS .= get_my_icon('blank');
551 $global{'max_id'} = $id; # not sure why....
552 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
553 s/[\\]printindex/\\textohtmlindex /o;
555 else {
556 die "\n\nBad number of index environments!\n\n";
558 #----------------------------------------------------------------------
559 lib_add_bbl_and_idx_dummy_commands()
560 if defined(&lib_add_bbl_and_idx_dummy_commands);
563 # The bibliographic references, the appendices, the lists of figures
564 # and tables etc. must appear in the contents table at the same level
565 # as the outermost sectioning command. This subroutine finds what is
566 # the outermost level and sets the above to the same level;
568 sub set_depth_levels {
569 # Sets $outermost_level
570 my $level;
571 #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
572 foreach $level ("part", "chapter", "section", "subsection",
573 "subsubsection", "paragraph") {
574 last if (($outermost_level) = /\\($level)$delimiter_rx/);
576 $level = ($outermost_level ? $section_commands{$outermost_level} :
577 do {$outermost_level = 'section'; 3;});
579 #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
580 if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
581 $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
582 } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
584 %unnumbered_section_commands = ('tableofcontents' => $level,
585 'listoffigures' => $level,
586 'listoftables' => $level,
587 'bibliography' => $level,
588 'textohtmlindex' => $level,
589 'textohtmlmoduleindex' => $level);
590 $section_headings{'textohtmlmoduleindex'} = 'h1';
592 %section_commands = (%unnumbered_section_commands,
593 %section_commands);
595 make_sections_rx();
599 # This changes the markup used for {verbatim} environments, and is the
600 # best way I've found that ensures the <dl> goes on the outside of the
601 # <pre>...</pre>.
603 # Note that this *must* be done in the init file, not the python.perl
604 # style support file. The %declarations must be set before
605 # initialize() is called in the main LaTeX2HTML script (which happens
606 # before style files are loaded).
608 %declarations = ('preform' => '<div class="verbatim"><pre></pre></div>',
609 %declarations);
612 # This is used to map the link rel attributes LaTeX2HTML uses to those
613 # currently recommended by the W3C.
614 sub custom_REL_hook {
615 my($rel,$junk) = @_;
616 return 'parent' if $rel eq 'up';
617 return 'prev' if $rel eq 'previous';
618 return $rel;
621 # This is added to get rid of the long comment that follows the
622 # doctype declaration; MSIE5 on NT4 SP4 barfs on it and drops the
623 # content of the page.
624 $MY_PARTIAL_HEADER = '';
625 sub make_head_and_body($$) {
626 my($title, $body) = @_;
627 $body = " $body" unless ($body eq '');
628 my $DTDcomment = '';
629 my($version, $isolanguage) = ($HTML_VERSION, 'EN');
630 my %isolanguages = ( 'english', 'EN' , 'USenglish', 'EN.US'
631 , 'original', 'EN' , 'german' , 'DE'
632 , 'austrian', 'DE.AT', 'french' , 'FR'
633 , 'spanish', 'ES');
634 $isolanguage = $isolanguages{$default_language};
635 $isolanguage = 'EN' unless $isolanguage;
636 $title = &purify($title,1);
637 eval("\$title = ". $default_title ) unless ($title);
639 # allow user-modification of the <TITLE> tag; thanks Dan Young
640 if (defined &custom_TITLE_hook) {
641 $title = &custom_TITLE_hook($title, $toc_sec_title);
644 if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included
645 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n";
646 } else {
647 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//"
648 . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n";
650 if ($MY_PARTIAL_HEADER eq '') {
651 $STYLESHEET = $FILE.".css" unless $STYLESHEET;
652 $MY_PARTIAL_HEADER = join('',
653 ($DOCTYPE ? $DTDcomment : ''),
654 "<html>\n<head>",
655 ($BASE ? "\n<base href=\"$BASE\">" : ''),
656 "\n<link rel=\"STYLESHEET\" href=\"$STYLESHEET\" type='text/css'>",
657 ($FAVORITES_ICON
658 ? ("\n<link rel=\"SHORTCUT ICON\" href=\"" . "$FAVORITES_ICON\">")
659 : ''),
660 ($EXTERNAL_UP_LINK
661 ? ("\n<link rel='start' href='" . $EXTERNAL_UP_LINK
662 . ($EXTERNAL_UP_TITLE ?
663 "' title='$EXTERNAL_UP_TITLE'>" : "'>"))
664 : ''),
665 "\n<link rel=\"first\" href=\"$FILE.html\"",
666 ($t_title ? " title='$t_title'" : ''),
667 '>',
668 ($HAVE_TABLE_OF_CONTENTS
669 ? ("\n<link rel='contents' href='$MY_CONTENTS_PAGE'"
670 . ' title="Contents">')
671 : ''),
672 ($HAVE_GENERAL_INDEX
673 ? "\n<link rel='index' href='genindex.html' title='Index'>"
674 : ''),
675 # disable for now -- Mozilla doesn't do well with multiple indexes
676 # ($HAVE_MODULE_INDEX
677 # ? '<link rel="index" href="modindex.html" title="Module Index">'
678 # . "\n"
679 # : ''),
680 ($INFO
681 # XXX We can do this with the Python tools since the About...
682 # page always gets copied to about.html, even when we use the
683 # generated node###.html page names. Won't work with the
684 # rest of the Python doc tools.
685 ? ("\n<link rel='last' href='about.html'"
686 . " title='About this document...'>"
687 . "\n<link rel='help' href='about.html'"
688 . " title='About this document...'>")
689 : ''),
690 $more_links_mark,
691 "\n",
692 ($CHARSET && $HTML_VERSION ge "2.1"
693 ? ('<meta http-equiv="Content-Type" content="text/html; '
694 . "charset=$CHARSET\">\n")
695 : ''),
696 ($AESOP_META_TYPE
697 ? "<meta name='aesop' content='$AESOP_META_TYPE'>\n" : ''));
699 if (!$charset && $CHARSET) {
700 $charset = $CHARSET;
701 $charset =~ s/_/\-/go;
703 # Remove section number from the title for use in the
704 # <meta name='description' ...> element in the document head.
705 my $metatitle = "$title";
706 $metatitle =~ s/^\d+(\.\d+)*\s*//;
708 join('',
709 $MY_PARTIAL_HEADER,
710 &meta_information($metatitle),
711 "<title>", $title, "</title>\n</head>\n<body$body>");
714 1; # This must be the last line