blob: 3f84c8ed9fffb01f94bb09d9e50f11fa22ad3c74 [file] [log] [blame]
Fred Drake85d14c92000-07-31 17:53:45 +00001# LaTeX2HTML support base for use with Python documentation.
Fred Drake41814bc1998-05-11 18:23:35 +00002
3package main;
4
Fred Drake85d14c92000-07-31 17:53:45 +00005use L2hos;
6
Fred Drakef8636092006-05-03 01:48:24 +00007$HTML_VERSION = 4.01;
8$LOWER_CASE_TAGS = 1;
9$NO_FRENCH_QUOTES = 1;
10
11# Force Unicode support to be loaded; request UTF-8 output.
12do_require_extension('unicode');
13do_require_extension('utf8');
14$HTML_OPTIONS = 'utf8';
Fred Drake28e7b4c1998-10-20 18:14:20 +000015
Fred Drake6aa5d481998-08-11 03:14:50 +000016$MAX_LINK_DEPTH = 2;
Fred Draked7571651998-04-23 20:06:24 +000017$ADDRESS = '';
Fred Drakebc7101d1998-03-06 21:18:55 +000018
Fred Drakee194beb1998-05-19 19:38:49 +000019$NO_FOOTNODE = 1;
Fred Drakebc7101d1998-03-06 21:18:55 +000020$NUMBERED_FOOTNOTES = 1;
21
22# Python documentation uses section numbers to support references to match
23# in the printed and online versions.
24#
25$SHOW_SECTION_NUMBERS = 1;
26
Fred Drake15a159c2002-10-01 15:20:20 +000027$ICONSERVER = '.';
Fred Drakef730fc32000-08-31 07:19:07 +000028$IMAGE_TYPE = 'gif';
Fred Drakebc7101d1998-03-06 21:18:55 +000029
Fred Drake6aa5d481998-08-11 03:14:50 +000030# Control where the navigation bars should show up:
31$TOP_NAVIGATION = 1;
32$BOTTOM_NAVIGATION = 1;
33$AUTO_NAVIGATION = 0;
34
Fred Drake16816272000-09-16 20:40:44 +000035$BODYTEXT = '';
Fred Drake0739c442003-09-04 22:16:45 +000036$CHILDLINE = "\n<p><br /></p><hr class='online-navigation' />\n";
Fred Drakebc7101d1998-03-06 21:18:55 +000037$VERBOSITY = 0;
Fred Drakebc7101d1998-03-06 21:18:55 +000038
Fred Drake4d10b431998-08-07 20:51:58 +000039# default # of columns for the indexes
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000040$INDEX_COLUMNS = 2;
Fred Drake2383f6d1999-03-02 16:00:37 +000041$MODULE_INDEX_COLUMNS = 4;
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000042
Fred Drakea219b412001-10-22 16:57:49 +000043$HAVE_MODULE_INDEX = 0;
44$HAVE_GENERAL_INDEX = 0;
45$HAVE_TABLE_OF_CONTENTS = 0;
46
Fred Drakee03e1fe2002-04-05 17:34:50 +000047$AESOP_META_TYPE = 'information';
48
Fred Drakec9f2c141998-03-11 12:08:21 +000049
Fred Drakedb34a1e1998-03-10 23:02:57 +000050# A little painful, but lets us clean up the top level directory a little,
Fred Drake85d14c92000-07-31 17:53:45 +000051# and not be tied to the current directory (as far as I can tell). Testing
52# an existing definition of $mydir is needed since it cannot be computed when
53# run under mkhowto with recent versions of LaTeX2HTML, since this file is
54# not read directly by LaTeX2HTML any more. mkhowto is required to prepend
55# the required definition at the top of the actual input file.
Fred Drakedb34a1e1998-03-10 23:02:57 +000056#
Fred Drake85d14c92000-07-31 17:53:45 +000057if (!defined $mydir) {
58 use Cwd;
59 use File::Basename;
60 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
Fred Drake7a556422003-09-04 22:21:17 +000061 chop $mydir; # remove trailing '/'
Fred Drake85d14c92000-07-31 17:53:45 +000062 $mydir = getcwd() . "$dd$mydir"
63 unless $mydir =~ s|^/|/|;
64}
Fred Drakedb34a1e1998-03-10 23:02:57 +000065$LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES";
Fred Drakeb3a3ed81998-07-24 22:17:34 +000066push (@INC, $mydir);
Fred Drakebc7101d1998-03-06 21:18:55 +000067
Fred Drake235e6b11998-03-27 05:19:43 +000068($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*');
69chop $myrootdir;
70
Fred Drakebc7101d1998-03-06 21:18:55 +000071
Fred Drakea4565b01998-05-15 17:14:17 +000072# Hackish way to get the appropriate paper-*/ directory into $TEXINPUTS;
73# pass in the paper size (a4 or letter) as the environment variable PAPER
74# to add the right directory. If not given, the current directory is
75# added instead for use with HOWTO processing.
76#
77if (defined $ENV{'PAPER'}) {
78 $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey";
79}
80else {
81 $mytexinputs = getcwd() . $envkey;
82}
83$mytexinputs .= "$myrootdir${dd}texinputs";
84
85
Fred Drakeb35f2b71999-09-23 16:53:09 +000086# Change this variable to change the text added in "About this document...";
87# this should be an absolute pathname to get it right.
88#
89$ABOUT_FILE = "$myrootdir${dd}html${dd}stdabout.dat";
90
91
Fred Drake85d14c92000-07-31 17:53:45 +000092sub custom_driver_hook {
Fred Drakea4565b01998-05-15 17:14:17 +000093 #
94 # This adds the directory of the main input file to $TEXINPUTS; it
95 # seems to be sufficiently general that it should be fine for HOWTO
96 # processing.
97 #
Fred Drakecc2e48d2003-09-27 16:04:23 +000098 # XXX This still isn't quite right; we should actually be inserting
99 # $mytexinputs just before any empty entry in TEXINPUTS is one
100 # exists instead of just concatenating the pieces like we do here.
101 #
Fred Drake73c5b6602002-10-24 16:36:05 +0000102 my $file = $_[0];
Fred Drake85d14c92000-07-31 17:53:45 +0000103 my($jobname, $dir, $ext) = fileparse($file, '\..*');
104 $dir = L2hos->Make_directory_absolute($dir);
Fred Drakea4565b01998-05-15 17:14:17 +0000105 $dir =~ s/$dd$//;
106 $TEXINPUTS = "$dir$envkey$mytexinputs";
Fred Drakecc2e48d2003-09-27 16:04:23 +0000107 # Push everything into $TEXINPUTS since LaTeX2HTML doesn't pick
Georg Brandl7eb4b7d2005-07-22 21:49:32 +0000108 # this up on its own; we clear $ENV{'TEXINPUTS'} so the value set
Fred Drakecc2e48d2003-09-27 16:04:23 +0000109 # for this by the main LaTeX2HTML script doesn't contain duplicate
110 # directories.
111 if ($ENV{'TEXINPUTS'}) {
112 $TEXINPUTS .= "$envkey$ENV{'TEXINPUTS'}";
113 $ENV{'TEXINPUTS'} = undef;
114 }
115 print "\nSetting \$TEXINPUTS to $TEXINPUTS\n";
Fred Drakef8636092006-05-03 01:48:24 +0000116
117 # Not sure why we need to deal with this both here and at the top,
118 # but this is needed to actually make it work.
119 do_require_extension('utf8');
120 $charset = $utf8_str;
121 $CHARSET = $utf8_str;
122 $USE_UTF = 1;
Fred Drake191439a1999-09-22 19:50:51 +0000123}
124
Fred Drakea4565b01998-05-15 17:14:17 +0000125
Fred Drake3f26af72004-01-13 23:43:58 +0000126# $CUSTOM_BUTTONS is only used for the module index link.
Fred Drake85d14c92000-07-31 17:53:45 +0000127$CUSTOM_BUTTONS = '';
Fred Drake062bc6e1998-08-13 22:03:46 +0000128
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000129sub make_nav_sectref($$$) {
130 my($label, $linktype, $title) = @_;
Fred Drakebeb27bf1999-02-16 17:22:32 +0000131 if ($title) {
Fred Drake02c70822000-09-19 15:36:19 +0000132 if ($title =~ /\<[aA] /) {
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000133 $title =~ s/\<[aA] /<a class="sectref" rel="$linktype" /;
Fred Drake2fc88a62003-08-05 03:45:37 +0000134 $title =~ s/ HREF=/ href=/;
Fred Drake02c70822000-09-19 15:36:19 +0000135 }
136 else {
137 $title = "<span class=\"sectref\">$title</span>";
138 }
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000139 return "<b class=\"navlabel\">$label:</b>\n$title\n";
Fred Drakebeb27bf1999-02-16 17:22:32 +0000140 }
141 return '';
142}
143
Fred Draked18722b2001-01-02 22:08:48 +0000144@my_icon_tags = ();
145$my_icon_tags{'next'} = 'Next Page';
146$my_icon_tags{'next_page'} = 'Next Page';
147$my_icon_tags{'previous'} = 'Previous Page';
148$my_icon_tags{'previous_page'} = 'Previous Page';
149$my_icon_tags{'up'} = 'Up One Level';
150$my_icon_tags{'contents'} = 'Contents';
151$my_icon_tags{'index'} = 'Index';
152$my_icon_tags{'modules'} = 'Module Index';
153
Fred Drakeb31d36c2001-01-04 15:16:01 +0000154@my_icon_names = ();
155$my_icon_names{'previous_page'} = 'previous';
156$my_icon_names{'next_page'} = 'next';
157
Fred Drakef5478632002-05-23 17:59:16 +0000158sub get_my_icon($) {
Fred Drake73c5b6602002-10-24 16:36:05 +0000159 my $name = $_[0];
Fred Draked18722b2001-01-02 22:08:48 +0000160 my $text = $my_icon_tags{$name};
Fred Drakeb31d36c2001-01-04 15:16:01 +0000161 if ($my_icon_names{$name}) {
162 $name = $my_icon_names{$name};
163 }
Fred Draked18722b2001-01-02 22:08:48 +0000164 if ($text eq '') {
165 $name = 'blank';
166 }
Fred Drake85d14c92000-07-31 17:53:45 +0000167 my $iconserver = ($ICONSERVER eq '.') ? '' : "$ICONSERVER/";
Fred Drakedd3d6a02002-10-30 17:00:58 +0000168 return "<img src='$iconserver$name.$IMAGE_TYPE'\n border='0'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000169 . " height='32' alt='$text' width='32' />";
Fred Drake85d14c92000-07-31 17:53:45 +0000170}
171
Fred Drake8b34e7c2003-05-03 02:07:22 +0000172sub unlinkify($) {
173 my $text = "$_[0]";
174 $text =~ s|</[aA]>||;
175 $text =~ s|<a\s+[^>]*>||i;
176 return $text;
177}
178
179sub use_icon($$$) {
180 my($rel,$str,$title) = @_;
Fred Drake3f26af72004-01-13 23:43:58 +0000181 if ($str) {
Fred Drake8b34e7c2003-05-03 02:07:22 +0000182 my $s = "$str";
183 if ($s =~ /\<tex2html_([a-z_]+)_visible_mark\>/) {
184 my $r = get_my_icon($1);
185 $s =~ s/\<tex2html_[a-z_]+_visible_mark\>/$r/;
186 }
Fred Drakee0bdaef2004-11-05 06:42:22 +0000187 $s =~ s/<[aA] /<a rel="$rel" title="$title"\n /;
Fred Drake2fc88a62003-08-05 03:45:37 +0000188 $s =~ s/ HREF=/ href=/;
Fred Drake8b34e7c2003-05-03 02:07:22 +0000189 return $s;
Fred Draked18722b2001-01-02 22:08:48 +0000190 }
Fred Drake8b34e7c2003-05-03 02:07:22 +0000191 else {
192 return get_my_icon('blank');
193 }
Fred Drake13210ed1998-03-17 06:28:05 +0000194}
195
Fred Drakef5478632002-05-23 17:59:16 +0000196sub make_nav_panel() {
Fred Drake85d14c92000-07-31 17:53:45 +0000197 my $s;
Fred Drake8b34e7c2003-05-03 02:07:22 +0000198 # new iconic rel iconic page title
Fred Drake216b2492004-09-09 05:13:52 +0000199 my $next = use_icon('next', $NEXT, unlinkify($NEXT_TITLE));
200 my $up = use_icon('parent', $UP, unlinkify($UP_TITLE));
201 my $previous = use_icon('prev', $PREVIOUS, unlinkify($PREVIOUS_TITLE));
202 my $contents = use_icon('contents', $CONTENTS, 'Table of Contents');
203 my $index = use_icon('index', $INDEX, 'Index');
Fred Drake85d14c92000-07-31 17:53:45 +0000204 if (!$CUSTOM_BUTTONS) {
Fred Drake8b34e7c2003-05-03 02:07:22 +0000205 $CUSTOM_BUTTONS = get_my_icon('blank');
Fred Drake85d14c92000-07-31 17:53:45 +0000206 }
207 $s = ('<table align="center" width="100%" cellpadding="0" cellspacing="2">'
208 . "\n<tr>"
209 # left-hand side
Fred Drake216b2492004-09-09 05:13:52 +0000210 . "\n<td class='online-navigation'>$previous</td>"
211 . "\n<td class='online-navigation'>$up</td>"
212 . "\n<td class='online-navigation'>$next</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000213 # title box
Fred Drakef730fc32000-08-31 07:19:07 +0000214 . "\n<td align=\"center\" width=\"100%\">$t_title</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000215 # right-hand side
Fred Drake216b2492004-09-09 05:13:52 +0000216 . "\n<td class='online-navigation'>$contents</td>"
Fred Drake0739c442003-09-04 22:16:45 +0000217 # module index
218 . "\n<td class='online-navigation'>$CUSTOM_BUTTONS</td>"
Fred Drake216b2492004-09-09 05:13:52 +0000219 . "\n<td class='online-navigation'>$index</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000220 . "\n</tr></table>\n"
221 # textual navigation
Fred Drake0739c442003-09-04 22:16:45 +0000222 . "<div class='online-navigation'>\n"
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000223 . make_nav_sectref("Previous", "prev", $PREVIOUS_TITLE)
224 . make_nav_sectref("Up", "parent", $UP_TITLE)
225 . make_nav_sectref("Next", "next", $NEXT_TITLE)
Fred Drake0739c442003-09-04 22:16:45 +0000226 . "</div>\n"
Fred Drake4640e132000-07-31 20:13:23 +0000227 );
Fred Drake85d14c92000-07-31 17:53:45 +0000228 # remove these; they are unnecessary and cause errors from validation
229 $s =~ s/ NAME="tex2html\d+"\n */ /g;
230 return $s;
231}
232
Fred Drakefb6499f2001-10-26 14:16:23 +0000233sub add_child_links {
234 my $toc = add_real_child_links(@_);
235 $toc =~ s|\s*</[aA]>|</a>|g;
236 $toc =~ s/ NAME=\"tex2html\d+\"\s*href=/ href=/gi;
Fred Drake2fc88a62003-08-05 03:45:37 +0000237 $toc =~ s|</UL>(\s*<BR( /)?>)?|</ul>|gi;
Fred Drake0739c442003-09-04 22:16:45 +0000238 if ($toc =~ / NAME=["']CHILD_LINKS["']/) {
239 return "<div class='online-navigation'>\n$toc</div>\n";
240 }
Fred Drakefb6499f2001-10-26 14:16:23 +0000241 return $toc;
242}
243
Fred Drakef5478632002-05-23 17:59:16 +0000244sub get_version_text() {
Fred Drake7497bd32000-10-25 16:18:10 +0000245 if ($PACKAGE_VERSION ne '' && $t_date) {
246 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000247 . "Release $PACKAGE_VERSION$RELEASE_INFO,"
Fred Drake7497bd32000-10-25 16:18:10 +0000248 . " documentation updated on $t_date.</span>");
249 }
250 if ($PACKAGE_VERSION ne '') {
251 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000252 . "Release $PACKAGE_VERSION$RELEASE_INFO.</span>");
Fred Drake7497bd32000-10-25 16:18:10 +0000253 }
254 if ($t_date) {
255 return ("<span class=\"release-info\">Documentation released on "
256 . "$t_date.</span>");
257 }
258 return '';
259}
260
Fred Drake85d14c92000-07-31 17:53:45 +0000261
Fred Drakef5478632002-05-23 17:59:16 +0000262sub top_navigation_panel() {
Fred Drake0c1b2532004-10-29 19:47:52 +0000263 return "\n<div id='top-navigation-panel' xml:id='top-navigation-panel'>\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000264 . make_nav_panel()
Fred Drake11b138f2003-09-11 04:14:20 +0000265 . "<hr /></div>\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000266}
267
Fred Drakef5478632002-05-23 17:59:16 +0000268sub bot_navigation_panel() {
Fred Drake0739c442003-09-04 22:16:45 +0000269 return "\n<div class='online-navigation'>\n"
Fred Drake859c46a2003-09-04 19:30:15 +0000270 . "<p></p><hr />\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000271 . make_nav_panel()
Fred Drake859c46a2003-09-04 19:30:15 +0000272 . "</div>\n"
Fred Drake2fc88a62003-08-05 03:45:37 +0000273 . "<hr />\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000274 . get_version_text()
275 . "\n";
Fred Drake64bdc241998-04-17 02:14:12 +0000276}
277
278sub add_link {
279 # Returns a pair (iconic link, textual link)
280 my($icon, $current_file, @link) = @_;
281 my($dummy, $file, $title) = split($delim,
Fred Drake7a556422003-09-04 22:21:17 +0000282 $section_info{join(' ',@link)});
Fred Draked18722b2001-01-02 22:08:48 +0000283 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
284 my $r = get_my_icon($1);
285 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
286 }
Fred Drake64bdc241998-04-17 02:14:12 +0000287 if ($title && ($file ne $current_file)) {
288 $title = purify($title);
Fred Drake7a556422003-09-04 22:21:17 +0000289 $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
290 return (make_href($file, $icon), make_href($file, "$title"))
291 }
Fred Draked18722b2001-01-02 22:08:48 +0000292 elsif ($icon eq get_my_icon('up') && $EXTERNAL_UP_LINK) {
Fred Drake7a556422003-09-04 22:21:17 +0000293 return (make_href($EXTERNAL_UP_LINK, $icon),
294 make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
295 }
Fred Draked18722b2001-01-02 22:08:48 +0000296 elsif ($icon eq get_my_icon('previous')
Fred Drake7a556422003-09-04 22:21:17 +0000297 && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
298 return (make_href($EXTERNAL_PREV_LINK, $icon),
299 make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
300 }
Fred Draked18722b2001-01-02 22:08:48 +0000301 elsif ($icon eq get_my_icon('next')
Fred Drake7a556422003-09-04 22:21:17 +0000302 && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
303 return (make_href($EXTERNAL_DOWN_LINK, $icon),
304 make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
305 }
Fred Drake85d14c92000-07-31 17:53:45 +0000306 return (&inactive_img($icon), "");
Fred Drake64bdc241998-04-17 02:14:12 +0000307}
308
Fred Drakef5478632002-05-23 17:59:16 +0000309sub add_special_link($$$) {
Fred Drake64bdc241998-04-17 02:14:12 +0000310 my($icon, $file, $current_file) = @_;
Fred Draked18722b2001-01-02 22:08:48 +0000311 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
312 my $r = get_my_icon($1);
313 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
314 }
Fred Drake85d14c92000-07-31 17:53:45 +0000315 return (($file && ($file ne $current_file))
316 ? make_href($file, $icon)
317 : undef)
Fred Drake64bdc241998-04-17 02:14:12 +0000318}
319
Fred Drake85d14c92000-07-31 17:53:45 +0000320# The img_tag() function seems only to be called with the parameter
321# 'anchor_invisible_mark', which we want to turn into ''. Since
322# replace_icon_marks() is the only interesting caller, and all it really
323# does is call img_tag(), we can just define the hook alternative to be
324# a no-op instead.
325#
326sub replace_icons_hook {}
Fred Drakebc7101d1998-03-06 21:18:55 +0000327
Fred Drake50cdd971999-02-19 23:04:59 +0000328sub do_cmd_arabic {
329 # get rid of that nasty <SPAN CLASS="arabic">...</SPAN>
Fred Drake73c5b6602002-10-24 16:36:05 +0000330 my($ctr, $val, $id, $text) = &read_counter_value($_[0]);
Fred Drake85d14c92000-07-31 17:53:45 +0000331 return ($val ? farabic($val) : "0") . $text;
Fred Drake50cdd971999-02-19 23:04:59 +0000332}
333
334
Fred Drakef5478632002-05-23 17:59:16 +0000335sub gen_index_id($$) {
Fred Drakebc7101d1998-03-06 21:18:55 +0000336 # this is used to ensure common index key generation and a stable sort
Fred Drakef5478632002-05-23 17:59:16 +0000337 my($str, $extra) = @_;
Fred Drake64bdc241998-04-17 02:14:12 +0000338 sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
Fred Drakebc7101d1998-03-06 21:18:55 +0000339}
340
Fred Drakef5478632002-05-23 17:59:16 +0000341sub insert_index($$$$$) {
342 my($mark, $datafile, $columns, $letters, $prefix) = @_;
Fred Drake4d10b431998-08-07 20:51:58 +0000343 my $prog = "$myrootdir/tools/buildindex.py";
344 my $index;
345 if ($letters) {
Fred Drake7a556422003-09-04 22:21:17 +0000346 $index = `$prog --columns $columns --letters $datafile`;
Fred Drake4d10b431998-08-07 20:51:58 +0000347 }
348 else {
Fred Drake7a556422003-09-04 22:21:17 +0000349 $index = `$prog --columns $columns $datafile`;
Fred Drake4d10b431998-08-07 20:51:58 +0000350 }
Fred Drakec5681732000-09-12 20:13:04 +0000351 if (!s/$mark/$prefix$index/) {
352 print "\nCould not locate index mark: $mark";
353 }
Fred Drake64bdc241998-04-17 02:14:12 +0000354}
355
Fred Drakef5478632002-05-23 17:59:16 +0000356sub add_idx() {
Fred Drake9bbdce51999-01-19 16:30:10 +0000357 print "\nBuilding HTML for the index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000358 close(IDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000359 insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
Fred Drake13210ed1998-03-17 06:28:05 +0000360}
Fred Drakebc7101d1998-03-06 21:18:55 +0000361
362
363$idx_module_mark = '<tex2html_idx_module_mark>';
364$idx_module_title = 'Module Index';
365
Fred Drakef5478632002-05-23 17:59:16 +0000366sub add_module_idx() {
Fred Drake9bbdce51999-01-19 16:30:10 +0000367 print "\nBuilding HTML for the module index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000368 my $key;
Fred Drake2383f6d1999-03-02 16:00:37 +0000369 my $first = 1;
370 my $prevplat = '';
371 my $allthesame = 1;
372 my $prefix = '';
373 foreach $key (keys %Modules) {
Fred Drake7a556422003-09-04 22:21:17 +0000374 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
375 my $plat = "$ModulePlatforms{$key}";
376 $plat = ''
377 if ($plat eq $IGNORE_PLATFORM_ANNOTATION);
378 if (!$first) {
379 $allthesame = 0
380 if ($prevplat ne $plat);
381 }
382 else { $first = 0; }
383 $prevplat = $plat;
Fred Drake2383f6d1999-03-02 16:00:37 +0000384 }
Fred Drake64bdc241998-04-17 02:14:12 +0000385 open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
Fred Drake235e6b11998-03-27 05:19:43 +0000386 foreach $key (keys %Modules) {
Fred Drake7a556422003-09-04 22:21:17 +0000387 # dump the line in the data file; just use a dummy seqno field
388 my $nkey = $1;
389 my $moditem = "$Modules{$key}";
390 my $plat = '';
391 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
392 if ($ModulePlatforms{$key} && !$allthesame) {
393 $plat = (" <em>(<span class=\"platform\">$ModulePlatforms{$key}"
394 . '</span>)</em>');
395 }
396 print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP
Fred Drakedce975c2001-06-20 21:31:36 +0000397 . "<tt class=\"module\">$key</tt>$plat###\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000398 }
Fred Drake235e6b11998-03-27 05:19:43 +0000399 close(MODIDXFILE);
Fred Drake42181db2001-01-09 22:02:10 +0000400
401 if ($GLOBAL_MODULE_INDEX) {
402 $prefix = <<MODULE_INDEX_PREFIX;
403
404<p> This index only lists modules documented in this manual.
405 The <em class="citetitle"><a href="$GLOBAL_MODULE_INDEX">Global Module
406 Index</a></em> lists all modules that are documented in this set
407 of manuals.</p>
408MODULE_INDEX_PREFIX
409 }
Fred Drake2383f6d1999-03-02 16:00:37 +0000410 if (!$allthesame) {
Fred Drake7a556422003-09-04 22:21:17 +0000411 $prefix .= <<PLAT_DISCUSS;
Fred Drake2383f6d1999-03-02 16:00:37 +0000412
413<p> Some module names are followed by an annotation indicating what
414platform they are available on.</p>
415
416PLAT_DISCUSS
417 }
418 insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
Fred Drake7a556422003-09-04 22:21:17 +0000419 $prefix);
Fred Drakebc7101d1998-03-06 21:18:55 +0000420}
421
Fred Drake235e6b11998-03-27 05:19:43 +0000422# replace both indexes as needed:
Fred Drake85d14c92000-07-31 17:53:45 +0000423sub add_idx_hook {
Fred Drakeb3a3ed81998-07-24 22:17:34 +0000424 add_idx() if (/$idx_mark/);
Fred Drake2383f6d1999-03-02 16:00:37 +0000425 process_python_state();
Fred Drakec5681732000-09-12 20:13:04 +0000426 if ($MODULE_INDEX_FILE) {
427 local ($_);
428 open(MYFILE, "<$MODULE_INDEX_FILE");
429 sysread(MYFILE, $_, 1024*1024);
430 close(MYFILE);
431 add_module_idx();
432 open(MYFILE,">$MODULE_INDEX_FILE");
433 print MYFILE $_;
434 close(MYFILE);
435 }
Fred Drake235e6b11998-03-27 05:19:43 +0000436}
Fred Drakebc7101d1998-03-06 21:18:55 +0000437
Fred Drakebc7101d1998-03-06 21:18:55 +0000438
Fred Drake191439a1999-09-22 19:50:51 +0000439# In addition to the standard stuff, add label to allow named node files and
440# support suppression of the page complete (for HTML Help use).
Fred Drake095f8172003-06-27 18:26:01 +0000441$MY_CONTENTS_PAGE = '';
Fred Drakebc7101d1998-03-06 21:18:55 +0000442sub do_cmd_tableofcontents {
443 local($_) = @_;
444 $TITLE = $toc_title;
445 $tocfile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000446 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000447 anchor_label('contents', $CURRENT_FILE, $_); # this is added
Fred Drake095f8172003-06-27 18:26:01 +0000448 $MY_CONTENTS_PAGE = "$CURRENT_FILE";
Fred Drakee0bdaef2004-11-05 06:42:22 +0000449 join('', "\\tableofchildlinks[off]", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000450 , make_section_heading($toc_title, 'h2'), $toc_mark
451 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000452}
453# In addition to the standard stuff, add label to allow named node files.
454sub do_cmd_listoffigures {
455 local($_) = @_;
456 $TITLE = $lof_title;
457 $loffile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000458 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000459 anchor_label('lof', $CURRENT_FILE, $_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000460 join('', "<br />\n", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000461 , make_section_heading($lof_title, 'h2'), $lof_mark
462 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000463}
464# In addition to the standard stuff, add label to allow named node files.
465sub do_cmd_listoftables {
466 local($_) = @_;
467 $TITLE = $lot_title;
468 $lotfile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000469 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000470 anchor_label('lot', $CURRENT_FILE, $_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000471 join('', "<br />\n", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000472 , make_section_heading($lot_title, 'h2'), $lot_mark
473 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000474}
475# In addition to the standard stuff, add label to allow named node files.
476sub do_cmd_textohtmlinfopage {
477 local($_) = @_;
Fred Drake7a556422003-09-04 22:21:17 +0000478 if ($INFO) { #
479 anchor_label("about",$CURRENT_FILE,$_); # this is added
480 } #
481 my $the_version = ''; # and the rest is
482 if ($t_date) { # mostly ours
483 $the_version = ",\n$t_date";
484 if ($PACKAGE_VERSION) {
485 $the_version .= ", Release $PACKAGE_VERSION$RELEASE_INFO";
486 }
Fred Drake15796f71998-11-30 19:25:47 +0000487 }
Fred Drake9443dc32001-08-10 20:12:09 +0000488 my $about;
489 open(ABOUT, "<$ABOUT_FILE") || die "\n$!\n";
490 sysread(ABOUT, $about, 1024*1024);
491 close(ABOUT);
Fred Drake15796f71998-11-30 19:25:47 +0000492 $_ = (($INFO == 1)
Fred Drakeb35f2b71999-09-23 16:53:09 +0000493 ? join('',
494 $close_all,
495 "<strong>$t_title</strong>$the_version\n",
Fred Drake9443dc32001-08-10 20:12:09 +0000496 $about,
Fred Drakeb35f2b71999-09-23 16:53:09 +0000497 $open_all, $_)
498 : join('', $close_all, $INFO,"\n", $open_all, $_));
Fred Drake15796f71998-11-30 19:25:47 +0000499 $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000500}
501
Fred Drakec6f3c8b2004-08-19 01:37:48 +0000502$GENERAL_INDEX_FILE = '';
503$MODULE_INDEX_FILE = '';
504
Fred Drakebc7101d1998-03-06 21:18:55 +0000505# $idx_mark will be replaced with the real index at the end
506sub do_cmd_textohtmlindex {
507 local($_) = @_;
508 $TITLE = $idx_title;
509 $idxfile = $CURRENT_FILE;
Fred Drakec6f3c8b2004-08-19 01:37:48 +0000510 $GENERAL_INDEX_FILE = "$CURRENT_FILE";
Fred Drake235e6b11998-03-27 05:19:43 +0000511 if (%index_labels) { make_index_labels(); }
512 if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); }
Fred Drakebc7101d1998-03-06 21:18:55 +0000513 else { $preindex = ''; }
Fred Drake235e6b11998-03-27 05:19:43 +0000514 my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
Fred Drakef5478632002-05-23 17:59:16 +0000515 my($pre, $post) = minimize_open_tags($heading);
Fred Drake7a556422003-09-04 22:21:17 +0000516 anchor_label('genindex',$CURRENT_FILE,$_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000517 return "<br />\n" . $pre . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000518}
519
520# $idx_module_mark will be replaced with the real index at the end
521sub do_cmd_textohtmlmoduleindex {
522 local($_) = @_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000523 $TITLE = $idx_module_title;
Fred Drakec5681732000-09-12 20:13:04 +0000524 anchor_label('modindex', $CURRENT_FILE, $_);
525 $MODULE_INDEX_FILE = "$CURRENT_FILE";
Fred Drake2fc88a62003-08-05 03:45:37 +0000526 $_ = ('<p></p>' . make_section_heading($idx_module_title, 'h2')
Fred Drakec5681732000-09-12 20:13:04 +0000527 . $idx_module_mark . $_);
528 return $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000529}
530
Fred Drakec5681732000-09-12 20:13:04 +0000531# The bibliography and the index should be treated as separate
532# sections in their own HTML files. The \bibliography{} command acts
533# as a sectioning command that has the desired effect. But when the
534# bibliography is constructed manually using the thebibliography
535# environment, or when using the theindex environment it is not
536# possible to use the normal sectioning mechanism. This subroutine
537# inserts a \bibliography{} or a dummy \textohtmlindex command just
538# before the appropriate environments to force sectioning.
Fred Drakebc7101d1998-03-06 21:18:55 +0000539
Fred Drake7a556422003-09-04 22:21:17 +0000540# XXX This *assumes* that if there are two {theindex} environments,
541# the first is the module index and the second is the standard
542# index. This is sufficient for the current Python documentation,
543# but that's about it.
Fred Drakebc7101d1998-03-06 21:18:55 +0000544
545sub add_bbl_and_idx_dummy_commands {
Fred Drake11916921998-04-02 22:30:57 +0000546 my $id = $global{'max_id'};
Fred Drakebc7101d1998-03-06 21:18:55 +0000547
Fred Drakea219b412001-10-22 16:57:49 +0000548 if (/[\\]tableofcontents/) {
549 $HAVE_TABLE_OF_CONTENTS = 1;
550 }
Fred Drakebc7101d1998-03-06 21:18:55 +0000551 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
Fred Drake191439a1999-09-22 19:50:51 +0000552 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo;
Fred Drake85d14c92000-07-31 17:53:45 +0000553 my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/);
554 if (scalar(@parts) == 3) {
555 # Be careful to re-write the string in place, since $_ is *not*
556 # returned explicity; *** nasty side-effect dependency! ***
Fred Drakebb7775a2001-12-04 17:03:54 +0000557 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
Fred Drake85d14c92000-07-31 17:53:45 +0000558 print "\nadd_bbl_and_idx_dummy_commands ==> adding module index";
559 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)"
560 . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
Fred Drake73c5b6602002-10-24 16:36:05 +0000561 s/$rx/\\textohtmlmoduleindex $1 \\textohtmlindex $2/o;
Fred Drake85d14c92000-07-31 17:53:45 +0000562 # Add a button to the navigation areas:
Fred Drakeaaa23852000-09-14 22:20:41 +0000563 $CUSTOM_BUTTONS .= ('<a href="modindex.html" title="Module Index">'
Fred Draked18722b2001-01-02 22:08:48 +0000564 . get_my_icon('modules')
Fred Drakeaaa23852000-09-14 22:20:41 +0000565 . '</a>');
Fred Drakea219b412001-10-22 16:57:49 +0000566 $HAVE_MODULE_INDEX = 1;
567 $HAVE_GENERAL_INDEX = 1;
568 }
569 elsif (scalar(@parts) == 2) {
Fred Drakebb7775a2001-12-04 17:03:54 +0000570 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
571 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
Fred Drake73c5b6602002-10-24 16:36:05 +0000572 s/$rx/\\textohtmlindex $1/o;
Fred Drakea219b412001-10-22 16:57:49 +0000573 $HAVE_GENERAL_INDEX = 1;
Fred Drake11916921998-04-02 22:30:57 +0000574 }
Fred Drakebb7775a2001-12-04 17:03:54 +0000575 elsif (scalar(@parts) == 1) {
576 print "\nadd_bbl_and_idx_dummy_commands ==> no index found";
Fred Draked18722b2001-01-02 22:08:48 +0000577 $CUSTOM_BUTTONS .= get_my_icon('blank');
Fred Drake85d14c92000-07-31 17:53:45 +0000578 $global{'max_id'} = $id; # not sure why....
579 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
Fred Drake7a556422003-09-04 22:21:17 +0000580 s/[\\]printindex/\\textohtmlindex /o;
Fred Drakebb7775a2001-12-04 17:03:54 +0000581 }
582 else {
583 die "\n\nBad number of index environments!\n\n";
584 }
Fred Drake11916921998-04-02 22:30:57 +0000585 #----------------------------------------------------------------------
Fred Drake64bdc241998-04-17 02:14:12 +0000586 lib_add_bbl_and_idx_dummy_commands()
Fred Drake11916921998-04-02 22:30:57 +0000587 if defined(&lib_add_bbl_and_idx_dummy_commands);
Fred Drakebc7101d1998-03-06 21:18:55 +0000588}
589
Fred Drakec5681732000-09-12 20:13:04 +0000590# The bibliographic references, the appendices, the lists of figures
591# and tables etc. must appear in the contents table at the same level
592# as the outermost sectioning command. This subroutine finds what is
593# the outermost level and sets the above to the same level;
Fred Drakebc7101d1998-03-06 21:18:55 +0000594
Fred Drake13210ed1998-03-17 06:28:05 +0000595sub set_depth_levels {
596 # Sets $outermost_level
Fred Drake11916921998-04-02 22:30:57 +0000597 my $level;
Fred Drake13210ed1998-03-17 06:28:05 +0000598 #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
599 foreach $level ("part", "chapter", "section", "subsection",
Fred Drake7a556422003-09-04 22:21:17 +0000600 "subsubsection", "paragraph") {
601 last if (($outermost_level) = /\\($level)$delimiter_rx/);
Fred Drake13210ed1998-03-17 06:28:05 +0000602 }
603 $level = ($outermost_level ? $section_commands{$outermost_level} :
Fred Drake7a556422003-09-04 22:21:17 +0000604 do {$outermost_level = 'section'; 3;});
Fred Drakebc7101d1998-03-06 21:18:55 +0000605
Fred Drake13210ed1998-03-17 06:28:05 +0000606 #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
Fred Drake7a556422003-09-04 22:21:17 +0000607 if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
608 $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
Fred Drake13210ed1998-03-17 06:28:05 +0000609 } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
Fred Drakebc7101d1998-03-06 21:18:55 +0000610
Fred Drake64bdc241998-04-17 02:14:12 +0000611 %unnumbered_section_commands = ('tableofcontents' => $level,
Fred Drake7a556422003-09-04 22:21:17 +0000612 'listoffigures' => $level,
613 'listoftables' => $level,
614 'bibliography' => $level,
615 'textohtmlindex' => $level,
616 'textohtmlmoduleindex' => $level);
Fred Drake64bdc241998-04-17 02:14:12 +0000617 $section_headings{'textohtmlmoduleindex'} = 'h1';
Fred Drakebc7101d1998-03-06 21:18:55 +0000618
Fred Drake64bdc241998-04-17 02:14:12 +0000619 %section_commands = (%unnumbered_section_commands,
Fred Drake7a556422003-09-04 22:21:17 +0000620 %section_commands);
Fred Drake11916921998-04-02 22:30:57 +0000621
622 make_sections_rx();
Fred Drake13210ed1998-03-17 06:28:05 +0000623}
Fred Drakebc7101d1998-03-06 21:18:55 +0000624
625
Fred Drake1072e461998-04-12 02:16:34 +0000626# This changes the markup used for {verbatim} environments, and is the
Fred Drake95474f91999-02-09 18:45:50 +0000627# best way I've found that ensures the <dl> goes on the outside of the
Fred Drake1072e461998-04-12 02:16:34 +0000628# <pre>...</pre>.
629#
630# Note that this *must* be done in the init file, not the python.perl
Fred Drakec5681732000-09-12 20:13:04 +0000631# style support file. The %declarations must be set before
632# initialize() is called in the main LaTeX2HTML script (which happens
633# before style files are loaded).
Fred Drake1072e461998-04-12 02:16:34 +0000634#
Fred Drake8a5e6792002-04-15 18:41:31 +0000635%declarations = ('preform' => '<div class="verbatim"><pre></pre></div>',
Fred Drake7a556422003-09-04 22:21:17 +0000636 %declarations);
Fred Drake1072e461998-04-12 02:16:34 +0000637
Fred Drakee15956b2000-04-03 04:51:13 +0000638
Fred Drakedcb16ac2004-11-10 07:48:17 +0000639# This is a modified version of what's provided by LaTeX2HTML; see the
640# comment on the middle stanza for an explanation of why we keep our
641# own version.
642#
643# This routine must be called once on the text only,
644# else it will "eat up" sensitive constructs.
645sub text_cleanup {
646 # MRO: replaced $* with /m
647 s/(\s*\n){3,}/\n\n/gom; # Replace consecutive blank lines with one
648 s/<(\/?)P>\s*(\w)/<$1P>\n$2/gom; # clean up paragraph starts and ends
649 s/$O\d+$C//go; # Get rid of bracket id's
650 s/$OP\d+$CP//go; # Get rid of processed bracket id's
651 s/(<!)?--?(>)?/(length($1) || length($2)) ? "$1--$2" : "-"/ge;
652 # Spacing commands
653 s/\\( |$)/ /go;
654 #JKR: There should be no more comments in the source now.
655 #s/([^\\]?)%/$1/go; # Remove the comment character
656 # Cannot treat \, as a command because , is a delimiter ...
657 s/\\,/ /go;
658 # Replace tilde's with non-breaking spaces
659 s/ *~/&nbsp;/g;
660
661 # This is why we have this copy of this routine; the following
662 # isn't so desirable as the author/maintainers of LaTeX2HTML seem
663 # to think. It's not commented out in the main script, so we have
664 # to override the whole thing. In particular, we don't want empty
665 # table cells to disappear.
666
667 ### DANGEROUS ?? ###
668 # remove redundant (not <P></P>) empty tags, incl. with attributes
669 #s/\n?<([^PD >][^>]*)>\s*<\/\1>//g;
670 #s/\n?<([^PD >][^>]*)>\s*<\/\1>//g;
671 # remove redundant empty tags (not </P><P> or <TD> or <TH>)
672 #s/<\/(TT|[^PTH][A-Z]+)><\1>//g;
673 #s/<([^PD ]+)(\s[^>]*)?>\n*<\/\1>//g;
674
675 #JCL(jcl-hex)
676 # Replace ^^ special chars (according to p.47 of the TeX book)
677 # Useful when coming from the .aux file (german umlauts, etc.)
678 s/\^\^([^0-9a-f])/chr((64+ord($1))&127)/ge;
679 s/\^\^([0-9a-f][0-9a-f])/chr(hex($1))/ge;
680}
681
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000682# This is used to map the link rel attributes LaTeX2HTML uses to those
683# currently recommended by the W3C.
684sub custom_REL_hook {
685 my($rel,$junk) = @_;
686 return 'parent' if $rel eq 'up';
687 return 'prev' if $rel eq 'previous';
688 return $rel;
689}
690
Fred Drakec5681732000-09-12 20:13:04 +0000691# This is added to get rid of the long comment that follows the
692# doctype declaration; MSIE5 on NT4 SP4 barfs on it and drops the
693# content of the page.
Fred Drakea219b412001-10-22 16:57:49 +0000694$MY_PARTIAL_HEADER = '';
Fred Drakef5478632002-05-23 17:59:16 +0000695sub make_head_and_body($$) {
Fred Drake85d14c92000-07-31 17:53:45 +0000696 my($title, $body) = @_;
Fred Drake16816272000-09-16 20:40:44 +0000697 $body = " $body" unless ($body eq '');
Fred Drake85d14c92000-07-31 17:53:45 +0000698 my $DTDcomment = '';
699 my($version, $isolanguage) = ($HTML_VERSION, 'EN');
700 my %isolanguages = ( 'english', 'EN' , 'USenglish', 'EN.US'
701 , 'original', 'EN' , 'german' , 'DE'
702 , 'austrian', 'DE.AT', 'french' , 'FR'
703 , 'spanish', 'ES');
Fred Drakee15956b2000-04-03 04:51:13 +0000704 $isolanguage = $isolanguages{$default_language};
705 $isolanguage = 'EN' unless $isolanguage;
706 $title = &purify($title,1);
707 eval("\$title = ". $default_title ) unless ($title);
708
Fred Drake2fc88a62003-08-05 03:45:37 +0000709 # allow user-modification of the <title> tag; thanks Dan Young
Fred Drakee15956b2000-04-03 04:51:13 +0000710 if (defined &custom_TITLE_hook) {
Fred Drake7a556422003-09-04 22:21:17 +0000711 $title = &custom_TITLE_hook($title, $toc_sec_title);
Fred Drakee15956b2000-04-03 04:51:13 +0000712 }
713
714 if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included
Fred Drake7a556422003-09-04 22:21:17 +0000715 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000716 } else {
Fred Drake7a556422003-09-04 22:21:17 +0000717 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//"
718 . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000719 }
Fred Drakea219b412001-10-22 16:57:49 +0000720 if ($MY_PARTIAL_HEADER eq '') {
Fred Drake0384be32004-11-05 05:06:08 +0000721 my $favicon = '';
722 if ($FAVORITES_ICON) {
723 my($myname, $mydir, $myext) = fileparse($FAVORITES_ICON, '\..*');
724 my $favtype = '';
725 if ($myext eq '.gif' || $myext eq '.png') {
726 $myext =~ s/^[.]//;
727 $favtype = " type=\"image/$myext\"";
728 }
729 $favicon = (
730 "\n<link rel=\"SHORTCUT ICON\" href=\"$FAVORITES_ICON\""
731 . "$favtype />");
732 }
Fred Drakea219b412001-10-22 16:57:49 +0000733 $STYLESHEET = $FILE.".css" unless $STYLESHEET;
734 $MY_PARTIAL_HEADER = join('',
Fred Drakedd3d6a02002-10-30 17:00:58 +0000735 ($DOCTYPE ? $DTDcomment : ''),
Fred Drake98b25762003-05-02 18:21:22 +0000736 "<html>\n<head>",
Fred Drake2fc88a62003-08-05 03:45:37 +0000737 ($BASE ? "\n<base href=\"$BASE\" />" : ''),
738 "\n<link rel=\"STYLESHEET\" href=\"$STYLESHEET\" type='text/css'",
739 " />",
Fred Drake0384be32004-11-05 05:06:08 +0000740 $favicon,
Fred Drake23949002002-10-30 21:51:18 +0000741 ($EXTERNAL_UP_LINK
Fred Drake98b25762003-05-02 18:21:22 +0000742 ? ("\n<link rel='start' href='" . $EXTERNAL_UP_LINK
743 . ($EXTERNAL_UP_TITLE ?
Fred Drake2fc88a62003-08-05 03:45:37 +0000744 "' title='$EXTERNAL_UP_TITLE' />" : "' />"))
Fred Drake23949002002-10-30 21:51:18 +0000745 : ''),
Fred Drake98b25762003-05-02 18:21:22 +0000746 "\n<link rel=\"first\" href=\"$FILE.html\"",
Fred Drake23949002002-10-30 21:51:18 +0000747 ($t_title ? " title='$t_title'" : ''),
Fred Drake2fc88a62003-08-05 03:45:37 +0000748 ' />',
Fred Drakea219b412001-10-22 16:57:49 +0000749 ($HAVE_TABLE_OF_CONTENTS
Fred Drake095f8172003-06-27 18:26:01 +0000750 ? ("\n<link rel='contents' href='$MY_CONTENTS_PAGE'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000751 . ' title="Contents" />')
Fred Drakea219b412001-10-22 16:57:49 +0000752 : ''),
753 ($HAVE_GENERAL_INDEX
Fred Drakec6f3c8b2004-08-19 01:37:48 +0000754 ? ("\n<link rel='index' href='$GENERAL_INDEX_FILE'"
755 . " title='Index' />")
Fred Drakea219b412001-10-22 16:57:49 +0000756 : ''),
757 # disable for now -- Mozilla doesn't do well with multiple indexes
758 # ($HAVE_MODULE_INDEX
Fred Drakec6f3c8b2004-08-19 01:37:48 +0000759 # ? ("<link rel="index" href='$MODULE_INDEX_FILE'"
760 # . " title='Module Index' />\n")
Fred Drakea219b412001-10-22 16:57:49 +0000761 # : ''),
Fred Drake23949002002-10-30 21:51:18 +0000762 ($INFO
763 # XXX We can do this with the Python tools since the About...
764 # page always gets copied to about.html, even when we use the
765 # generated node###.html page names. Won't work with the
766 # rest of the Python doc tools.
Fred Drake98b25762003-05-02 18:21:22 +0000767 ? ("\n<link rel='last' href='about.html'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000768 . " title='About this document...' />"
Fred Drake98b25762003-05-02 18:21:22 +0000769 . "\n<link rel='help' href='about.html'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000770 . " title='About this document...' />")
Fred Drake23949002002-10-30 21:51:18 +0000771 : ''),
Fred Drakedd3d6a02002-10-30 17:00:58 +0000772 $more_links_mark,
Fred Drake0e2e6872002-10-30 19:55:23 +0000773 "\n",
Fred Drakedd3d6a02002-10-30 17:00:58 +0000774 ($CHARSET && $HTML_VERSION ge "2.1"
775 ? ('<meta http-equiv="Content-Type" content="text/html; '
Fred Drake2fc88a62003-08-05 03:45:37 +0000776 . "charset=$CHARSET\" />\n")
Fred Drakedd3d6a02002-10-30 17:00:58 +0000777 : ''),
778 ($AESOP_META_TYPE
Fred Drake2fc88a62003-08-05 03:45:37 +0000779 ? "<meta name='aesop' content='$AESOP_META_TYPE' />\n" : ''));
Fred Drakea219b412001-10-22 16:57:49 +0000780 }
Fred Drake0e2e6872002-10-30 19:55:23 +0000781 if (!$charset && $CHARSET) {
782 $charset = $CHARSET;
783 $charset =~ s/_/\-/go;
784 }
Fred Drakedd3d6a02002-10-30 17:00:58 +0000785 join('',
786 $MY_PARTIAL_HEADER,
Fred Drakedd3d6a02002-10-30 17:00:58 +0000787 "<title>", $title, "</title>\n</head>\n<body$body>");
Fred Drakee15956b2000-04-03 04:51:13 +0000788}
789
Fred Drake2fc88a62003-08-05 03:45:37 +0000790sub replace_morelinks {
791 $more_links =~ s/ REL=/ rel=/g;
792 $more_links =~ s/ HREF=/ href=/g;
Fred Drakee0bdaef2004-11-05 06:42:22 +0000793 $more_links =~ s/<LINK /<link /g;
794 $more_links =~ s/">/" \/>/g;
Fred Drake2fc88a62003-08-05 03:45:37 +0000795 $_ =~ s/$more_links_mark/$more_links/e;
796}
797
Fred Drake7a556422003-09-04 22:21:17 +00007981; # This must be the last line