blob: 7c5d1230d47c066793865cd88ced16855d29af72 [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
Thomas Wouters477c8d52006-05-27 19:21:47 +00007$HTML_VERSION = 4.01;
8$LOWER_CASE_TAGS = 1;
9$NO_FRENCH_QUOTES = 1;
10
11# '' in \code{...} is still converted, so we can't use this yet.
12#$USE_CURLY_QUOTES = 1;
13
14# Force Unicode support to be loaded; request UTF-8 output.
15do_require_extension('unicode');
16do_require_extension('utf8');
17$HTML_OPTIONS = 'utf8';
Fred Drake28e7b4c1998-10-20 18:14:20 +000018
Fred Drake6aa5d481998-08-11 03:14:50 +000019$MAX_LINK_DEPTH = 2;
Fred Draked7571651998-04-23 20:06:24 +000020$ADDRESS = '';
Fred Drakebc7101d1998-03-06 21:18:55 +000021
Fred Drakee194beb1998-05-19 19:38:49 +000022$NO_FOOTNODE = 1;
Fred Drakebc7101d1998-03-06 21:18:55 +000023$NUMBERED_FOOTNOTES = 1;
24
25# Python documentation uses section numbers to support references to match
26# in the printed and online versions.
27#
28$SHOW_SECTION_NUMBERS = 1;
29
Fred Drake15a159c2002-10-01 15:20:20 +000030$ICONSERVER = '.';
Fred Drakef730fc32000-08-31 07:19:07 +000031$IMAGE_TYPE = 'gif';
Fred Drakebc7101d1998-03-06 21:18:55 +000032
Fred Drake6aa5d481998-08-11 03:14:50 +000033# Control where the navigation bars should show up:
34$TOP_NAVIGATION = 1;
35$BOTTOM_NAVIGATION = 1;
36$AUTO_NAVIGATION = 0;
37
Fred Drake16816272000-09-16 20:40:44 +000038$BODYTEXT = '';
Fred Drake0739c442003-09-04 22:16:45 +000039$CHILDLINE = "\n<p><br /></p><hr class='online-navigation' />\n";
Fred Drakebc7101d1998-03-06 21:18:55 +000040$VERBOSITY = 0;
Fred Drakebc7101d1998-03-06 21:18:55 +000041
Fred Drake4d10b431998-08-07 20:51:58 +000042# default # of columns for the indexes
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000043$INDEX_COLUMNS = 2;
Fred Drake2383f6d1999-03-02 16:00:37 +000044$MODULE_INDEX_COLUMNS = 4;
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000045
Fred Drakea219b412001-10-22 16:57:49 +000046$HAVE_MODULE_INDEX = 0;
47$HAVE_GENERAL_INDEX = 0;
48$HAVE_TABLE_OF_CONTENTS = 0;
49
Fred Drakee03e1fe2002-04-05 17:34:50 +000050$AESOP_META_TYPE = 'information';
51
Fred Drakec9f2c141998-03-11 12:08:21 +000052
Fred Drakedb34a1e1998-03-10 23:02:57 +000053# A little painful, but lets us clean up the top level directory a little,
Fred Drake85d14c92000-07-31 17:53:45 +000054# and not be tied to the current directory (as far as I can tell). Testing
55# an existing definition of $mydir is needed since it cannot be computed when
56# run under mkhowto with recent versions of LaTeX2HTML, since this file is
57# not read directly by LaTeX2HTML any more. mkhowto is required to prepend
58# the required definition at the top of the actual input file.
Fred Drakedb34a1e1998-03-10 23:02:57 +000059#
Fred Drake85d14c92000-07-31 17:53:45 +000060if (!defined $mydir) {
61 use Cwd;
62 use File::Basename;
63 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
Fred Drake7a556422003-09-04 22:21:17 +000064 chop $mydir; # remove trailing '/'
Fred Drake85d14c92000-07-31 17:53:45 +000065 $mydir = getcwd() . "$dd$mydir"
66 unless $mydir =~ s|^/|/|;
67}
Fred Drakedb34a1e1998-03-10 23:02:57 +000068$LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES";
Fred Drakeb3a3ed81998-07-24 22:17:34 +000069push (@INC, $mydir);
Fred Drakebc7101d1998-03-06 21:18:55 +000070
Fred Drake235e6b11998-03-27 05:19:43 +000071($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*');
72chop $myrootdir;
73
Fred Drakebc7101d1998-03-06 21:18:55 +000074
Fred Drakea4565b01998-05-15 17:14:17 +000075# Hackish way to get the appropriate paper-*/ directory into $TEXINPUTS;
76# pass in the paper size (a4 or letter) as the environment variable PAPER
77# to add the right directory. If not given, the current directory is
78# added instead for use with HOWTO processing.
79#
80if (defined $ENV{'PAPER'}) {
81 $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey";
82}
83else {
84 $mytexinputs = getcwd() . $envkey;
85}
86$mytexinputs .= "$myrootdir${dd}texinputs";
87
88
Fred Drakeb35f2b71999-09-23 16:53:09 +000089# Change this variable to change the text added in "About this document...";
90# this should be an absolute pathname to get it right.
91#
92$ABOUT_FILE = "$myrootdir${dd}html${dd}stdabout.dat";
93
94
Fred Drake85d14c92000-07-31 17:53:45 +000095sub custom_driver_hook {
Fred Drakea4565b01998-05-15 17:14:17 +000096 #
97 # This adds the directory of the main input file to $TEXINPUTS; it
98 # seems to be sufficiently general that it should be fine for HOWTO
99 # processing.
100 #
Fred Drakecc2e48d2003-09-27 16:04:23 +0000101 # XXX This still isn't quite right; we should actually be inserting
102 # $mytexinputs just before any empty entry in TEXINPUTS is one
103 # exists instead of just concatenating the pieces like we do here.
104 #
Fred Drake73c5b6602002-10-24 16:36:05 +0000105 my $file = $_[0];
Fred Drake85d14c92000-07-31 17:53:45 +0000106 my($jobname, $dir, $ext) = fileparse($file, '\..*');
107 $dir = L2hos->Make_directory_absolute($dir);
Fred Drakea4565b01998-05-15 17:14:17 +0000108 $dir =~ s/$dd$//;
109 $TEXINPUTS = "$dir$envkey$mytexinputs";
Fred Drakecc2e48d2003-09-27 16:04:23 +0000110 # Push everything into $TEXINPUTS since LaTeX2HTML doesn't pick
Georg Brandl7eb4b7d2005-07-22 21:49:32 +0000111 # this up on its own; we clear $ENV{'TEXINPUTS'} so the value set
Fred Drakecc2e48d2003-09-27 16:04:23 +0000112 # for this by the main LaTeX2HTML script doesn't contain duplicate
113 # directories.
114 if ($ENV{'TEXINPUTS'}) {
115 $TEXINPUTS .= "$envkey$ENV{'TEXINPUTS'}";
116 $ENV{'TEXINPUTS'} = undef;
117 }
118 print "\nSetting \$TEXINPUTS to $TEXINPUTS\n";
Thomas Wouters477c8d52006-05-27 19:21:47 +0000119
120 # Not sure why we need to deal with this both here and at the top,
121 # but this is needed to actually make it work.
122 do_require_extension('utf8');
123 $charset = $utf8_str;
124 $CHARSET = $utf8_str;
125 $USE_UTF = 1;
Fred Drake191439a1999-09-22 19:50:51 +0000126}
127
Fred Drakea4565b01998-05-15 17:14:17 +0000128
Fred Drake3f26af72004-01-13 23:43:58 +0000129# $CUSTOM_BUTTONS is only used for the module index link.
Fred Drake85d14c92000-07-31 17:53:45 +0000130$CUSTOM_BUTTONS = '';
Fred Drake062bc6e1998-08-13 22:03:46 +0000131
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000132sub make_nav_sectref($$$) {
133 my($label, $linktype, $title) = @_;
Fred Drakebeb27bf1999-02-16 17:22:32 +0000134 if ($title) {
Fred Drake02c70822000-09-19 15:36:19 +0000135 if ($title =~ /\<[aA] /) {
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000136 $title =~ s/\<[aA] /<a class="sectref" rel="$linktype" /;
Fred Drake2fc88a62003-08-05 03:45:37 +0000137 $title =~ s/ HREF=/ href=/;
Fred Drake02c70822000-09-19 15:36:19 +0000138 }
139 else {
140 $title = "<span class=\"sectref\">$title</span>";
141 }
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000142 return "<b class=\"navlabel\">$label:</b>\n$title\n";
Fred Drakebeb27bf1999-02-16 17:22:32 +0000143 }
144 return '';
145}
146
Fred Draked18722b2001-01-02 22:08:48 +0000147@my_icon_tags = ();
148$my_icon_tags{'next'} = 'Next Page';
149$my_icon_tags{'next_page'} = 'Next Page';
150$my_icon_tags{'previous'} = 'Previous Page';
151$my_icon_tags{'previous_page'} = 'Previous Page';
152$my_icon_tags{'up'} = 'Up One Level';
153$my_icon_tags{'contents'} = 'Contents';
154$my_icon_tags{'index'} = 'Index';
155$my_icon_tags{'modules'} = 'Module Index';
156
Fred Drakeb31d36c2001-01-04 15:16:01 +0000157@my_icon_names = ();
158$my_icon_names{'previous_page'} = 'previous';
159$my_icon_names{'next_page'} = 'next';
160
Fred Drakef5478632002-05-23 17:59:16 +0000161sub get_my_icon($) {
Fred Drake73c5b6602002-10-24 16:36:05 +0000162 my $name = $_[0];
Fred Draked18722b2001-01-02 22:08:48 +0000163 my $text = $my_icon_tags{$name};
Fred Drakeb31d36c2001-01-04 15:16:01 +0000164 if ($my_icon_names{$name}) {
165 $name = $my_icon_names{$name};
166 }
Fred Draked18722b2001-01-02 22:08:48 +0000167 if ($text eq '') {
168 $name = 'blank';
169 }
Fred Drake85d14c92000-07-31 17:53:45 +0000170 my $iconserver = ($ICONSERVER eq '.') ? '' : "$ICONSERVER/";
Fred Drakedd3d6a02002-10-30 17:00:58 +0000171 return "<img src='$iconserver$name.$IMAGE_TYPE'\n border='0'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000172 . " height='32' alt='$text' width='32' />";
Fred Drake85d14c92000-07-31 17:53:45 +0000173}
174
Fred Drake8b34e7c2003-05-03 02:07:22 +0000175sub unlinkify($) {
176 my $text = "$_[0]";
177 $text =~ s|</[aA]>||;
178 $text =~ s|<a\s+[^>]*>||i;
179 return $text;
180}
181
182sub use_icon($$$) {
183 my($rel,$str,$title) = @_;
Fred Drake3f26af72004-01-13 23:43:58 +0000184 if ($str) {
Fred Drake8b34e7c2003-05-03 02:07:22 +0000185 my $s = "$str";
186 if ($s =~ /\<tex2html_([a-z_]+)_visible_mark\>/) {
187 my $r = get_my_icon($1);
188 $s =~ s/\<tex2html_[a-z_]+_visible_mark\>/$r/;
189 }
Fred Drakee0bdaef2004-11-05 06:42:22 +0000190 $s =~ s/<[aA] /<a rel="$rel" title="$title"\n /;
Fred Drake2fc88a62003-08-05 03:45:37 +0000191 $s =~ s/ HREF=/ href=/;
Fred Drake8b34e7c2003-05-03 02:07:22 +0000192 return $s;
Fred Draked18722b2001-01-02 22:08:48 +0000193 }
Fred Drake8b34e7c2003-05-03 02:07:22 +0000194 else {
195 return get_my_icon('blank');
196 }
Fred Drake13210ed1998-03-17 06:28:05 +0000197}
198
Fred Drakef5478632002-05-23 17:59:16 +0000199sub make_nav_panel() {
Fred Drake85d14c92000-07-31 17:53:45 +0000200 my $s;
Fred Drake8b34e7c2003-05-03 02:07:22 +0000201 # new iconic rel iconic page title
Fred Drake216b2492004-09-09 05:13:52 +0000202 my $next = use_icon('next', $NEXT, unlinkify($NEXT_TITLE));
203 my $up = use_icon('parent', $UP, unlinkify($UP_TITLE));
204 my $previous = use_icon('prev', $PREVIOUS, unlinkify($PREVIOUS_TITLE));
205 my $contents = use_icon('contents', $CONTENTS, 'Table of Contents');
206 my $index = use_icon('index', $INDEX, 'Index');
Fred Drake85d14c92000-07-31 17:53:45 +0000207 if (!$CUSTOM_BUTTONS) {
Fred Drake8b34e7c2003-05-03 02:07:22 +0000208 $CUSTOM_BUTTONS = get_my_icon('blank');
Fred Drake85d14c92000-07-31 17:53:45 +0000209 }
210 $s = ('<table align="center" width="100%" cellpadding="0" cellspacing="2">'
211 . "\n<tr>"
212 # left-hand side
Fred Drake216b2492004-09-09 05:13:52 +0000213 . "\n<td class='online-navigation'>$previous</td>"
214 . "\n<td class='online-navigation'>$up</td>"
215 . "\n<td class='online-navigation'>$next</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000216 # title box
Fred Drakef730fc32000-08-31 07:19:07 +0000217 . "\n<td align=\"center\" width=\"100%\">$t_title</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000218 # right-hand side
Fred Drake216b2492004-09-09 05:13:52 +0000219 . "\n<td class='online-navigation'>$contents</td>"
Fred Drake0739c442003-09-04 22:16:45 +0000220 # module index
221 . "\n<td class='online-navigation'>$CUSTOM_BUTTONS</td>"
Fred Drake216b2492004-09-09 05:13:52 +0000222 . "\n<td class='online-navigation'>$index</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000223 . "\n</tr></table>\n"
224 # textual navigation
Fred Drake0739c442003-09-04 22:16:45 +0000225 . "<div class='online-navigation'>\n"
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000226 . make_nav_sectref("Previous", "prev", $PREVIOUS_TITLE)
227 . make_nav_sectref("Up", "parent", $UP_TITLE)
228 . make_nav_sectref("Next", "next", $NEXT_TITLE)
Fred Drake0739c442003-09-04 22:16:45 +0000229 . "</div>\n"
Fred Drake4640e132000-07-31 20:13:23 +0000230 );
Fred Drake85d14c92000-07-31 17:53:45 +0000231 # remove these; they are unnecessary and cause errors from validation
232 $s =~ s/ NAME="tex2html\d+"\n */ /g;
233 return $s;
234}
235
Fred Drakefb6499f2001-10-26 14:16:23 +0000236sub add_child_links {
237 my $toc = add_real_child_links(@_);
238 $toc =~ s|\s*</[aA]>|</a>|g;
239 $toc =~ s/ NAME=\"tex2html\d+\"\s*href=/ href=/gi;
Fred Drake2fc88a62003-08-05 03:45:37 +0000240 $toc =~ s|</UL>(\s*<BR( /)?>)?|</ul>|gi;
Fred Drake0739c442003-09-04 22:16:45 +0000241 if ($toc =~ / NAME=["']CHILD_LINKS["']/) {
242 return "<div class='online-navigation'>\n$toc</div>\n";
243 }
Fred Drakefb6499f2001-10-26 14:16:23 +0000244 return $toc;
245}
246
Fred Drakef5478632002-05-23 17:59:16 +0000247sub get_version_text() {
Fred Drake7497bd32000-10-25 16:18:10 +0000248 if ($PACKAGE_VERSION ne '' && $t_date) {
249 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000250 . "Release $PACKAGE_VERSION$RELEASE_INFO,"
Fred Drake7497bd32000-10-25 16:18:10 +0000251 . " documentation updated on $t_date.</span>");
252 }
253 if ($PACKAGE_VERSION ne '') {
254 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000255 . "Release $PACKAGE_VERSION$RELEASE_INFO.</span>");
Fred Drake7497bd32000-10-25 16:18:10 +0000256 }
257 if ($t_date) {
258 return ("<span class=\"release-info\">Documentation released on "
259 . "$t_date.</span>");
260 }
261 return '';
262}
263
Fred Drake85d14c92000-07-31 17:53:45 +0000264
Fred Drakef5478632002-05-23 17:59:16 +0000265sub top_navigation_panel() {
Fred Drake0c1b2532004-10-29 19:47:52 +0000266 return "\n<div id='top-navigation-panel' xml:id='top-navigation-panel'>\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000267 . make_nav_panel()
Fred Drake11b138f2003-09-11 04:14:20 +0000268 . "<hr /></div>\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000269}
270
Fred Drakef5478632002-05-23 17:59:16 +0000271sub bot_navigation_panel() {
Fred Drake0739c442003-09-04 22:16:45 +0000272 return "\n<div class='online-navigation'>\n"
Fred Drake859c46a2003-09-04 19:30:15 +0000273 . "<p></p><hr />\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000274 . make_nav_panel()
Fred Drake859c46a2003-09-04 19:30:15 +0000275 . "</div>\n"
Fred Drake2fc88a62003-08-05 03:45:37 +0000276 . "<hr />\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000277 . get_version_text()
278 . "\n";
Fred Drake64bdc241998-04-17 02:14:12 +0000279}
280
281sub add_link {
282 # Returns a pair (iconic link, textual link)
283 my($icon, $current_file, @link) = @_;
284 my($dummy, $file, $title) = split($delim,
Fred Drake7a556422003-09-04 22:21:17 +0000285 $section_info{join(' ',@link)});
Fred Draked18722b2001-01-02 22:08:48 +0000286 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
287 my $r = get_my_icon($1);
288 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
289 }
Fred Drake64bdc241998-04-17 02:14:12 +0000290 if ($title && ($file ne $current_file)) {
291 $title = purify($title);
Fred Drake7a556422003-09-04 22:21:17 +0000292 $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
293 return (make_href($file, $icon), make_href($file, "$title"))
294 }
Fred Draked18722b2001-01-02 22:08:48 +0000295 elsif ($icon eq get_my_icon('up') && $EXTERNAL_UP_LINK) {
Fred Drake7a556422003-09-04 22:21:17 +0000296 return (make_href($EXTERNAL_UP_LINK, $icon),
297 make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
298 }
Fred Draked18722b2001-01-02 22:08:48 +0000299 elsif ($icon eq get_my_icon('previous')
Fred Drake7a556422003-09-04 22:21:17 +0000300 && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
301 return (make_href($EXTERNAL_PREV_LINK, $icon),
302 make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
303 }
Fred Draked18722b2001-01-02 22:08:48 +0000304 elsif ($icon eq get_my_icon('next')
Fred Drake7a556422003-09-04 22:21:17 +0000305 && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
306 return (make_href($EXTERNAL_DOWN_LINK, $icon),
307 make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
308 }
Fred Drake85d14c92000-07-31 17:53:45 +0000309 return (&inactive_img($icon), "");
Fred Drake64bdc241998-04-17 02:14:12 +0000310}
311
Fred Drakef5478632002-05-23 17:59:16 +0000312sub add_special_link($$$) {
Fred Drake64bdc241998-04-17 02:14:12 +0000313 my($icon, $file, $current_file) = @_;
Fred Draked18722b2001-01-02 22:08:48 +0000314 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
315 my $r = get_my_icon($1);
316 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
317 }
Fred Drake85d14c92000-07-31 17:53:45 +0000318 return (($file && ($file ne $current_file))
319 ? make_href($file, $icon)
320 : undef)
Fred Drake64bdc241998-04-17 02:14:12 +0000321}
322
Fred Drake85d14c92000-07-31 17:53:45 +0000323# The img_tag() function seems only to be called with the parameter
324# 'anchor_invisible_mark', which we want to turn into ''. Since
325# replace_icon_marks() is the only interesting caller, and all it really
326# does is call img_tag(), we can just define the hook alternative to be
327# a no-op instead.
328#
329sub replace_icons_hook {}
Fred Drakebc7101d1998-03-06 21:18:55 +0000330
Fred Drake50cdd971999-02-19 23:04:59 +0000331sub do_cmd_arabic {
332 # get rid of that nasty <SPAN CLASS="arabic">...</SPAN>
Fred Drake73c5b6602002-10-24 16:36:05 +0000333 my($ctr, $val, $id, $text) = &read_counter_value($_[0]);
Fred Drake85d14c92000-07-31 17:53:45 +0000334 return ($val ? farabic($val) : "0") . $text;
Fred Drake50cdd971999-02-19 23:04:59 +0000335}
336
337
Fred Drakef5478632002-05-23 17:59:16 +0000338sub gen_index_id($$) {
Fred Drakebc7101d1998-03-06 21:18:55 +0000339 # this is used to ensure common index key generation and a stable sort
Fred Drakef5478632002-05-23 17:59:16 +0000340 my($str, $extra) = @_;
Fred Drake64bdc241998-04-17 02:14:12 +0000341 sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
Fred Drakebc7101d1998-03-06 21:18:55 +0000342}
343
Fred Drakef5478632002-05-23 17:59:16 +0000344sub insert_index($$$$$) {
345 my($mark, $datafile, $columns, $letters, $prefix) = @_;
Fred Drake4d10b431998-08-07 20:51:58 +0000346 my $prog = "$myrootdir/tools/buildindex.py";
347 my $index;
348 if ($letters) {
Fred Drake7a556422003-09-04 22:21:17 +0000349 $index = `$prog --columns $columns --letters $datafile`;
Fred Drake4d10b431998-08-07 20:51:58 +0000350 }
351 else {
Fred Drake7a556422003-09-04 22:21:17 +0000352 $index = `$prog --columns $columns $datafile`;
Fred Drake4d10b431998-08-07 20:51:58 +0000353 }
Fred Drakec5681732000-09-12 20:13:04 +0000354 if (!s/$mark/$prefix$index/) {
355 print "\nCould not locate index mark: $mark";
356 }
Fred Drake64bdc241998-04-17 02:14:12 +0000357}
358
Fred Drakef5478632002-05-23 17:59:16 +0000359sub add_idx() {
Fred Drake9bbdce51999-01-19 16:30:10 +0000360 print "\nBuilding HTML for the index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000361 close(IDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000362 insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
Fred Drake13210ed1998-03-17 06:28:05 +0000363}
Fred Drakebc7101d1998-03-06 21:18:55 +0000364
365
366$idx_module_mark = '<tex2html_idx_module_mark>';
367$idx_module_title = 'Module Index';
368
Fred Drakef5478632002-05-23 17:59:16 +0000369sub add_module_idx() {
Fred Drake9bbdce51999-01-19 16:30:10 +0000370 print "\nBuilding HTML for the module index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000371 my $key;
Fred Drake2383f6d1999-03-02 16:00:37 +0000372 my $first = 1;
373 my $prevplat = '';
374 my $allthesame = 1;
375 my $prefix = '';
376 foreach $key (keys %Modules) {
Fred Drake7a556422003-09-04 22:21:17 +0000377 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
378 my $plat = "$ModulePlatforms{$key}";
379 $plat = ''
380 if ($plat eq $IGNORE_PLATFORM_ANNOTATION);
381 if (!$first) {
382 $allthesame = 0
383 if ($prevplat ne $plat);
384 }
385 else { $first = 0; }
386 $prevplat = $plat;
Fred Drake2383f6d1999-03-02 16:00:37 +0000387 }
Fred Drake64bdc241998-04-17 02:14:12 +0000388 open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
Fred Drake235e6b11998-03-27 05:19:43 +0000389 foreach $key (keys %Modules) {
Fred Drake7a556422003-09-04 22:21:17 +0000390 # dump the line in the data file; just use a dummy seqno field
391 my $nkey = $1;
392 my $moditem = "$Modules{$key}";
393 my $plat = '';
394 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
395 if ($ModulePlatforms{$key} && !$allthesame) {
396 $plat = (" <em>(<span class=\"platform\">$ModulePlatforms{$key}"
397 . '</span>)</em>');
398 }
399 print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP
Fred Drakedce975c2001-06-20 21:31:36 +0000400 . "<tt class=\"module\">$key</tt>$plat###\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000401 }
Fred Drake235e6b11998-03-27 05:19:43 +0000402 close(MODIDXFILE);
Fred Drake42181db2001-01-09 22:02:10 +0000403
404 if ($GLOBAL_MODULE_INDEX) {
405 $prefix = <<MODULE_INDEX_PREFIX;
406
407<p> This index only lists modules documented in this manual.
408 The <em class="citetitle"><a href="$GLOBAL_MODULE_INDEX">Global Module
409 Index</a></em> lists all modules that are documented in this set
410 of manuals.</p>
411MODULE_INDEX_PREFIX
412 }
Fred Drake2383f6d1999-03-02 16:00:37 +0000413 if (!$allthesame) {
Fred Drake7a556422003-09-04 22:21:17 +0000414 $prefix .= <<PLAT_DISCUSS;
Fred Drake2383f6d1999-03-02 16:00:37 +0000415
416<p> Some module names are followed by an annotation indicating what
417platform they are available on.</p>
418
419PLAT_DISCUSS
420 }
421 insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
Fred Drake7a556422003-09-04 22:21:17 +0000422 $prefix);
Fred Drakebc7101d1998-03-06 21:18:55 +0000423}
424
Fred Drake235e6b11998-03-27 05:19:43 +0000425# replace both indexes as needed:
Fred Drake85d14c92000-07-31 17:53:45 +0000426sub add_idx_hook {
Fred Drakeb3a3ed81998-07-24 22:17:34 +0000427 add_idx() if (/$idx_mark/);
Fred Drake2383f6d1999-03-02 16:00:37 +0000428 process_python_state();
Fred Drakec5681732000-09-12 20:13:04 +0000429 if ($MODULE_INDEX_FILE) {
430 local ($_);
431 open(MYFILE, "<$MODULE_INDEX_FILE");
432 sysread(MYFILE, $_, 1024*1024);
433 close(MYFILE);
434 add_module_idx();
435 open(MYFILE,">$MODULE_INDEX_FILE");
436 print MYFILE $_;
437 close(MYFILE);
438 }
Fred Drake235e6b11998-03-27 05:19:43 +0000439}
Fred Drakebc7101d1998-03-06 21:18:55 +0000440
Fred Drakebc7101d1998-03-06 21:18:55 +0000441
Fred Drake191439a1999-09-22 19:50:51 +0000442# In addition to the standard stuff, add label to allow named node files and
443# support suppression of the page complete (for HTML Help use).
Fred Drake095f8172003-06-27 18:26:01 +0000444$MY_CONTENTS_PAGE = '';
Fred Drakebc7101d1998-03-06 21:18:55 +0000445sub do_cmd_tableofcontents {
446 local($_) = @_;
447 $TITLE = $toc_title;
448 $tocfile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000449 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000450 anchor_label('contents', $CURRENT_FILE, $_); # this is added
Fred Drake095f8172003-06-27 18:26:01 +0000451 $MY_CONTENTS_PAGE = "$CURRENT_FILE";
Fred Drakee0bdaef2004-11-05 06:42:22 +0000452 join('', "\\tableofchildlinks[off]", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000453 , make_section_heading($toc_title, 'h2'), $toc_mark
454 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000455}
456# In addition to the standard stuff, add label to allow named node files.
457sub do_cmd_listoffigures {
458 local($_) = @_;
459 $TITLE = $lof_title;
460 $loffile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000461 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000462 anchor_label('lof', $CURRENT_FILE, $_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000463 join('', "<br />\n", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000464 , make_section_heading($lof_title, 'h2'), $lof_mark
465 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000466}
467# In addition to the standard stuff, add label to allow named node files.
468sub do_cmd_listoftables {
469 local($_) = @_;
470 $TITLE = $lot_title;
471 $lotfile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000472 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000473 anchor_label('lot', $CURRENT_FILE, $_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000474 join('', "<br />\n", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000475 , make_section_heading($lot_title, 'h2'), $lot_mark
476 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000477}
478# In addition to the standard stuff, add label to allow named node files.
479sub do_cmd_textohtmlinfopage {
480 local($_) = @_;
Fred Drake7a556422003-09-04 22:21:17 +0000481 if ($INFO) { #
482 anchor_label("about",$CURRENT_FILE,$_); # this is added
483 } #
484 my $the_version = ''; # and the rest is
485 if ($t_date) { # mostly ours
486 $the_version = ",\n$t_date";
487 if ($PACKAGE_VERSION) {
488 $the_version .= ", Release $PACKAGE_VERSION$RELEASE_INFO";
489 }
Fred Drake15796f71998-11-30 19:25:47 +0000490 }
Fred Drake9443dc32001-08-10 20:12:09 +0000491 my $about;
492 open(ABOUT, "<$ABOUT_FILE") || die "\n$!\n";
493 sysread(ABOUT, $about, 1024*1024);
494 close(ABOUT);
Fred Drake15796f71998-11-30 19:25:47 +0000495 $_ = (($INFO == 1)
Fred Drakeb35f2b71999-09-23 16:53:09 +0000496 ? join('',
497 $close_all,
498 "<strong>$t_title</strong>$the_version\n",
Fred Drake9443dc32001-08-10 20:12:09 +0000499 $about,
Fred Drakeb35f2b71999-09-23 16:53:09 +0000500 $open_all, $_)
501 : join('', $close_all, $INFO,"\n", $open_all, $_));
Fred Drake15796f71998-11-30 19:25:47 +0000502 $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000503}
504
Fred Drakec6f3c8b2004-08-19 01:37:48 +0000505$GENERAL_INDEX_FILE = '';
506$MODULE_INDEX_FILE = '';
507
Fred Drakebc7101d1998-03-06 21:18:55 +0000508# $idx_mark will be replaced with the real index at the end
509sub do_cmd_textohtmlindex {
510 local($_) = @_;
511 $TITLE = $idx_title;
512 $idxfile = $CURRENT_FILE;
Fred Drakec6f3c8b2004-08-19 01:37:48 +0000513 $GENERAL_INDEX_FILE = "$CURRENT_FILE";
Fred Drake235e6b11998-03-27 05:19:43 +0000514 if (%index_labels) { make_index_labels(); }
515 if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); }
Fred Drakebc7101d1998-03-06 21:18:55 +0000516 else { $preindex = ''; }
Fred Drake235e6b11998-03-27 05:19:43 +0000517 my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
Fred Drakef5478632002-05-23 17:59:16 +0000518 my($pre, $post) = minimize_open_tags($heading);
Fred Drake7a556422003-09-04 22:21:17 +0000519 anchor_label('genindex',$CURRENT_FILE,$_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000520 return "<br />\n" . $pre . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000521}
522
523# $idx_module_mark will be replaced with the real index at the end
524sub do_cmd_textohtmlmoduleindex {
525 local($_) = @_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000526 $TITLE = $idx_module_title;
Fred Drakec5681732000-09-12 20:13:04 +0000527 anchor_label('modindex', $CURRENT_FILE, $_);
528 $MODULE_INDEX_FILE = "$CURRENT_FILE";
Fred Drake2fc88a62003-08-05 03:45:37 +0000529 $_ = ('<p></p>' . make_section_heading($idx_module_title, 'h2')
Fred Drakec5681732000-09-12 20:13:04 +0000530 . $idx_module_mark . $_);
531 return $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000532}
533
Fred Drakec5681732000-09-12 20:13:04 +0000534# The bibliography and the index should be treated as separate
535# sections in their own HTML files. The \bibliography{} command acts
536# as a sectioning command that has the desired effect. But when the
537# bibliography is constructed manually using the thebibliography
538# environment, or when using the theindex environment it is not
539# possible to use the normal sectioning mechanism. This subroutine
540# inserts a \bibliography{} or a dummy \textohtmlindex command just
541# before the appropriate environments to force sectioning.
Fred Drakebc7101d1998-03-06 21:18:55 +0000542
Fred Drake7a556422003-09-04 22:21:17 +0000543# XXX This *assumes* that if there are two {theindex} environments,
544# the first is the module index and the second is the standard
545# index. This is sufficient for the current Python documentation,
546# but that's about it.
Fred Drakebc7101d1998-03-06 21:18:55 +0000547
548sub add_bbl_and_idx_dummy_commands {
Fred Drake11916921998-04-02 22:30:57 +0000549 my $id = $global{'max_id'};
Fred Drakebc7101d1998-03-06 21:18:55 +0000550
Fred Drakea219b412001-10-22 16:57:49 +0000551 if (/[\\]tableofcontents/) {
552 $HAVE_TABLE_OF_CONTENTS = 1;
553 }
Fred Drakebc7101d1998-03-06 21:18:55 +0000554 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
Fred Drake191439a1999-09-22 19:50:51 +0000555 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 +0000556 my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/);
557 if (scalar(@parts) == 3) {
558 # Be careful to re-write the string in place, since $_ is *not*
559 # returned explicity; *** nasty side-effect dependency! ***
Fred Drakebb7775a2001-12-04 17:03:54 +0000560 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
Fred Drake85d14c92000-07-31 17:53:45 +0000561 print "\nadd_bbl_and_idx_dummy_commands ==> adding module index";
562 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)"
563 . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
Fred Drake73c5b6602002-10-24 16:36:05 +0000564 s/$rx/\\textohtmlmoduleindex $1 \\textohtmlindex $2/o;
Fred Drake85d14c92000-07-31 17:53:45 +0000565 # Add a button to the navigation areas:
Fred Drakeaaa23852000-09-14 22:20:41 +0000566 $CUSTOM_BUTTONS .= ('<a href="modindex.html" title="Module Index">'
Fred Draked18722b2001-01-02 22:08:48 +0000567 . get_my_icon('modules')
Fred Drakeaaa23852000-09-14 22:20:41 +0000568 . '</a>');
Fred Drakea219b412001-10-22 16:57:49 +0000569 $HAVE_MODULE_INDEX = 1;
570 $HAVE_GENERAL_INDEX = 1;
571 }
572 elsif (scalar(@parts) == 2) {
Fred Drakebb7775a2001-12-04 17:03:54 +0000573 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
574 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
Fred Drake73c5b6602002-10-24 16:36:05 +0000575 s/$rx/\\textohtmlindex $1/o;
Fred Drakea219b412001-10-22 16:57:49 +0000576 $HAVE_GENERAL_INDEX = 1;
Fred Drake11916921998-04-02 22:30:57 +0000577 }
Fred Drakebb7775a2001-12-04 17:03:54 +0000578 elsif (scalar(@parts) == 1) {
579 print "\nadd_bbl_and_idx_dummy_commands ==> no index found";
Fred Draked18722b2001-01-02 22:08:48 +0000580 $CUSTOM_BUTTONS .= get_my_icon('blank');
Fred Drake85d14c92000-07-31 17:53:45 +0000581 $global{'max_id'} = $id; # not sure why....
582 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
Fred Drake7a556422003-09-04 22:21:17 +0000583 s/[\\]printindex/\\textohtmlindex /o;
Fred Drakebb7775a2001-12-04 17:03:54 +0000584 }
585 else {
586 die "\n\nBad number of index environments!\n\n";
587 }
Fred Drake11916921998-04-02 22:30:57 +0000588 #----------------------------------------------------------------------
Fred Drake64bdc241998-04-17 02:14:12 +0000589 lib_add_bbl_and_idx_dummy_commands()
Fred Drake11916921998-04-02 22:30:57 +0000590 if defined(&lib_add_bbl_and_idx_dummy_commands);
Fred Drakebc7101d1998-03-06 21:18:55 +0000591}
592
Fred Drakec5681732000-09-12 20:13:04 +0000593# The bibliographic references, the appendices, the lists of figures
594# and tables etc. must appear in the contents table at the same level
595# as the outermost sectioning command. This subroutine finds what is
596# the outermost level and sets the above to the same level;
Fred Drakebc7101d1998-03-06 21:18:55 +0000597
Fred Drake13210ed1998-03-17 06:28:05 +0000598sub set_depth_levels {
599 # Sets $outermost_level
Fred Drake11916921998-04-02 22:30:57 +0000600 my $level;
Fred Drake13210ed1998-03-17 06:28:05 +0000601 #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
602 foreach $level ("part", "chapter", "section", "subsection",
Fred Drake7a556422003-09-04 22:21:17 +0000603 "subsubsection", "paragraph") {
604 last if (($outermost_level) = /\\($level)$delimiter_rx/);
Fred Drake13210ed1998-03-17 06:28:05 +0000605 }
606 $level = ($outermost_level ? $section_commands{$outermost_level} :
Fred Drake7a556422003-09-04 22:21:17 +0000607 do {$outermost_level = 'section'; 3;});
Fred Drakebc7101d1998-03-06 21:18:55 +0000608
Fred Drake13210ed1998-03-17 06:28:05 +0000609 #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
Fred Drake7a556422003-09-04 22:21:17 +0000610 if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
611 $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
Fred Drake13210ed1998-03-17 06:28:05 +0000612 } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
Fred Drakebc7101d1998-03-06 21:18:55 +0000613
Fred Drake64bdc241998-04-17 02:14:12 +0000614 %unnumbered_section_commands = ('tableofcontents' => $level,
Fred Drake7a556422003-09-04 22:21:17 +0000615 'listoffigures' => $level,
616 'listoftables' => $level,
617 'bibliography' => $level,
618 'textohtmlindex' => $level,
619 'textohtmlmoduleindex' => $level);
Fred Drake64bdc241998-04-17 02:14:12 +0000620 $section_headings{'textohtmlmoduleindex'} = 'h1';
Fred Drakebc7101d1998-03-06 21:18:55 +0000621
Fred Drake64bdc241998-04-17 02:14:12 +0000622 %section_commands = (%unnumbered_section_commands,
Fred Drake7a556422003-09-04 22:21:17 +0000623 %section_commands);
Fred Drake11916921998-04-02 22:30:57 +0000624
625 make_sections_rx();
Fred Drake13210ed1998-03-17 06:28:05 +0000626}
Fred Drakebc7101d1998-03-06 21:18:55 +0000627
628
Fred Drake1072e461998-04-12 02:16:34 +0000629# This changes the markup used for {verbatim} environments, and is the
Fred Drake95474f91999-02-09 18:45:50 +0000630# best way I've found that ensures the <dl> goes on the outside of the
Fred Drake1072e461998-04-12 02:16:34 +0000631# <pre>...</pre>.
632#
633# Note that this *must* be done in the init file, not the python.perl
Fred Drakec5681732000-09-12 20:13:04 +0000634# style support file. The %declarations must be set before
635# initialize() is called in the main LaTeX2HTML script (which happens
636# before style files are loaded).
Fred Drake1072e461998-04-12 02:16:34 +0000637#
Fred Drake8a5e6792002-04-15 18:41:31 +0000638%declarations = ('preform' => '<div class="verbatim"><pre></pre></div>',
Fred Drake7a556422003-09-04 22:21:17 +0000639 %declarations);
Fred Drake1072e461998-04-12 02:16:34 +0000640
Fred Drakee15956b2000-04-03 04:51:13 +0000641
Fred Drakedcb16ac2004-11-10 07:48:17 +0000642# This is a modified version of what's provided by LaTeX2HTML; see the
643# comment on the middle stanza for an explanation of why we keep our
644# own version.
645#
646# This routine must be called once on the text only,
647# else it will "eat up" sensitive constructs.
648sub text_cleanup {
649 # MRO: replaced $* with /m
650 s/(\s*\n){3,}/\n\n/gom; # Replace consecutive blank lines with one
651 s/<(\/?)P>\s*(\w)/<$1P>\n$2/gom; # clean up paragraph starts and ends
652 s/$O\d+$C//go; # Get rid of bracket id's
653 s/$OP\d+$CP//go; # Get rid of processed bracket id's
654 s/(<!)?--?(>)?/(length($1) || length($2)) ? "$1--$2" : "-"/ge;
655 # Spacing commands
656 s/\\( |$)/ /go;
657 #JKR: There should be no more comments in the source now.
658 #s/([^\\]?)%/$1/go; # Remove the comment character
659 # Cannot treat \, as a command because , is a delimiter ...
660 s/\\,/ /go;
661 # Replace tilde's with non-breaking spaces
662 s/ *~/&nbsp;/g;
663
664 # This is why we have this copy of this routine; the following
665 # isn't so desirable as the author/maintainers of LaTeX2HTML seem
666 # to think. It's not commented out in the main script, so we have
667 # to override the whole thing. In particular, we don't want empty
668 # table cells to disappear.
669
670 ### DANGEROUS ?? ###
671 # remove redundant (not <P></P>) empty tags, incl. with attributes
672 #s/\n?<([^PD >][^>]*)>\s*<\/\1>//g;
673 #s/\n?<([^PD >][^>]*)>\s*<\/\1>//g;
674 # remove redundant empty tags (not </P><P> or <TD> or <TH>)
675 #s/<\/(TT|[^PTH][A-Z]+)><\1>//g;
676 #s/<([^PD ]+)(\s[^>]*)?>\n*<\/\1>//g;
677
678 #JCL(jcl-hex)
679 # Replace ^^ special chars (according to p.47 of the TeX book)
680 # Useful when coming from the .aux file (german umlauts, etc.)
681 s/\^\^([^0-9a-f])/chr((64+ord($1))&127)/ge;
682 s/\^\^([0-9a-f][0-9a-f])/chr(hex($1))/ge;
683}
684
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000685# This is used to map the link rel attributes LaTeX2HTML uses to those
686# currently recommended by the W3C.
687sub custom_REL_hook {
688 my($rel,$junk) = @_;
689 return 'parent' if $rel eq 'up';
690 return 'prev' if $rel eq 'previous';
691 return $rel;
692}
693
Fred Drakec5681732000-09-12 20:13:04 +0000694# This is added to get rid of the long comment that follows the
695# doctype declaration; MSIE5 on NT4 SP4 barfs on it and drops the
696# content of the page.
Fred Drakea219b412001-10-22 16:57:49 +0000697$MY_PARTIAL_HEADER = '';
Fred Drakef5478632002-05-23 17:59:16 +0000698sub make_head_and_body($$) {
Fred Drake85d14c92000-07-31 17:53:45 +0000699 my($title, $body) = @_;
Fred Drake16816272000-09-16 20:40:44 +0000700 $body = " $body" unless ($body eq '');
Fred Drake85d14c92000-07-31 17:53:45 +0000701 my $DTDcomment = '';
702 my($version, $isolanguage) = ($HTML_VERSION, 'EN');
703 my %isolanguages = ( 'english', 'EN' , 'USenglish', 'EN.US'
704 , 'original', 'EN' , 'german' , 'DE'
705 , 'austrian', 'DE.AT', 'french' , 'FR'
706 , 'spanish', 'ES');
Fred Drakee15956b2000-04-03 04:51:13 +0000707 $isolanguage = $isolanguages{$default_language};
708 $isolanguage = 'EN' unless $isolanguage;
709 $title = &purify($title,1);
710 eval("\$title = ". $default_title ) unless ($title);
711
Fred Drake2fc88a62003-08-05 03:45:37 +0000712 # allow user-modification of the <title> tag; thanks Dan Young
Fred Drakee15956b2000-04-03 04:51:13 +0000713 if (defined &custom_TITLE_hook) {
Fred Drake7a556422003-09-04 22:21:17 +0000714 $title = &custom_TITLE_hook($title, $toc_sec_title);
Fred Drakee15956b2000-04-03 04:51:13 +0000715 }
716
717 if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included
Fred Drake7a556422003-09-04 22:21:17 +0000718 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000719 } else {
Fred Drake7a556422003-09-04 22:21:17 +0000720 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//"
721 . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000722 }
Fred Drakea219b412001-10-22 16:57:49 +0000723 if ($MY_PARTIAL_HEADER eq '') {
Fred Drake0384be32004-11-05 05:06:08 +0000724 my $favicon = '';
725 if ($FAVORITES_ICON) {
726 my($myname, $mydir, $myext) = fileparse($FAVORITES_ICON, '\..*');
727 my $favtype = '';
728 if ($myext eq '.gif' || $myext eq '.png') {
729 $myext =~ s/^[.]//;
730 $favtype = " type=\"image/$myext\"";
731 }
732 $favicon = (
733 "\n<link rel=\"SHORTCUT ICON\" href=\"$FAVORITES_ICON\""
734 . "$favtype />");
735 }
Fred Drakea219b412001-10-22 16:57:49 +0000736 $STYLESHEET = $FILE.".css" unless $STYLESHEET;
737 $MY_PARTIAL_HEADER = join('',
Fred Drakedd3d6a02002-10-30 17:00:58 +0000738 ($DOCTYPE ? $DTDcomment : ''),
Fred Drake98b25762003-05-02 18:21:22 +0000739 "<html>\n<head>",
Fred Drake2fc88a62003-08-05 03:45:37 +0000740 ($BASE ? "\n<base href=\"$BASE\" />" : ''),
741 "\n<link rel=\"STYLESHEET\" href=\"$STYLESHEET\" type='text/css'",
742 " />",
Fred Drake0384be32004-11-05 05:06:08 +0000743 $favicon,
Fred Drake23949002002-10-30 21:51:18 +0000744 ($EXTERNAL_UP_LINK
Fred Drake98b25762003-05-02 18:21:22 +0000745 ? ("\n<link rel='start' href='" . $EXTERNAL_UP_LINK
746 . ($EXTERNAL_UP_TITLE ?
Fred Drake2fc88a62003-08-05 03:45:37 +0000747 "' title='$EXTERNAL_UP_TITLE' />" : "' />"))
Fred Drake23949002002-10-30 21:51:18 +0000748 : ''),
Fred Drake98b25762003-05-02 18:21:22 +0000749 "\n<link rel=\"first\" href=\"$FILE.html\"",
Fred Drake23949002002-10-30 21:51:18 +0000750 ($t_title ? " title='$t_title'" : ''),
Fred Drake2fc88a62003-08-05 03:45:37 +0000751 ' />',
Fred Drakea219b412001-10-22 16:57:49 +0000752 ($HAVE_TABLE_OF_CONTENTS
Fred Drake095f8172003-06-27 18:26:01 +0000753 ? ("\n<link rel='contents' href='$MY_CONTENTS_PAGE'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000754 . ' title="Contents" />')
Fred Drakea219b412001-10-22 16:57:49 +0000755 : ''),
756 ($HAVE_GENERAL_INDEX
Fred Drakec6f3c8b2004-08-19 01:37:48 +0000757 ? ("\n<link rel='index' href='$GENERAL_INDEX_FILE'"
758 . " title='Index' />")
Fred Drakea219b412001-10-22 16:57:49 +0000759 : ''),
760 # disable for now -- Mozilla doesn't do well with multiple indexes
761 # ($HAVE_MODULE_INDEX
Fred Drakec6f3c8b2004-08-19 01:37:48 +0000762 # ? ("<link rel="index" href='$MODULE_INDEX_FILE'"
763 # . " title='Module Index' />\n")
Fred Drakea219b412001-10-22 16:57:49 +0000764 # : ''),
Fred Drake23949002002-10-30 21:51:18 +0000765 ($INFO
766 # XXX We can do this with the Python tools since the About...
767 # page always gets copied to about.html, even when we use the
768 # generated node###.html page names. Won't work with the
769 # rest of the Python doc tools.
Fred Drake98b25762003-05-02 18:21:22 +0000770 ? ("\n<link rel='last' href='about.html'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000771 . " title='About this document...' />"
Fred Drake98b25762003-05-02 18:21:22 +0000772 . "\n<link rel='help' href='about.html'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000773 . " title='About this document...' />")
Fred Drake23949002002-10-30 21:51:18 +0000774 : ''),
Fred Drakedd3d6a02002-10-30 17:00:58 +0000775 $more_links_mark,
Fred Drake0e2e6872002-10-30 19:55:23 +0000776 "\n",
Fred Drakedd3d6a02002-10-30 17:00:58 +0000777 ($CHARSET && $HTML_VERSION ge "2.1"
778 ? ('<meta http-equiv="Content-Type" content="text/html; '
Fred Drake2fc88a62003-08-05 03:45:37 +0000779 . "charset=$CHARSET\" />\n")
Fred Drakedd3d6a02002-10-30 17:00:58 +0000780 : ''),
781 ($AESOP_META_TYPE
Fred Drake2fc88a62003-08-05 03:45:37 +0000782 ? "<meta name='aesop' content='$AESOP_META_TYPE' />\n" : ''));
Fred Drakea219b412001-10-22 16:57:49 +0000783 }
Fred Drake0e2e6872002-10-30 19:55:23 +0000784 if (!$charset && $CHARSET) {
785 $charset = $CHARSET;
786 $charset =~ s/_/\-/go;
787 }
Fred Drakedd3d6a02002-10-30 17:00:58 +0000788 join('',
789 $MY_PARTIAL_HEADER,
Fred Drakedd3d6a02002-10-30 17:00:58 +0000790 "<title>", $title, "</title>\n</head>\n<body$body>");
Fred Drakee15956b2000-04-03 04:51:13 +0000791}
792
Fred Drake2fc88a62003-08-05 03:45:37 +0000793sub replace_morelinks {
794 $more_links =~ s/ REL=/ rel=/g;
795 $more_links =~ s/ HREF=/ href=/g;
Fred Drakee0bdaef2004-11-05 06:42:22 +0000796 $more_links =~ s/<LINK /<link /g;
797 $more_links =~ s/">/" \/>/g;
Fred Drake2fc88a62003-08-05 03:45:37 +0000798 $_ =~ s/$more_links_mark/$more_links/e;
799}
800
Fred Drake7a556422003-09-04 22:21:17 +00008011; # This must be the last line