blob: 87f73dbc6307fd867fa4eb441e6e995d30c68cbd [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 Drake28e7b4c1998-10-20 18:14:20 +00007$HTML_VERSION = 4.0;
8
Fred Drake6aa5d481998-08-11 03:14:50 +00009$MAX_LINK_DEPTH = 2;
Fred Draked7571651998-04-23 20:06:24 +000010$ADDRESS = '';
Fred Drakebc7101d1998-03-06 21:18:55 +000011
Fred Drakee194beb1998-05-19 19:38:49 +000012$NO_FOOTNODE = 1;
Fred Drakebc7101d1998-03-06 21:18:55 +000013$NUMBERED_FOOTNOTES = 1;
14
15# Python documentation uses section numbers to support references to match
16# in the printed and online versions.
17#
18$SHOW_SECTION_NUMBERS = 1;
19
Fred Drake15a159c2002-10-01 15:20:20 +000020$ICONSERVER = '.';
Fred Drakef730fc32000-08-31 07:19:07 +000021$IMAGE_TYPE = 'gif';
Fred Drakebc7101d1998-03-06 21:18:55 +000022
Fred Drake6aa5d481998-08-11 03:14:50 +000023# Control where the navigation bars should show up:
24$TOP_NAVIGATION = 1;
25$BOTTOM_NAVIGATION = 1;
26$AUTO_NAVIGATION = 0;
27
Fred Drake16816272000-09-16 20:40:44 +000028$BODYTEXT = '';
Fred Drake0739c442003-09-04 22:16:45 +000029$CHILDLINE = "\n<p><br /></p><hr class='online-navigation' />\n";
Fred Drakebc7101d1998-03-06 21:18:55 +000030$VERBOSITY = 0;
Fred Drakebc7101d1998-03-06 21:18:55 +000031
Fred Drake4d10b431998-08-07 20:51:58 +000032# default # of columns for the indexes
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000033$INDEX_COLUMNS = 2;
Fred Drake2383f6d1999-03-02 16:00:37 +000034$MODULE_INDEX_COLUMNS = 4;
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000035
Fred Drakea219b412001-10-22 16:57:49 +000036$HAVE_MODULE_INDEX = 0;
37$HAVE_GENERAL_INDEX = 0;
38$HAVE_TABLE_OF_CONTENTS = 0;
39
Fred Drakee03e1fe2002-04-05 17:34:50 +000040$AESOP_META_TYPE = 'information';
41
Fred Drakec9f2c141998-03-11 12:08:21 +000042
Fred Drakedb34a1e1998-03-10 23:02:57 +000043# A little painful, but lets us clean up the top level directory a little,
Fred Drake85d14c92000-07-31 17:53:45 +000044# 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.
Fred Drakedb34a1e1998-03-10 23:02:57 +000049#
Fred Drake85d14c92000-07-31 17:53:45 +000050if (!defined $mydir) {
51 use Cwd;
52 use File::Basename;
53 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
Fred Drake7a556422003-09-04 22:21:17 +000054 chop $mydir; # remove trailing '/'
Fred Drake85d14c92000-07-31 17:53:45 +000055 $mydir = getcwd() . "$dd$mydir"
56 unless $mydir =~ s|^/|/|;
57}
Fred Drakedb34a1e1998-03-10 23:02:57 +000058$LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES";
Fred Drakeb3a3ed81998-07-24 22:17:34 +000059push (@INC, $mydir);
Fred Drakebc7101d1998-03-06 21:18:55 +000060
Fred Drake235e6b11998-03-27 05:19:43 +000061($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*');
62chop $myrootdir;
63
Fred Drakebc7101d1998-03-06 21:18:55 +000064
Fred Drakea4565b01998-05-15 17:14:17 +000065# 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.
69#
70if (defined $ENV{'PAPER'}) {
71 $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey";
72}
73else {
74 $mytexinputs = getcwd() . $envkey;
75}
76$mytexinputs .= "$myrootdir${dd}texinputs";
77
78
Fred Drakeb35f2b71999-09-23 16:53:09 +000079# Change this variable to change the text added in "About this document...";
80# this should be an absolute pathname to get it right.
81#
82$ABOUT_FILE = "$myrootdir${dd}html${dd}stdabout.dat";
83
84
Fred Drake85d14c92000-07-31 17:53:45 +000085sub custom_driver_hook {
Fred Drakea4565b01998-05-15 17:14:17 +000086 #
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.
90 #
Fred Drakecc2e48d2003-09-27 16:04:23 +000091 # 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.
94 #
Fred Drake73c5b6602002-10-24 16:36:05 +000095 my $file = $_[0];
Fred Drake85d14c92000-07-31 17:53:45 +000096 my($jobname, $dir, $ext) = fileparse($file, '\..*');
97 $dir = L2hos->Make_directory_absolute($dir);
Fred Drakea4565b01998-05-15 17:14:17 +000098 $dir =~ s/$dd$//;
99 $TEXINPUTS = "$dir$envkey$mytexinputs";
Fred Drakecc2e48d2003-09-27 16:04:23 +0000100 # 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;
107 }
108 print "\nSetting \$TEXINPUTS to $TEXINPUTS\n";
Fred Drake191439a1999-09-22 19:50:51 +0000109}
110
Fred Drakea4565b01998-05-15 17:14:17 +0000111
Fred Drake85d14c92000-07-31 17:53:45 +0000112$CUSTOM_BUTTONS = '';
Fred Drake062bc6e1998-08-13 22:03:46 +0000113
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000114sub make_nav_sectref($$$) {
115 my($label, $linktype, $title) = @_;
Fred Drakebeb27bf1999-02-16 17:22:32 +0000116 if ($title) {
Fred Drake02c70822000-09-19 15:36:19 +0000117 if ($title =~ /\<[aA] /) {
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000118 $title =~ s/\<[aA] /<a class="sectref" rel="$linktype" /;
Fred Drake2fc88a62003-08-05 03:45:37 +0000119 $title =~ s/ HREF=/ href=/;
Fred Drake02c70822000-09-19 15:36:19 +0000120 }
121 else {
122 $title = "<span class=\"sectref\">$title</span>";
123 }
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000124 return "<b class=\"navlabel\">$label:</b>\n$title\n";
Fred Drakebeb27bf1999-02-16 17:22:32 +0000125 }
126 return '';
127}
128
Fred Draked18722b2001-01-02 22:08:48 +0000129@my_icon_tags = ();
130$my_icon_tags{'next'} = 'Next Page';
131$my_icon_tags{'next_page'} = 'Next Page';
132$my_icon_tags{'previous'} = 'Previous Page';
133$my_icon_tags{'previous_page'} = 'Previous Page';
134$my_icon_tags{'up'} = 'Up One Level';
135$my_icon_tags{'contents'} = 'Contents';
136$my_icon_tags{'index'} = 'Index';
137$my_icon_tags{'modules'} = 'Module Index';
138
Fred Drakeb31d36c2001-01-04 15:16:01 +0000139@my_icon_names = ();
140$my_icon_names{'previous_page'} = 'previous';
141$my_icon_names{'next_page'} = 'next';
142
Fred Drakef5478632002-05-23 17:59:16 +0000143sub get_my_icon($) {
Fred Drake73c5b6602002-10-24 16:36:05 +0000144 my $name = $_[0];
Fred Draked18722b2001-01-02 22:08:48 +0000145 my $text = $my_icon_tags{$name};
Fred Drakeb31d36c2001-01-04 15:16:01 +0000146 if ($my_icon_names{$name}) {
147 $name = $my_icon_names{$name};
148 }
Fred Draked18722b2001-01-02 22:08:48 +0000149 if ($text eq '') {
150 $name = 'blank';
151 }
Fred Drake85d14c92000-07-31 17:53:45 +0000152 my $iconserver = ($ICONSERVER eq '.') ? '' : "$ICONSERVER/";
Fred Drakedd3d6a02002-10-30 17:00:58 +0000153 return "<img src='$iconserver$name.$IMAGE_TYPE'\n border='0'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000154 . " height='32' alt='$text' width='32' />";
Fred Drake85d14c92000-07-31 17:53:45 +0000155}
156
Fred Drake8b34e7c2003-05-03 02:07:22 +0000157sub unlinkify($) {
158 my $text = "$_[0]";
159 $text =~ s|</[aA]>||;
160 $text =~ s|<a\s+[^>]*>||i;
161 return $text;
162}
163
164sub use_icon($$$) {
165 my($rel,$str,$title) = @_;
166 if ($title) {
167 my $s = "$str";
168 if ($s =~ /\<tex2html_([a-z_]+)_visible_mark\>/) {
169 my $r = get_my_icon($1);
170 $s =~ s/\<tex2html_[a-z_]+_visible_mark\>/$r/;
171 }
172 $s =~ s/<[aA] /<a rel="$rel" title="$title" \n /;
Fred Drake2fc88a62003-08-05 03:45:37 +0000173 $s =~ s/ HREF=/ href=/;
Fred Drake8b34e7c2003-05-03 02:07:22 +0000174 return $s;
Fred Draked18722b2001-01-02 22:08:48 +0000175 }
Fred Drake8b34e7c2003-05-03 02:07:22 +0000176 else {
177 return get_my_icon('blank');
178 }
Fred Drake13210ed1998-03-17 06:28:05 +0000179}
180
Fred Drakef5478632002-05-23 17:59:16 +0000181sub make_nav_panel() {
Fred Drake85d14c92000-07-31 17:53:45 +0000182 my $s;
Fred Drake8b34e7c2003-05-03 02:07:22 +0000183 # new iconic rel iconic page title
184 $NEXT = use_icon('next', $NEXT, unlinkify($NEXT_TITLE));
185 $UP = use_icon('parent', $UP, unlinkify($UP_TITLE));
186 $PREVIOUS = use_icon('prev', $PREVIOUS, unlinkify($PREVIOUS_TITLE));
187 $CONTENTS = use_icon('contents', $CONTENTS, 'Table of Contents');
188 $INDEX = use_icon('index', $INDEX, 'Index');
Fred Drake85d14c92000-07-31 17:53:45 +0000189 if (!$CUSTOM_BUTTONS) {
Fred Drake8b34e7c2003-05-03 02:07:22 +0000190 $CUSTOM_BUTTONS = get_my_icon('blank');
Fred Drake85d14c92000-07-31 17:53:45 +0000191 }
192 $s = ('<table align="center" width="100%" cellpadding="0" cellspacing="2">'
193 . "\n<tr>"
194 # left-hand side
Fred Drake0739c442003-09-04 22:16:45 +0000195 . "\n<td class='online-navigation'>$PREVIOUS</td>"
196 . "\n<td class='online-navigation'>$UP</td>"
197 . "\n<td class='online-navigation'>$NEXT</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000198 # title box
Fred Drakef730fc32000-08-31 07:19:07 +0000199 . "\n<td align=\"center\" width=\"100%\">$t_title</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000200 # right-hand side
Fred Drake0739c442003-09-04 22:16:45 +0000201 . "\n<td class='online-navigation'>$CONTENTS</td>"
202 # module index
203 . "\n<td class='online-navigation'>$CUSTOM_BUTTONS</td>"
204 . "\n<td class='online-navigation'>$INDEX</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000205 . "\n</tr></table>\n"
206 # textual navigation
Fred Drake0739c442003-09-04 22:16:45 +0000207 . "<div class='online-navigation'>\n"
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000208 . make_nav_sectref("Previous", "prev", $PREVIOUS_TITLE)
209 . make_nav_sectref("Up", "parent", $UP_TITLE)
210 . make_nav_sectref("Next", "next", $NEXT_TITLE)
Fred Drake0739c442003-09-04 22:16:45 +0000211 . "</div>\n"
Fred Drake4640e132000-07-31 20:13:23 +0000212 );
Fred Drake85d14c92000-07-31 17:53:45 +0000213 # remove these; they are unnecessary and cause errors from validation
214 $s =~ s/ NAME="tex2html\d+"\n */ /g;
215 return $s;
216}
217
Fred Drakefb6499f2001-10-26 14:16:23 +0000218sub add_child_links {
219 my $toc = add_real_child_links(@_);
220 $toc =~ s|\s*</[aA]>|</a>|g;
221 $toc =~ s/ NAME=\"tex2html\d+\"\s*href=/ href=/gi;
Fred Drake2fc88a62003-08-05 03:45:37 +0000222 $toc =~ s|</UL>(\s*<BR( /)?>)?|</ul>|gi;
Fred Drake0739c442003-09-04 22:16:45 +0000223 if ($toc =~ / NAME=["']CHILD_LINKS["']/) {
224 return "<div class='online-navigation'>\n$toc</div>\n";
225 }
Fred Drakefb6499f2001-10-26 14:16:23 +0000226 return $toc;
227}
228
Fred Drakef5478632002-05-23 17:59:16 +0000229sub get_version_text() {
Fred Drake7497bd32000-10-25 16:18:10 +0000230 if ($PACKAGE_VERSION ne '' && $t_date) {
231 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000232 . "Release $PACKAGE_VERSION$RELEASE_INFO,"
Fred Drake7497bd32000-10-25 16:18:10 +0000233 . " documentation updated on $t_date.</span>");
234 }
235 if ($PACKAGE_VERSION ne '') {
236 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000237 . "Release $PACKAGE_VERSION$RELEASE_INFO.</span>");
Fred Drake7497bd32000-10-25 16:18:10 +0000238 }
239 if ($t_date) {
240 return ("<span class=\"release-info\">Documentation released on "
241 . "$t_date.</span>");
242 }
243 return '';
244}
245
Fred Drake85d14c92000-07-31 17:53:45 +0000246
Fred Drakef5478632002-05-23 17:59:16 +0000247sub top_navigation_panel() {
Fred Drake859c46a2003-09-04 19:30:15 +0000248 return "\n<div id='top-navigation-panel'>\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000249 . make_nav_panel()
Fred Drake11b138f2003-09-11 04:14:20 +0000250 . "<hr /></div>\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000251}
252
Fred Drakef5478632002-05-23 17:59:16 +0000253sub bot_navigation_panel() {
Fred Drake0739c442003-09-04 22:16:45 +0000254 return "\n<div class='online-navigation'>\n"
Fred Drake859c46a2003-09-04 19:30:15 +0000255 . "<p></p><hr />\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000256 . make_nav_panel()
Fred Drake859c46a2003-09-04 19:30:15 +0000257 . "</div>\n"
Fred Drake2fc88a62003-08-05 03:45:37 +0000258 . "<hr />\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000259 . get_version_text()
260 . "\n";
Fred Drake64bdc241998-04-17 02:14:12 +0000261}
262
263sub add_link {
264 # Returns a pair (iconic link, textual link)
265 my($icon, $current_file, @link) = @_;
266 my($dummy, $file, $title) = split($delim,
Fred Drake7a556422003-09-04 22:21:17 +0000267 $section_info{join(' ',@link)});
Fred Draked18722b2001-01-02 22:08:48 +0000268 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
269 my $r = get_my_icon($1);
270 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
271 }
Fred Drake64bdc241998-04-17 02:14:12 +0000272 if ($title && ($file ne $current_file)) {
273 $title = purify($title);
Fred Drake7a556422003-09-04 22:21:17 +0000274 $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
275 return (make_href($file, $icon), make_href($file, "$title"))
276 }
Fred Draked18722b2001-01-02 22:08:48 +0000277 elsif ($icon eq get_my_icon('up') && $EXTERNAL_UP_LINK) {
Fred Drake7a556422003-09-04 22:21:17 +0000278 return (make_href($EXTERNAL_UP_LINK, $icon),
279 make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
280 }
Fred Draked18722b2001-01-02 22:08:48 +0000281 elsif ($icon eq get_my_icon('previous')
Fred Drake7a556422003-09-04 22:21:17 +0000282 && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
283 return (make_href($EXTERNAL_PREV_LINK, $icon),
284 make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
285 }
Fred Draked18722b2001-01-02 22:08:48 +0000286 elsif ($icon eq get_my_icon('next')
Fred Drake7a556422003-09-04 22:21:17 +0000287 && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
288 return (make_href($EXTERNAL_DOWN_LINK, $icon),
289 make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
290 }
Fred Drake85d14c92000-07-31 17:53:45 +0000291 return (&inactive_img($icon), "");
Fred Drake64bdc241998-04-17 02:14:12 +0000292}
293
Fred Drakef5478632002-05-23 17:59:16 +0000294sub add_special_link($$$) {
Fred Drake64bdc241998-04-17 02:14:12 +0000295 my($icon, $file, $current_file) = @_;
Fred Draked18722b2001-01-02 22:08:48 +0000296 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
297 my $r = get_my_icon($1);
298 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
299 }
Fred Drake85d14c92000-07-31 17:53:45 +0000300 return (($file && ($file ne $current_file))
301 ? make_href($file, $icon)
302 : undef)
Fred Drake64bdc241998-04-17 02:14:12 +0000303}
304
Fred Drake85d14c92000-07-31 17:53:45 +0000305# The img_tag() function seems only to be called with the parameter
306# 'anchor_invisible_mark', which we want to turn into ''. Since
307# replace_icon_marks() is the only interesting caller, and all it really
308# does is call img_tag(), we can just define the hook alternative to be
309# a no-op instead.
310#
311sub replace_icons_hook {}
Fred Drakebc7101d1998-03-06 21:18:55 +0000312
Fred Drake50cdd971999-02-19 23:04:59 +0000313sub do_cmd_arabic {
314 # get rid of that nasty <SPAN CLASS="arabic">...</SPAN>
Fred Drake73c5b6602002-10-24 16:36:05 +0000315 my($ctr, $val, $id, $text) = &read_counter_value($_[0]);
Fred Drake85d14c92000-07-31 17:53:45 +0000316 return ($val ? farabic($val) : "0") . $text;
Fred Drake50cdd971999-02-19 23:04:59 +0000317}
318
319
Fred Drakef5478632002-05-23 17:59:16 +0000320sub gen_index_id($$) {
Fred Drakebc7101d1998-03-06 21:18:55 +0000321 # this is used to ensure common index key generation and a stable sort
Fred Drakef5478632002-05-23 17:59:16 +0000322 my($str, $extra) = @_;
Fred Drake64bdc241998-04-17 02:14:12 +0000323 sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
Fred Drakebc7101d1998-03-06 21:18:55 +0000324}
325
Fred Drakef5478632002-05-23 17:59:16 +0000326sub insert_index($$$$$) {
327 my($mark, $datafile, $columns, $letters, $prefix) = @_;
Fred Drake4d10b431998-08-07 20:51:58 +0000328 my $prog = "$myrootdir/tools/buildindex.py";
329 my $index;
330 if ($letters) {
Fred Drake7a556422003-09-04 22:21:17 +0000331 $index = `$prog --columns $columns --letters $datafile`;
Fred Drake4d10b431998-08-07 20:51:58 +0000332 }
333 else {
Fred Drake7a556422003-09-04 22:21:17 +0000334 $index = `$prog --columns $columns $datafile`;
Fred Drake4d10b431998-08-07 20:51:58 +0000335 }
Fred Drakec5681732000-09-12 20:13:04 +0000336 if (!s/$mark/$prefix$index/) {
337 print "\nCould not locate index mark: $mark";
338 }
Fred Drake64bdc241998-04-17 02:14:12 +0000339}
340
Fred Drakef5478632002-05-23 17:59:16 +0000341sub add_idx() {
Fred Drake9bbdce51999-01-19 16:30:10 +0000342 print "\nBuilding HTML for the index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000343 close(IDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000344 insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
Fred Drake13210ed1998-03-17 06:28:05 +0000345}
Fred Drakebc7101d1998-03-06 21:18:55 +0000346
347
348$idx_module_mark = '<tex2html_idx_module_mark>';
349$idx_module_title = 'Module Index';
350
Fred Drakef5478632002-05-23 17:59:16 +0000351sub add_module_idx() {
Fred Drake9bbdce51999-01-19 16:30:10 +0000352 print "\nBuilding HTML for the module index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000353 my $key;
Fred Drake2383f6d1999-03-02 16:00:37 +0000354 my $first = 1;
355 my $prevplat = '';
356 my $allthesame = 1;
357 my $prefix = '';
358 foreach $key (keys %Modules) {
Fred Drake7a556422003-09-04 22:21:17 +0000359 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
360 my $plat = "$ModulePlatforms{$key}";
361 $plat = ''
362 if ($plat eq $IGNORE_PLATFORM_ANNOTATION);
363 if (!$first) {
364 $allthesame = 0
365 if ($prevplat ne $plat);
366 }
367 else { $first = 0; }
368 $prevplat = $plat;
Fred Drake2383f6d1999-03-02 16:00:37 +0000369 }
Fred Drake64bdc241998-04-17 02:14:12 +0000370 open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
Fred Drake235e6b11998-03-27 05:19:43 +0000371 foreach $key (keys %Modules) {
Fred Drake7a556422003-09-04 22:21:17 +0000372 # dump the line in the data file; just use a dummy seqno field
373 my $nkey = $1;
374 my $moditem = "$Modules{$key}";
375 my $plat = '';
376 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
377 if ($ModulePlatforms{$key} && !$allthesame) {
378 $plat = (" <em>(<span class=\"platform\">$ModulePlatforms{$key}"
379 . '</span>)</em>');
380 }
381 print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP
Fred Drakedce975c2001-06-20 21:31:36 +0000382 . "<tt class=\"module\">$key</tt>$plat###\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000383 }
Fred Drake235e6b11998-03-27 05:19:43 +0000384 close(MODIDXFILE);
Fred Drake42181db2001-01-09 22:02:10 +0000385
386 if ($GLOBAL_MODULE_INDEX) {
387 $prefix = <<MODULE_INDEX_PREFIX;
388
389<p> This index only lists modules documented in this manual.
390 The <em class="citetitle"><a href="$GLOBAL_MODULE_INDEX">Global Module
391 Index</a></em> lists all modules that are documented in this set
392 of manuals.</p>
393MODULE_INDEX_PREFIX
394 }
Fred Drake2383f6d1999-03-02 16:00:37 +0000395 if (!$allthesame) {
Fred Drake7a556422003-09-04 22:21:17 +0000396 $prefix .= <<PLAT_DISCUSS;
Fred Drake2383f6d1999-03-02 16:00:37 +0000397
398<p> Some module names are followed by an annotation indicating what
399platform they are available on.</p>
400
401PLAT_DISCUSS
402 }
403 insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
Fred Drake7a556422003-09-04 22:21:17 +0000404 $prefix);
Fred Drakebc7101d1998-03-06 21:18:55 +0000405}
406
Fred Drake235e6b11998-03-27 05:19:43 +0000407# replace both indexes as needed:
Fred Drake85d14c92000-07-31 17:53:45 +0000408sub add_idx_hook {
Fred Drakeb3a3ed81998-07-24 22:17:34 +0000409 add_idx() if (/$idx_mark/);
Fred Drake2383f6d1999-03-02 16:00:37 +0000410 process_python_state();
Fred Drakec5681732000-09-12 20:13:04 +0000411 if ($MODULE_INDEX_FILE) {
412 local ($_);
413 open(MYFILE, "<$MODULE_INDEX_FILE");
414 sysread(MYFILE, $_, 1024*1024);
415 close(MYFILE);
416 add_module_idx();
417 open(MYFILE,">$MODULE_INDEX_FILE");
418 print MYFILE $_;
419 close(MYFILE);
420 }
Fred Drake235e6b11998-03-27 05:19:43 +0000421}
Fred Drakebc7101d1998-03-06 21:18:55 +0000422
Fred Drakebc7101d1998-03-06 21:18:55 +0000423
Fred Drake191439a1999-09-22 19:50:51 +0000424# In addition to the standard stuff, add label to allow named node files and
425# support suppression of the page complete (for HTML Help use).
Fred Drake095f8172003-06-27 18:26:01 +0000426$MY_CONTENTS_PAGE = '';
Fred Drakebc7101d1998-03-06 21:18:55 +0000427sub do_cmd_tableofcontents {
428 local($_) = @_;
429 $TITLE = $toc_title;
430 $tocfile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000431 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000432 anchor_label('contents', $CURRENT_FILE, $_); # this is added
Fred Drake095f8172003-06-27 18:26:01 +0000433 $MY_CONTENTS_PAGE = "$CURRENT_FILE";
Fred Drake2fc88a62003-08-05 03:45:37 +0000434 join('', "<br />\n\\tableofchildlinks[off]", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000435 , make_section_heading($toc_title, 'h2'), $toc_mark
436 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000437}
438# In addition to the standard stuff, add label to allow named node files.
439sub do_cmd_listoffigures {
440 local($_) = @_;
441 $TITLE = $lof_title;
442 $loffile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000443 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000444 anchor_label('lof', $CURRENT_FILE, $_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000445 join('', "<br />\n", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000446 , make_section_heading($lof_title, 'h2'), $lof_mark
447 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000448}
449# In addition to the standard stuff, add label to allow named node files.
450sub do_cmd_listoftables {
451 local($_) = @_;
452 $TITLE = $lot_title;
453 $lotfile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000454 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000455 anchor_label('lot', $CURRENT_FILE, $_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000456 join('', "<br />\n", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000457 , make_section_heading($lot_title, 'h2'), $lot_mark
458 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000459}
460# In addition to the standard stuff, add label to allow named node files.
461sub do_cmd_textohtmlinfopage {
462 local($_) = @_;
Fred Drake7a556422003-09-04 22:21:17 +0000463 if ($INFO) { #
464 anchor_label("about",$CURRENT_FILE,$_); # this is added
465 } #
466 my $the_version = ''; # and the rest is
467 if ($t_date) { # mostly ours
468 $the_version = ",\n$t_date";
469 if ($PACKAGE_VERSION) {
470 $the_version .= ", Release $PACKAGE_VERSION$RELEASE_INFO";
471 }
Fred Drake15796f71998-11-30 19:25:47 +0000472 }
Fred Drake9443dc32001-08-10 20:12:09 +0000473 my $about;
474 open(ABOUT, "<$ABOUT_FILE") || die "\n$!\n";
475 sysread(ABOUT, $about, 1024*1024);
476 close(ABOUT);
Fred Drake15796f71998-11-30 19:25:47 +0000477 $_ = (($INFO == 1)
Fred Drakeb35f2b71999-09-23 16:53:09 +0000478 ? join('',
479 $close_all,
480 "<strong>$t_title</strong>$the_version\n",
Fred Drake9443dc32001-08-10 20:12:09 +0000481 $about,
Fred Drakeb35f2b71999-09-23 16:53:09 +0000482 $open_all, $_)
483 : join('', $close_all, $INFO,"\n", $open_all, $_));
Fred Drake15796f71998-11-30 19:25:47 +0000484 $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000485}
486
487# $idx_mark will be replaced with the real index at the end
488sub do_cmd_textohtmlindex {
489 local($_) = @_;
490 $TITLE = $idx_title;
491 $idxfile = $CURRENT_FILE;
Fred Drake235e6b11998-03-27 05:19:43 +0000492 if (%index_labels) { make_index_labels(); }
493 if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); }
Fred Drakebc7101d1998-03-06 21:18:55 +0000494 else { $preindex = ''; }
Fred Drake235e6b11998-03-27 05:19:43 +0000495 my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
Fred Drakef5478632002-05-23 17:59:16 +0000496 my($pre, $post) = minimize_open_tags($heading);
Fred Drake7a556422003-09-04 22:21:17 +0000497 anchor_label('genindex',$CURRENT_FILE,$_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000498 return "<br />\n" . $pre . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000499}
500
Fred Drakec5681732000-09-12 20:13:04 +0000501$MODULE_INDEX_FILE = '';
502
Fred Drakebc7101d1998-03-06 21:18:55 +0000503# $idx_module_mark will be replaced with the real index at the end
504sub do_cmd_textohtmlmoduleindex {
505 local($_) = @_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000506 $TITLE = $idx_module_title;
Fred Drakec5681732000-09-12 20:13:04 +0000507 anchor_label('modindex', $CURRENT_FILE, $_);
508 $MODULE_INDEX_FILE = "$CURRENT_FILE";
Fred Drake2fc88a62003-08-05 03:45:37 +0000509 $_ = ('<p></p>' . make_section_heading($idx_module_title, 'h2')
Fred Drakec5681732000-09-12 20:13:04 +0000510 . $idx_module_mark . $_);
511 return $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000512}
513
Fred Drakec5681732000-09-12 20:13:04 +0000514# The bibliography and the index should be treated as separate
515# sections in their own HTML files. The \bibliography{} command acts
516# as a sectioning command that has the desired effect. But when the
517# bibliography is constructed manually using the thebibliography
518# environment, or when using the theindex environment it is not
519# possible to use the normal sectioning mechanism. This subroutine
520# inserts a \bibliography{} or a dummy \textohtmlindex command just
521# before the appropriate environments to force sectioning.
Fred Drakebc7101d1998-03-06 21:18:55 +0000522
Fred Drake7a556422003-09-04 22:21:17 +0000523# XXX This *assumes* that if there are two {theindex} environments,
524# the first is the module index and the second is the standard
525# index. This is sufficient for the current Python documentation,
526# but that's about it.
Fred Drakebc7101d1998-03-06 21:18:55 +0000527
528sub add_bbl_and_idx_dummy_commands {
Fred Drake11916921998-04-02 22:30:57 +0000529 my $id = $global{'max_id'};
Fred Drakebc7101d1998-03-06 21:18:55 +0000530
Fred Drakea219b412001-10-22 16:57:49 +0000531 if (/[\\]tableofcontents/) {
532 $HAVE_TABLE_OF_CONTENTS = 1;
533 }
Fred Drakebc7101d1998-03-06 21:18:55 +0000534 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
Fred Drake191439a1999-09-22 19:50:51 +0000535 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 +0000536 my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/);
537 if (scalar(@parts) == 3) {
538 # Be careful to re-write the string in place, since $_ is *not*
539 # returned explicity; *** nasty side-effect dependency! ***
Fred Drakebb7775a2001-12-04 17:03:54 +0000540 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
Fred Drake85d14c92000-07-31 17:53:45 +0000541 print "\nadd_bbl_and_idx_dummy_commands ==> adding module index";
542 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)"
543 . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
Fred Drake73c5b6602002-10-24 16:36:05 +0000544 s/$rx/\\textohtmlmoduleindex $1 \\textohtmlindex $2/o;
Fred Drake85d14c92000-07-31 17:53:45 +0000545 # Add a button to the navigation areas:
Fred Drakeaaa23852000-09-14 22:20:41 +0000546 $CUSTOM_BUTTONS .= ('<a href="modindex.html" title="Module Index">'
Fred Draked18722b2001-01-02 22:08:48 +0000547 . get_my_icon('modules')
Fred Drakeaaa23852000-09-14 22:20:41 +0000548 . '</a>');
Fred Drakea219b412001-10-22 16:57:49 +0000549 $HAVE_MODULE_INDEX = 1;
550 $HAVE_GENERAL_INDEX = 1;
551 }
552 elsif (scalar(@parts) == 2) {
Fred Drakebb7775a2001-12-04 17:03:54 +0000553 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
554 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
Fred Drake73c5b6602002-10-24 16:36:05 +0000555 s/$rx/\\textohtmlindex $1/o;
Fred Drakea219b412001-10-22 16:57:49 +0000556 $HAVE_GENERAL_INDEX = 1;
Fred Drake11916921998-04-02 22:30:57 +0000557 }
Fred Drakebb7775a2001-12-04 17:03:54 +0000558 elsif (scalar(@parts) == 1) {
559 print "\nadd_bbl_and_idx_dummy_commands ==> no index found";
Fred Draked18722b2001-01-02 22:08:48 +0000560 $CUSTOM_BUTTONS .= get_my_icon('blank');
Fred Drake85d14c92000-07-31 17:53:45 +0000561 $global{'max_id'} = $id; # not sure why....
562 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
Fred Drake7a556422003-09-04 22:21:17 +0000563 s/[\\]printindex/\\textohtmlindex /o;
Fred Drakebb7775a2001-12-04 17:03:54 +0000564 }
565 else {
566 die "\n\nBad number of index environments!\n\n";
567 }
Fred Drake11916921998-04-02 22:30:57 +0000568 #----------------------------------------------------------------------
Fred Drake64bdc241998-04-17 02:14:12 +0000569 lib_add_bbl_and_idx_dummy_commands()
Fred Drake11916921998-04-02 22:30:57 +0000570 if defined(&lib_add_bbl_and_idx_dummy_commands);
Fred Drakebc7101d1998-03-06 21:18:55 +0000571}
572
Fred Drakec5681732000-09-12 20:13:04 +0000573# The bibliographic references, the appendices, the lists of figures
574# and tables etc. must appear in the contents table at the same level
575# as the outermost sectioning command. This subroutine finds what is
576# the outermost level and sets the above to the same level;
Fred Drakebc7101d1998-03-06 21:18:55 +0000577
Fred Drake13210ed1998-03-17 06:28:05 +0000578sub set_depth_levels {
579 # Sets $outermost_level
Fred Drake11916921998-04-02 22:30:57 +0000580 my $level;
Fred Drake13210ed1998-03-17 06:28:05 +0000581 #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
582 foreach $level ("part", "chapter", "section", "subsection",
Fred Drake7a556422003-09-04 22:21:17 +0000583 "subsubsection", "paragraph") {
584 last if (($outermost_level) = /\\($level)$delimiter_rx/);
Fred Drake13210ed1998-03-17 06:28:05 +0000585 }
586 $level = ($outermost_level ? $section_commands{$outermost_level} :
Fred Drake7a556422003-09-04 22:21:17 +0000587 do {$outermost_level = 'section'; 3;});
Fred Drakebc7101d1998-03-06 21:18:55 +0000588
Fred Drake13210ed1998-03-17 06:28:05 +0000589 #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
Fred Drake7a556422003-09-04 22:21:17 +0000590 if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
591 $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
Fred Drake13210ed1998-03-17 06:28:05 +0000592 } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
Fred Drakebc7101d1998-03-06 21:18:55 +0000593
Fred Drake64bdc241998-04-17 02:14:12 +0000594 %unnumbered_section_commands = ('tableofcontents' => $level,
Fred Drake7a556422003-09-04 22:21:17 +0000595 'listoffigures' => $level,
596 'listoftables' => $level,
597 'bibliography' => $level,
598 'textohtmlindex' => $level,
599 'textohtmlmoduleindex' => $level);
Fred Drake64bdc241998-04-17 02:14:12 +0000600 $section_headings{'textohtmlmoduleindex'} = 'h1';
Fred Drakebc7101d1998-03-06 21:18:55 +0000601
Fred Drake64bdc241998-04-17 02:14:12 +0000602 %section_commands = (%unnumbered_section_commands,
Fred Drake7a556422003-09-04 22:21:17 +0000603 %section_commands);
Fred Drake11916921998-04-02 22:30:57 +0000604
605 make_sections_rx();
Fred Drake13210ed1998-03-17 06:28:05 +0000606}
Fred Drakebc7101d1998-03-06 21:18:55 +0000607
608
Fred Drake1072e461998-04-12 02:16:34 +0000609# This changes the markup used for {verbatim} environments, and is the
Fred Drake95474f91999-02-09 18:45:50 +0000610# best way I've found that ensures the <dl> goes on the outside of the
Fred Drake1072e461998-04-12 02:16:34 +0000611# <pre>...</pre>.
612#
613# Note that this *must* be done in the init file, not the python.perl
Fred Drakec5681732000-09-12 20:13:04 +0000614# style support file. The %declarations must be set before
615# initialize() is called in the main LaTeX2HTML script (which happens
616# before style files are loaded).
Fred Drake1072e461998-04-12 02:16:34 +0000617#
Fred Drake8a5e6792002-04-15 18:41:31 +0000618%declarations = ('preform' => '<div class="verbatim"><pre></pre></div>',
Fred Drake7a556422003-09-04 22:21:17 +0000619 %declarations);
Fred Drake1072e461998-04-12 02:16:34 +0000620
Fred Drakee15956b2000-04-03 04:51:13 +0000621
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000622# This is used to map the link rel attributes LaTeX2HTML uses to those
623# currently recommended by the W3C.
624sub custom_REL_hook {
625 my($rel,$junk) = @_;
626 return 'parent' if $rel eq 'up';
627 return 'prev' if $rel eq 'previous';
628 return $rel;
629}
630
Fred Drakec5681732000-09-12 20:13:04 +0000631# This is added to get rid of the long comment that follows the
632# doctype declaration; MSIE5 on NT4 SP4 barfs on it and drops the
633# content of the page.
Fred Drakea219b412001-10-22 16:57:49 +0000634$MY_PARTIAL_HEADER = '';
Fred Drakef5478632002-05-23 17:59:16 +0000635sub make_head_and_body($$) {
Fred Drake85d14c92000-07-31 17:53:45 +0000636 my($title, $body) = @_;
Fred Drake16816272000-09-16 20:40:44 +0000637 $body = " $body" unless ($body eq '');
Fred Drake85d14c92000-07-31 17:53:45 +0000638 my $DTDcomment = '';
639 my($version, $isolanguage) = ($HTML_VERSION, 'EN');
640 my %isolanguages = ( 'english', 'EN' , 'USenglish', 'EN.US'
641 , 'original', 'EN' , 'german' , 'DE'
642 , 'austrian', 'DE.AT', 'french' , 'FR'
643 , 'spanish', 'ES');
Fred Drakee15956b2000-04-03 04:51:13 +0000644 $isolanguage = $isolanguages{$default_language};
645 $isolanguage = 'EN' unless $isolanguage;
646 $title = &purify($title,1);
647 eval("\$title = ". $default_title ) unless ($title);
648
Fred Drake2fc88a62003-08-05 03:45:37 +0000649 # allow user-modification of the <title> tag; thanks Dan Young
Fred Drakee15956b2000-04-03 04:51:13 +0000650 if (defined &custom_TITLE_hook) {
Fred Drake7a556422003-09-04 22:21:17 +0000651 $title = &custom_TITLE_hook($title, $toc_sec_title);
Fred Drakee15956b2000-04-03 04:51:13 +0000652 }
653
654 if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included
Fred Drake7a556422003-09-04 22:21:17 +0000655 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000656 } else {
Fred Drake7a556422003-09-04 22:21:17 +0000657 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//"
658 . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000659 }
Fred Drakea219b412001-10-22 16:57:49 +0000660 if ($MY_PARTIAL_HEADER eq '') {
661 $STYLESHEET = $FILE.".css" unless $STYLESHEET;
662 $MY_PARTIAL_HEADER = join('',
Fred Drakedd3d6a02002-10-30 17:00:58 +0000663 ($DOCTYPE ? $DTDcomment : ''),
Fred Drake98b25762003-05-02 18:21:22 +0000664 "<html>\n<head>",
Fred Drake2fc88a62003-08-05 03:45:37 +0000665 ($BASE ? "\n<base href=\"$BASE\" />" : ''),
666 "\n<link rel=\"STYLESHEET\" href=\"$STYLESHEET\" type='text/css'",
667 " />",
Fred Drakedd3d6a02002-10-30 17:00:58 +0000668 ($FAVORITES_ICON
Fred Drake2fc88a62003-08-05 03:45:37 +0000669 ? ("\n<link rel=\"SHORTCUT ICON\" href=\"$FAVORITES_ICON\" />")
Fred Drakedd3d6a02002-10-30 17:00:58 +0000670 : ''),
Fred Drake23949002002-10-30 21:51:18 +0000671 ($EXTERNAL_UP_LINK
Fred Drake98b25762003-05-02 18:21:22 +0000672 ? ("\n<link rel='start' href='" . $EXTERNAL_UP_LINK
673 . ($EXTERNAL_UP_TITLE ?
Fred Drake2fc88a62003-08-05 03:45:37 +0000674 "' title='$EXTERNAL_UP_TITLE' />" : "' />"))
Fred Drake23949002002-10-30 21:51:18 +0000675 : ''),
Fred Drake98b25762003-05-02 18:21:22 +0000676 "\n<link rel=\"first\" href=\"$FILE.html\"",
Fred Drake23949002002-10-30 21:51:18 +0000677 ($t_title ? " title='$t_title'" : ''),
Fred Drake2fc88a62003-08-05 03:45:37 +0000678 ' />',
Fred Drakea219b412001-10-22 16:57:49 +0000679 ($HAVE_TABLE_OF_CONTENTS
Fred Drake095f8172003-06-27 18:26:01 +0000680 ? ("\n<link rel='contents' href='$MY_CONTENTS_PAGE'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000681 . ' title="Contents" />')
Fred Drakea219b412001-10-22 16:57:49 +0000682 : ''),
683 ($HAVE_GENERAL_INDEX
Fred Drake2fc88a62003-08-05 03:45:37 +0000684 ? "\n<link rel='index' href='genindex.html' title='Index' />"
Fred Drakea219b412001-10-22 16:57:49 +0000685 : ''),
686 # disable for now -- Mozilla doesn't do well with multiple indexes
687 # ($HAVE_MODULE_INDEX
Fred Drake2fc88a62003-08-05 03:45:37 +0000688 # ? '<link rel="index" href="modindex.html" title="Module Index"'
689 # . " />\n"
Fred Drakea219b412001-10-22 16:57:49 +0000690 # : ''),
Fred Drake23949002002-10-30 21:51:18 +0000691 ($INFO
692 # XXX We can do this with the Python tools since the About...
693 # page always gets copied to about.html, even when we use the
694 # generated node###.html page names. Won't work with the
695 # rest of the Python doc tools.
Fred Drake98b25762003-05-02 18:21:22 +0000696 ? ("\n<link rel='last' href='about.html'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000697 . " title='About this document...' />"
Fred Drake98b25762003-05-02 18:21:22 +0000698 . "\n<link rel='help' href='about.html'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000699 . " title='About this document...' />")
Fred Drake23949002002-10-30 21:51:18 +0000700 : ''),
Fred Drakedd3d6a02002-10-30 17:00:58 +0000701 $more_links_mark,
Fred Drake0e2e6872002-10-30 19:55:23 +0000702 "\n",
Fred Drakedd3d6a02002-10-30 17:00:58 +0000703 ($CHARSET && $HTML_VERSION ge "2.1"
704 ? ('<meta http-equiv="Content-Type" content="text/html; '
Fred Drake2fc88a62003-08-05 03:45:37 +0000705 . "charset=$CHARSET\" />\n")
Fred Drakedd3d6a02002-10-30 17:00:58 +0000706 : ''),
707 ($AESOP_META_TYPE
Fred Drake2fc88a62003-08-05 03:45:37 +0000708 ? "<meta name='aesop' content='$AESOP_META_TYPE' />\n" : ''));
Fred Drakea219b412001-10-22 16:57:49 +0000709 }
Fred Drake0e2e6872002-10-30 19:55:23 +0000710 if (!$charset && $CHARSET) {
711 $charset = $CHARSET;
712 $charset =~ s/_/\-/go;
713 }
Fred Drakef06b9052003-05-02 18:08:16 +0000714 # Remove section number from the title for use in the
715 # <meta name='description' ...> element in the document head.
716 my $metatitle = "$title";
717 $metatitle =~ s/^\d+(\.\d+)*\s*//;
Fred Drake2fc88a62003-08-05 03:45:37 +0000718 $metatitle = meta_information($metatitle);
719 $metatitle =~ s/ NAME=/ name=/g;
720 $metatitle =~ s/ CONTENT=/ content=/g;
Fred Drakef06b9052003-05-02 18:08:16 +0000721
Fred Drakedd3d6a02002-10-30 17:00:58 +0000722 join('',
723 $MY_PARTIAL_HEADER,
Fred Drake2fc88a62003-08-05 03:45:37 +0000724 $metatitle,
Fred Drakedd3d6a02002-10-30 17:00:58 +0000725 "<title>", $title, "</title>\n</head>\n<body$body>");
Fred Drakee15956b2000-04-03 04:51:13 +0000726}
727
Fred Drake2fc88a62003-08-05 03:45:37 +0000728sub replace_morelinks {
729 $more_links =~ s/ REL=/ rel=/g;
730 $more_links =~ s/ HREF=/ href=/g;
731 $_ =~ s/$more_links_mark/$more_links/e;
732}
733
Fred Drake7a556422003-09-04 22:21:17 +00007341; # This must be the last line