blob: 2456d9a87065144451d97f12e7ee0693c597d25d [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 Drake73c5b6602002-10-24 16:36:05 +000091 my $file = $_[0];
Fred Drake85d14c92000-07-31 17:53:45 +000092 my($jobname, $dir, $ext) = fileparse($file, '\..*');
93 $dir = L2hos->Make_directory_absolute($dir);
Fred Drakea4565b01998-05-15 17:14:17 +000094 $dir =~ s/$dd$//;
95 $TEXINPUTS = "$dir$envkey$mytexinputs";
Fred Drake85d14c92000-07-31 17:53:45 +000096 print "\nAdding $dir to \$TEXINPUTS\n";
Fred Drake191439a1999-09-22 19:50:51 +000097}
98
Fred Drakea4565b01998-05-15 17:14:17 +000099
Fred Drake85d14c92000-07-31 17:53:45 +0000100$CUSTOM_BUTTONS = '';
Fred Drake062bc6e1998-08-13 22:03:46 +0000101
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000102sub make_nav_sectref($$$) {
103 my($label, $linktype, $title) = @_;
Fred Drakebeb27bf1999-02-16 17:22:32 +0000104 if ($title) {
Fred Drake02c70822000-09-19 15:36:19 +0000105 if ($title =~ /\<[aA] /) {
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000106 $title =~ s/\<[aA] /<a class="sectref" rel="$linktype" /;
Fred Drake2fc88a62003-08-05 03:45:37 +0000107 $title =~ s/ HREF=/ href=/;
Fred Drake02c70822000-09-19 15:36:19 +0000108 }
109 else {
110 $title = "<span class=\"sectref\">$title</span>";
111 }
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000112 return "<b class=\"navlabel\">$label:</b>\n$title\n";
Fred Drakebeb27bf1999-02-16 17:22:32 +0000113 }
114 return '';
115}
116
Fred Draked18722b2001-01-02 22:08:48 +0000117@my_icon_tags = ();
118$my_icon_tags{'next'} = 'Next Page';
119$my_icon_tags{'next_page'} = 'Next Page';
120$my_icon_tags{'previous'} = 'Previous Page';
121$my_icon_tags{'previous_page'} = 'Previous Page';
122$my_icon_tags{'up'} = 'Up One Level';
123$my_icon_tags{'contents'} = 'Contents';
124$my_icon_tags{'index'} = 'Index';
125$my_icon_tags{'modules'} = 'Module Index';
126
Fred Drakeb31d36c2001-01-04 15:16:01 +0000127@my_icon_names = ();
128$my_icon_names{'previous_page'} = 'previous';
129$my_icon_names{'next_page'} = 'next';
130
Fred Drakef5478632002-05-23 17:59:16 +0000131sub get_my_icon($) {
Fred Drake73c5b6602002-10-24 16:36:05 +0000132 my $name = $_[0];
Fred Draked18722b2001-01-02 22:08:48 +0000133 my $text = $my_icon_tags{$name};
Fred Drakeb31d36c2001-01-04 15:16:01 +0000134 if ($my_icon_names{$name}) {
135 $name = $my_icon_names{$name};
136 }
Fred Draked18722b2001-01-02 22:08:48 +0000137 if ($text eq '') {
138 $name = 'blank';
139 }
Fred Drake85d14c92000-07-31 17:53:45 +0000140 my $iconserver = ($ICONSERVER eq '.') ? '' : "$ICONSERVER/";
Fred Drakedd3d6a02002-10-30 17:00:58 +0000141 return "<img src='$iconserver$name.$IMAGE_TYPE'\n border='0'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000142 . " height='32' alt='$text' width='32' />";
Fred Drake85d14c92000-07-31 17:53:45 +0000143}
144
Fred Drake8b34e7c2003-05-03 02:07:22 +0000145sub unlinkify($) {
146 my $text = "$_[0]";
147 $text =~ s|</[aA]>||;
148 $text =~ s|<a\s+[^>]*>||i;
149 return $text;
150}
151
152sub use_icon($$$) {
153 my($rel,$str,$title) = @_;
154 if ($title) {
155 my $s = "$str";
156 if ($s =~ /\<tex2html_([a-z_]+)_visible_mark\>/) {
157 my $r = get_my_icon($1);
158 $s =~ s/\<tex2html_[a-z_]+_visible_mark\>/$r/;
159 }
160 $s =~ s/<[aA] /<a rel="$rel" title="$title" \n /;
Fred Drake2fc88a62003-08-05 03:45:37 +0000161 $s =~ s/ HREF=/ href=/;
Fred Drake8b34e7c2003-05-03 02:07:22 +0000162 return $s;
Fred Draked18722b2001-01-02 22:08:48 +0000163 }
Fred Drake8b34e7c2003-05-03 02:07:22 +0000164 else {
165 return get_my_icon('blank');
166 }
Fred Drake13210ed1998-03-17 06:28:05 +0000167}
168
Fred Drakef5478632002-05-23 17:59:16 +0000169sub make_nav_panel() {
Fred Drake85d14c92000-07-31 17:53:45 +0000170 my $s;
Fred Drake8b34e7c2003-05-03 02:07:22 +0000171 # new iconic rel iconic page title
172 $NEXT = use_icon('next', $NEXT, unlinkify($NEXT_TITLE));
173 $UP = use_icon('parent', $UP, unlinkify($UP_TITLE));
174 $PREVIOUS = use_icon('prev', $PREVIOUS, unlinkify($PREVIOUS_TITLE));
175 $CONTENTS = use_icon('contents', $CONTENTS, 'Table of Contents');
176 $INDEX = use_icon('index', $INDEX, 'Index');
Fred Drake85d14c92000-07-31 17:53:45 +0000177 if (!$CUSTOM_BUTTONS) {
Fred Drake8b34e7c2003-05-03 02:07:22 +0000178 $CUSTOM_BUTTONS = get_my_icon('blank');
Fred Drake85d14c92000-07-31 17:53:45 +0000179 }
180 $s = ('<table align="center" width="100%" cellpadding="0" cellspacing="2">'
181 . "\n<tr>"
182 # left-hand side
Fred Drake0739c442003-09-04 22:16:45 +0000183 . "\n<td class='online-navigation'>$PREVIOUS</td>"
184 . "\n<td class='online-navigation'>$UP</td>"
185 . "\n<td class='online-navigation'>$NEXT</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000186 # title box
Fred Drakef730fc32000-08-31 07:19:07 +0000187 . "\n<td align=\"center\" width=\"100%\">$t_title</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000188 # right-hand side
Fred Drake0739c442003-09-04 22:16:45 +0000189 . "\n<td class='online-navigation'>$CONTENTS</td>"
190 # module index
191 . "\n<td class='online-navigation'>$CUSTOM_BUTTONS</td>"
192 . "\n<td class='online-navigation'>$INDEX</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000193 . "\n</tr></table>\n"
194 # textual navigation
Fred Drake0739c442003-09-04 22:16:45 +0000195 . "<div class='online-navigation'>\n"
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000196 . make_nav_sectref("Previous", "prev", $PREVIOUS_TITLE)
197 . make_nav_sectref("Up", "parent", $UP_TITLE)
198 . make_nav_sectref("Next", "next", $NEXT_TITLE)
Fred Drake0739c442003-09-04 22:16:45 +0000199 . "</div>\n"
Fred Drake4640e132000-07-31 20:13:23 +0000200 );
Fred Drake85d14c92000-07-31 17:53:45 +0000201 # remove these; they are unnecessary and cause errors from validation
202 $s =~ s/ NAME="tex2html\d+"\n */ /g;
203 return $s;
204}
205
Fred Drakefb6499f2001-10-26 14:16:23 +0000206sub add_child_links {
207 my $toc = add_real_child_links(@_);
208 $toc =~ s|\s*</[aA]>|</a>|g;
209 $toc =~ s/ NAME=\"tex2html\d+\"\s*href=/ href=/gi;
Fred Drake2fc88a62003-08-05 03:45:37 +0000210 $toc =~ s|</UL>(\s*<BR( /)?>)?|</ul>|gi;
Fred Drake0739c442003-09-04 22:16:45 +0000211 if ($toc =~ / NAME=["']CHILD_LINKS["']/) {
212 return "<div class='online-navigation'>\n$toc</div>\n";
213 }
Fred Drakefb6499f2001-10-26 14:16:23 +0000214 return $toc;
215}
216
Fred Drakef5478632002-05-23 17:59:16 +0000217sub get_version_text() {
Fred Drake7497bd32000-10-25 16:18:10 +0000218 if ($PACKAGE_VERSION ne '' && $t_date) {
219 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000220 . "Release $PACKAGE_VERSION$RELEASE_INFO,"
Fred Drake7497bd32000-10-25 16:18:10 +0000221 . " documentation updated on $t_date.</span>");
222 }
223 if ($PACKAGE_VERSION ne '') {
224 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000225 . "Release $PACKAGE_VERSION$RELEASE_INFO.</span>");
Fred Drake7497bd32000-10-25 16:18:10 +0000226 }
227 if ($t_date) {
228 return ("<span class=\"release-info\">Documentation released on "
229 . "$t_date.</span>");
230 }
231 return '';
232}
233
Fred Drake85d14c92000-07-31 17:53:45 +0000234
Fred Drakef5478632002-05-23 17:59:16 +0000235sub top_navigation_panel() {
Fred Drake859c46a2003-09-04 19:30:15 +0000236 return "\n<div id='top-navigation-panel'>\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000237 . make_nav_panel()
Fred Drake859c46a2003-09-04 19:30:15 +0000238 . "<br /><hr /></div>\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000239}
240
Fred Drakef5478632002-05-23 17:59:16 +0000241sub bot_navigation_panel() {
Fred Drake0739c442003-09-04 22:16:45 +0000242 return "\n<div class='online-navigation'>\n"
Fred Drake859c46a2003-09-04 19:30:15 +0000243 . "<p></p><hr />\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000244 . make_nav_panel()
Fred Drake859c46a2003-09-04 19:30:15 +0000245 . "</div>\n"
Fred Drake2fc88a62003-08-05 03:45:37 +0000246 . "<hr />\n"
Fred Drake7497bd32000-10-25 16:18:10 +0000247 . get_version_text()
248 . "\n";
Fred Drake64bdc241998-04-17 02:14:12 +0000249}
250
251sub add_link {
252 # Returns a pair (iconic link, textual link)
253 my($icon, $current_file, @link) = @_;
254 my($dummy, $file, $title) = split($delim,
Fred Drake7a556422003-09-04 22:21:17 +0000255 $section_info{join(' ',@link)});
Fred Draked18722b2001-01-02 22:08:48 +0000256 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
257 my $r = get_my_icon($1);
258 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
259 }
Fred Drake64bdc241998-04-17 02:14:12 +0000260 if ($title && ($file ne $current_file)) {
261 $title = purify($title);
Fred Drake7a556422003-09-04 22:21:17 +0000262 $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
263 return (make_href($file, $icon), make_href($file, "$title"))
264 }
Fred Draked18722b2001-01-02 22:08:48 +0000265 elsif ($icon eq get_my_icon('up') && $EXTERNAL_UP_LINK) {
Fred Drake7a556422003-09-04 22:21:17 +0000266 return (make_href($EXTERNAL_UP_LINK, $icon),
267 make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
268 }
Fred Draked18722b2001-01-02 22:08:48 +0000269 elsif ($icon eq get_my_icon('previous')
Fred Drake7a556422003-09-04 22:21:17 +0000270 && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
271 return (make_href($EXTERNAL_PREV_LINK, $icon),
272 make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
273 }
Fred Draked18722b2001-01-02 22:08:48 +0000274 elsif ($icon eq get_my_icon('next')
Fred Drake7a556422003-09-04 22:21:17 +0000275 && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
276 return (make_href($EXTERNAL_DOWN_LINK, $icon),
277 make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
278 }
Fred Drake85d14c92000-07-31 17:53:45 +0000279 return (&inactive_img($icon), "");
Fred Drake64bdc241998-04-17 02:14:12 +0000280}
281
Fred Drakef5478632002-05-23 17:59:16 +0000282sub add_special_link($$$) {
Fred Drake64bdc241998-04-17 02:14:12 +0000283 my($icon, $file, $current_file) = @_;
Fred Draked18722b2001-01-02 22:08:48 +0000284 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
285 my $r = get_my_icon($1);
286 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
287 }
Fred Drake85d14c92000-07-31 17:53:45 +0000288 return (($file && ($file ne $current_file))
289 ? make_href($file, $icon)
290 : undef)
Fred Drake64bdc241998-04-17 02:14:12 +0000291}
292
Fred Drake85d14c92000-07-31 17:53:45 +0000293# The img_tag() function seems only to be called with the parameter
294# 'anchor_invisible_mark', which we want to turn into ''. Since
295# replace_icon_marks() is the only interesting caller, and all it really
296# does is call img_tag(), we can just define the hook alternative to be
297# a no-op instead.
298#
299sub replace_icons_hook {}
Fred Drakebc7101d1998-03-06 21:18:55 +0000300
Fred Drake50cdd971999-02-19 23:04:59 +0000301sub do_cmd_arabic {
302 # get rid of that nasty <SPAN CLASS="arabic">...</SPAN>
Fred Drake73c5b6602002-10-24 16:36:05 +0000303 my($ctr, $val, $id, $text) = &read_counter_value($_[0]);
Fred Drake85d14c92000-07-31 17:53:45 +0000304 return ($val ? farabic($val) : "0") . $text;
Fred Drake50cdd971999-02-19 23:04:59 +0000305}
306
307
Fred Drakef5478632002-05-23 17:59:16 +0000308sub gen_index_id($$) {
Fred Drakebc7101d1998-03-06 21:18:55 +0000309 # this is used to ensure common index key generation and a stable sort
Fred Drakef5478632002-05-23 17:59:16 +0000310 my($str, $extra) = @_;
Fred Drake64bdc241998-04-17 02:14:12 +0000311 sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
Fred Drakebc7101d1998-03-06 21:18:55 +0000312}
313
Fred Drakef5478632002-05-23 17:59:16 +0000314sub insert_index($$$$$) {
315 my($mark, $datafile, $columns, $letters, $prefix) = @_;
Fred Drake4d10b431998-08-07 20:51:58 +0000316 my $prog = "$myrootdir/tools/buildindex.py";
317 my $index;
318 if ($letters) {
Fred Drake7a556422003-09-04 22:21:17 +0000319 $index = `$prog --columns $columns --letters $datafile`;
Fred Drake4d10b431998-08-07 20:51:58 +0000320 }
321 else {
Fred Drake7a556422003-09-04 22:21:17 +0000322 $index = `$prog --columns $columns $datafile`;
Fred Drake4d10b431998-08-07 20:51:58 +0000323 }
Fred Drakec5681732000-09-12 20:13:04 +0000324 if (!s/$mark/$prefix$index/) {
325 print "\nCould not locate index mark: $mark";
326 }
Fred Drake64bdc241998-04-17 02:14:12 +0000327}
328
Fred Drakef5478632002-05-23 17:59:16 +0000329sub add_idx() {
Fred Drake9bbdce51999-01-19 16:30:10 +0000330 print "\nBuilding HTML for the index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000331 close(IDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000332 insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
Fred Drake13210ed1998-03-17 06:28:05 +0000333}
Fred Drakebc7101d1998-03-06 21:18:55 +0000334
335
336$idx_module_mark = '<tex2html_idx_module_mark>';
337$idx_module_title = 'Module Index';
338
Fred Drakef5478632002-05-23 17:59:16 +0000339sub add_module_idx() {
Fred Drake9bbdce51999-01-19 16:30:10 +0000340 print "\nBuilding HTML for the module index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000341 my $key;
Fred Drake2383f6d1999-03-02 16:00:37 +0000342 my $first = 1;
343 my $prevplat = '';
344 my $allthesame = 1;
345 my $prefix = '';
346 foreach $key (keys %Modules) {
Fred Drake7a556422003-09-04 22:21:17 +0000347 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
348 my $plat = "$ModulePlatforms{$key}";
349 $plat = ''
350 if ($plat eq $IGNORE_PLATFORM_ANNOTATION);
351 if (!$first) {
352 $allthesame = 0
353 if ($prevplat ne $plat);
354 }
355 else { $first = 0; }
356 $prevplat = $plat;
Fred Drake2383f6d1999-03-02 16:00:37 +0000357 }
Fred Drake64bdc241998-04-17 02:14:12 +0000358 open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
Fred Drake235e6b11998-03-27 05:19:43 +0000359 foreach $key (keys %Modules) {
Fred Drake7a556422003-09-04 22:21:17 +0000360 # dump the line in the data file; just use a dummy seqno field
361 my $nkey = $1;
362 my $moditem = "$Modules{$key}";
363 my $plat = '';
364 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/;
365 if ($ModulePlatforms{$key} && !$allthesame) {
366 $plat = (" <em>(<span class=\"platform\">$ModulePlatforms{$key}"
367 . '</span>)</em>');
368 }
369 print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP
Fred Drakedce975c2001-06-20 21:31:36 +0000370 . "<tt class=\"module\">$key</tt>$plat###\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000371 }
Fred Drake235e6b11998-03-27 05:19:43 +0000372 close(MODIDXFILE);
Fred Drake42181db2001-01-09 22:02:10 +0000373
374 if ($GLOBAL_MODULE_INDEX) {
375 $prefix = <<MODULE_INDEX_PREFIX;
376
377<p> This index only lists modules documented in this manual.
378 The <em class="citetitle"><a href="$GLOBAL_MODULE_INDEX">Global Module
379 Index</a></em> lists all modules that are documented in this set
380 of manuals.</p>
381MODULE_INDEX_PREFIX
382 }
Fred Drake2383f6d1999-03-02 16:00:37 +0000383 if (!$allthesame) {
Fred Drake7a556422003-09-04 22:21:17 +0000384 $prefix .= <<PLAT_DISCUSS;
Fred Drake2383f6d1999-03-02 16:00:37 +0000385
386<p> Some module names are followed by an annotation indicating what
387platform they are available on.</p>
388
389PLAT_DISCUSS
390 }
391 insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
Fred Drake7a556422003-09-04 22:21:17 +0000392 $prefix);
Fred Drakebc7101d1998-03-06 21:18:55 +0000393}
394
Fred Drake235e6b11998-03-27 05:19:43 +0000395# replace both indexes as needed:
Fred Drake85d14c92000-07-31 17:53:45 +0000396sub add_idx_hook {
Fred Drakeb3a3ed81998-07-24 22:17:34 +0000397 add_idx() if (/$idx_mark/);
Fred Drake2383f6d1999-03-02 16:00:37 +0000398 process_python_state();
Fred Drakec5681732000-09-12 20:13:04 +0000399 if ($MODULE_INDEX_FILE) {
400 local ($_);
401 open(MYFILE, "<$MODULE_INDEX_FILE");
402 sysread(MYFILE, $_, 1024*1024);
403 close(MYFILE);
404 add_module_idx();
405 open(MYFILE,">$MODULE_INDEX_FILE");
406 print MYFILE $_;
407 close(MYFILE);
408 }
Fred Drake235e6b11998-03-27 05:19:43 +0000409}
Fred Drakebc7101d1998-03-06 21:18:55 +0000410
Fred Drakebc7101d1998-03-06 21:18:55 +0000411
Fred Drake191439a1999-09-22 19:50:51 +0000412# In addition to the standard stuff, add label to allow named node files and
413# support suppression of the page complete (for HTML Help use).
Fred Drake095f8172003-06-27 18:26:01 +0000414$MY_CONTENTS_PAGE = '';
Fred Drakebc7101d1998-03-06 21:18:55 +0000415sub do_cmd_tableofcontents {
416 local($_) = @_;
417 $TITLE = $toc_title;
418 $tocfile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000419 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000420 anchor_label('contents', $CURRENT_FILE, $_); # this is added
Fred Drake095f8172003-06-27 18:26:01 +0000421 $MY_CONTENTS_PAGE = "$CURRENT_FILE";
Fred Drake2fc88a62003-08-05 03:45:37 +0000422 join('', "<br />\n\\tableofchildlinks[off]", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000423 , make_section_heading($toc_title, 'h2'), $toc_mark
424 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000425}
426# In addition to the standard stuff, add label to allow named node files.
427sub do_cmd_listoffigures {
428 local($_) = @_;
429 $TITLE = $lof_title;
430 $loffile = $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('lof', $CURRENT_FILE, $_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000433 join('', "<br />\n", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000434 , make_section_heading($lof_title, 'h2'), $lof_mark
435 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000436}
437# In addition to the standard stuff, add label to allow named node files.
438sub do_cmd_listoftables {
439 local($_) = @_;
440 $TITLE = $lot_title;
441 $lotfile = $CURRENT_FILE;
Fred Drakef5478632002-05-23 17:59:16 +0000442 my($closures, $reopens) = preserve_open_tags();
Fred Drake7a556422003-09-04 22:21:17 +0000443 anchor_label('lot', $CURRENT_FILE, $_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000444 join('', "<br />\n", $closures
Fred Drake7a556422003-09-04 22:21:17 +0000445 , make_section_heading($lot_title, 'h2'), $lot_mark
446 , $reopens, $_);
Fred Drakebc7101d1998-03-06 21:18:55 +0000447}
448# In addition to the standard stuff, add label to allow named node files.
449sub do_cmd_textohtmlinfopage {
450 local($_) = @_;
Fred Drake7a556422003-09-04 22:21:17 +0000451 if ($INFO) { #
452 anchor_label("about",$CURRENT_FILE,$_); # this is added
453 } #
454 my $the_version = ''; # and the rest is
455 if ($t_date) { # mostly ours
456 $the_version = ",\n$t_date";
457 if ($PACKAGE_VERSION) {
458 $the_version .= ", Release $PACKAGE_VERSION$RELEASE_INFO";
459 }
Fred Drake15796f71998-11-30 19:25:47 +0000460 }
Fred Drake9443dc32001-08-10 20:12:09 +0000461 my $about;
462 open(ABOUT, "<$ABOUT_FILE") || die "\n$!\n";
463 sysread(ABOUT, $about, 1024*1024);
464 close(ABOUT);
Fred Drake15796f71998-11-30 19:25:47 +0000465 $_ = (($INFO == 1)
Fred Drakeb35f2b71999-09-23 16:53:09 +0000466 ? join('',
467 $close_all,
468 "<strong>$t_title</strong>$the_version\n",
Fred Drake9443dc32001-08-10 20:12:09 +0000469 $about,
Fred Drakeb35f2b71999-09-23 16:53:09 +0000470 $open_all, $_)
471 : join('', $close_all, $INFO,"\n", $open_all, $_));
Fred Drake15796f71998-11-30 19:25:47 +0000472 $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000473}
474
475# $idx_mark will be replaced with the real index at the end
476sub do_cmd_textohtmlindex {
477 local($_) = @_;
478 $TITLE = $idx_title;
479 $idxfile = $CURRENT_FILE;
Fred Drake235e6b11998-03-27 05:19:43 +0000480 if (%index_labels) { make_index_labels(); }
481 if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); }
Fred Drakebc7101d1998-03-06 21:18:55 +0000482 else { $preindex = ''; }
Fred Drake235e6b11998-03-27 05:19:43 +0000483 my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
Fred Drakef5478632002-05-23 17:59:16 +0000484 my($pre, $post) = minimize_open_tags($heading);
Fred Drake7a556422003-09-04 22:21:17 +0000485 anchor_label('genindex',$CURRENT_FILE,$_); # this is added
Fred Drake2fc88a62003-08-05 03:45:37 +0000486 return "<br />\n" . $pre . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000487}
488
Fred Drakec5681732000-09-12 20:13:04 +0000489$MODULE_INDEX_FILE = '';
490
Fred Drakebc7101d1998-03-06 21:18:55 +0000491# $idx_module_mark will be replaced with the real index at the end
492sub do_cmd_textohtmlmoduleindex {
493 local($_) = @_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000494 $TITLE = $idx_module_title;
Fred Drakec5681732000-09-12 20:13:04 +0000495 anchor_label('modindex', $CURRENT_FILE, $_);
496 $MODULE_INDEX_FILE = "$CURRENT_FILE";
Fred Drake2fc88a62003-08-05 03:45:37 +0000497 $_ = ('<p></p>' . make_section_heading($idx_module_title, 'h2')
Fred Drakec5681732000-09-12 20:13:04 +0000498 . $idx_module_mark . $_);
499 return $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000500}
501
Fred Drakec5681732000-09-12 20:13:04 +0000502# The bibliography and the index should be treated as separate
503# sections in their own HTML files. The \bibliography{} command acts
504# as a sectioning command that has the desired effect. But when the
505# bibliography is constructed manually using the thebibliography
506# environment, or when using the theindex environment it is not
507# possible to use the normal sectioning mechanism. This subroutine
508# inserts a \bibliography{} or a dummy \textohtmlindex command just
509# before the appropriate environments to force sectioning.
Fred Drakebc7101d1998-03-06 21:18:55 +0000510
Fred Drake7a556422003-09-04 22:21:17 +0000511# XXX This *assumes* that if there are two {theindex} environments,
512# the first is the module index and the second is the standard
513# index. This is sufficient for the current Python documentation,
514# but that's about it.
Fred Drakebc7101d1998-03-06 21:18:55 +0000515
516sub add_bbl_and_idx_dummy_commands {
Fred Drake11916921998-04-02 22:30:57 +0000517 my $id = $global{'max_id'};
Fred Drakebc7101d1998-03-06 21:18:55 +0000518
Fred Drakea219b412001-10-22 16:57:49 +0000519 if (/[\\]tableofcontents/) {
520 $HAVE_TABLE_OF_CONTENTS = 1;
521 }
Fred Drakebc7101d1998-03-06 21:18:55 +0000522 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
Fred Drake191439a1999-09-22 19:50:51 +0000523 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 +0000524 my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/);
525 if (scalar(@parts) == 3) {
526 # Be careful to re-write the string in place, since $_ is *not*
527 # returned explicity; *** nasty side-effect dependency! ***
Fred Drakebb7775a2001-12-04 17:03:54 +0000528 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
Fred Drake85d14c92000-07-31 17:53:45 +0000529 print "\nadd_bbl_and_idx_dummy_commands ==> adding module index";
530 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)"
531 . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
Fred Drake73c5b6602002-10-24 16:36:05 +0000532 s/$rx/\\textohtmlmoduleindex $1 \\textohtmlindex $2/o;
Fred Drake85d14c92000-07-31 17:53:45 +0000533 # Add a button to the navigation areas:
Fred Drakeaaa23852000-09-14 22:20:41 +0000534 $CUSTOM_BUTTONS .= ('<a href="modindex.html" title="Module Index">'
Fred Draked18722b2001-01-02 22:08:48 +0000535 . get_my_icon('modules')
Fred Drakeaaa23852000-09-14 22:20:41 +0000536 . '</a>');
Fred Drakea219b412001-10-22 16:57:49 +0000537 $HAVE_MODULE_INDEX = 1;
538 $HAVE_GENERAL_INDEX = 1;
539 }
540 elsif (scalar(@parts) == 2) {
Fred Drakebb7775a2001-12-04 17:03:54 +0000541 print "\nadd_bbl_and_idx_dummy_commands ==> adding general index";
542 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
Fred Drake73c5b6602002-10-24 16:36:05 +0000543 s/$rx/\\textohtmlindex $1/o;
Fred Drakea219b412001-10-22 16:57:49 +0000544 $HAVE_GENERAL_INDEX = 1;
Fred Drake11916921998-04-02 22:30:57 +0000545 }
Fred Drakebb7775a2001-12-04 17:03:54 +0000546 elsif (scalar(@parts) == 1) {
547 print "\nadd_bbl_and_idx_dummy_commands ==> no index found";
Fred Draked18722b2001-01-02 22:08:48 +0000548 $CUSTOM_BUTTONS .= get_my_icon('blank');
Fred Drake85d14c92000-07-31 17:53:45 +0000549 $global{'max_id'} = $id; # not sure why....
550 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
Fred Drake7a556422003-09-04 22:21:17 +0000551 s/[\\]printindex/\\textohtmlindex /o;
Fred Drakebb7775a2001-12-04 17:03:54 +0000552 }
553 else {
554 die "\n\nBad number of index environments!\n\n";
555 }
Fred Drake11916921998-04-02 22:30:57 +0000556 #----------------------------------------------------------------------
Fred Drake64bdc241998-04-17 02:14:12 +0000557 lib_add_bbl_and_idx_dummy_commands()
Fred Drake11916921998-04-02 22:30:57 +0000558 if defined(&lib_add_bbl_and_idx_dummy_commands);
Fred Drakebc7101d1998-03-06 21:18:55 +0000559}
560
Fred Drakec5681732000-09-12 20:13:04 +0000561# The bibliographic references, the appendices, the lists of figures
562# and tables etc. must appear in the contents table at the same level
563# as the outermost sectioning command. This subroutine finds what is
564# the outermost level and sets the above to the same level;
Fred Drakebc7101d1998-03-06 21:18:55 +0000565
Fred Drake13210ed1998-03-17 06:28:05 +0000566sub set_depth_levels {
567 # Sets $outermost_level
Fred Drake11916921998-04-02 22:30:57 +0000568 my $level;
Fred Drake13210ed1998-03-17 06:28:05 +0000569 #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
570 foreach $level ("part", "chapter", "section", "subsection",
Fred Drake7a556422003-09-04 22:21:17 +0000571 "subsubsection", "paragraph") {
572 last if (($outermost_level) = /\\($level)$delimiter_rx/);
Fred Drake13210ed1998-03-17 06:28:05 +0000573 }
574 $level = ($outermost_level ? $section_commands{$outermost_level} :
Fred Drake7a556422003-09-04 22:21:17 +0000575 do {$outermost_level = 'section'; 3;});
Fred Drakebc7101d1998-03-06 21:18:55 +0000576
Fred Drake13210ed1998-03-17 06:28:05 +0000577 #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
Fred Drake7a556422003-09-04 22:21:17 +0000578 if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
579 $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
Fred Drake13210ed1998-03-17 06:28:05 +0000580 } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
Fred Drakebc7101d1998-03-06 21:18:55 +0000581
Fred Drake64bdc241998-04-17 02:14:12 +0000582 %unnumbered_section_commands = ('tableofcontents' => $level,
Fred Drake7a556422003-09-04 22:21:17 +0000583 'listoffigures' => $level,
584 'listoftables' => $level,
585 'bibliography' => $level,
586 'textohtmlindex' => $level,
587 'textohtmlmoduleindex' => $level);
Fred Drake64bdc241998-04-17 02:14:12 +0000588 $section_headings{'textohtmlmoduleindex'} = 'h1';
Fred Drakebc7101d1998-03-06 21:18:55 +0000589
Fred Drake64bdc241998-04-17 02:14:12 +0000590 %section_commands = (%unnumbered_section_commands,
Fred Drake7a556422003-09-04 22:21:17 +0000591 %section_commands);
Fred Drake11916921998-04-02 22:30:57 +0000592
593 make_sections_rx();
Fred Drake13210ed1998-03-17 06:28:05 +0000594}
Fred Drakebc7101d1998-03-06 21:18:55 +0000595
596
Fred Drake1072e461998-04-12 02:16:34 +0000597# This changes the markup used for {verbatim} environments, and is the
Fred Drake95474f91999-02-09 18:45:50 +0000598# best way I've found that ensures the <dl> goes on the outside of the
Fred Drake1072e461998-04-12 02:16:34 +0000599# <pre>...</pre>.
600#
601# Note that this *must* be done in the init file, not the python.perl
Fred Drakec5681732000-09-12 20:13:04 +0000602# style support file. The %declarations must be set before
603# initialize() is called in the main LaTeX2HTML script (which happens
604# before style files are loaded).
Fred Drake1072e461998-04-12 02:16:34 +0000605#
Fred Drake8a5e6792002-04-15 18:41:31 +0000606%declarations = ('preform' => '<div class="verbatim"><pre></pre></div>',
Fred Drake7a556422003-09-04 22:21:17 +0000607 %declarations);
Fred Drake1072e461998-04-12 02:16:34 +0000608
Fred Drakee15956b2000-04-03 04:51:13 +0000609
Fred Drakebf8ec3e2003-05-02 20:18:01 +0000610# This is used to map the link rel attributes LaTeX2HTML uses to those
611# currently recommended by the W3C.
612sub custom_REL_hook {
613 my($rel,$junk) = @_;
614 return 'parent' if $rel eq 'up';
615 return 'prev' if $rel eq 'previous';
616 return $rel;
617}
618
Fred Drakec5681732000-09-12 20:13:04 +0000619# This is added to get rid of the long comment that follows the
620# doctype declaration; MSIE5 on NT4 SP4 barfs on it and drops the
621# content of the page.
Fred Drakea219b412001-10-22 16:57:49 +0000622$MY_PARTIAL_HEADER = '';
Fred Drakef5478632002-05-23 17:59:16 +0000623sub make_head_and_body($$) {
Fred Drake85d14c92000-07-31 17:53:45 +0000624 my($title, $body) = @_;
Fred Drake16816272000-09-16 20:40:44 +0000625 $body = " $body" unless ($body eq '');
Fred Drake85d14c92000-07-31 17:53:45 +0000626 my $DTDcomment = '';
627 my($version, $isolanguage) = ($HTML_VERSION, 'EN');
628 my %isolanguages = ( 'english', 'EN' , 'USenglish', 'EN.US'
629 , 'original', 'EN' , 'german' , 'DE'
630 , 'austrian', 'DE.AT', 'french' , 'FR'
631 , 'spanish', 'ES');
Fred Drakee15956b2000-04-03 04:51:13 +0000632 $isolanguage = $isolanguages{$default_language};
633 $isolanguage = 'EN' unless $isolanguage;
634 $title = &purify($title,1);
635 eval("\$title = ". $default_title ) unless ($title);
636
Fred Drake2fc88a62003-08-05 03:45:37 +0000637 # allow user-modification of the <title> tag; thanks Dan Young
Fred Drakee15956b2000-04-03 04:51:13 +0000638 if (defined &custom_TITLE_hook) {
Fred Drake7a556422003-09-04 22:21:17 +0000639 $title = &custom_TITLE_hook($title, $toc_sec_title);
Fred Drakee15956b2000-04-03 04:51:13 +0000640 }
641
642 if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included
Fred Drake7a556422003-09-04 22:21:17 +0000643 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000644 } else {
Fred Drake7a556422003-09-04 22:21:17 +0000645 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//"
646 . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n";
Fred Drakee15956b2000-04-03 04:51:13 +0000647 }
Fred Drakea219b412001-10-22 16:57:49 +0000648 if ($MY_PARTIAL_HEADER eq '') {
649 $STYLESHEET = $FILE.".css" unless $STYLESHEET;
650 $MY_PARTIAL_HEADER = join('',
Fred Drakedd3d6a02002-10-30 17:00:58 +0000651 ($DOCTYPE ? $DTDcomment : ''),
Fred Drake98b25762003-05-02 18:21:22 +0000652 "<html>\n<head>",
Fred Drake2fc88a62003-08-05 03:45:37 +0000653 ($BASE ? "\n<base href=\"$BASE\" />" : ''),
654 "\n<link rel=\"STYLESHEET\" href=\"$STYLESHEET\" type='text/css'",
655 " />",
Fred Drakedd3d6a02002-10-30 17:00:58 +0000656 ($FAVORITES_ICON
Fred Drake2fc88a62003-08-05 03:45:37 +0000657 ? ("\n<link rel=\"SHORTCUT ICON\" href=\"$FAVORITES_ICON\" />")
Fred Drakedd3d6a02002-10-30 17:00:58 +0000658 : ''),
Fred Drake23949002002-10-30 21:51:18 +0000659 ($EXTERNAL_UP_LINK
Fred Drake98b25762003-05-02 18:21:22 +0000660 ? ("\n<link rel='start' href='" . $EXTERNAL_UP_LINK
661 . ($EXTERNAL_UP_TITLE ?
Fred Drake2fc88a62003-08-05 03:45:37 +0000662 "' title='$EXTERNAL_UP_TITLE' />" : "' />"))
Fred Drake23949002002-10-30 21:51:18 +0000663 : ''),
Fred Drake98b25762003-05-02 18:21:22 +0000664 "\n<link rel=\"first\" href=\"$FILE.html\"",
Fred Drake23949002002-10-30 21:51:18 +0000665 ($t_title ? " title='$t_title'" : ''),
Fred Drake2fc88a62003-08-05 03:45:37 +0000666 ' />',
Fred Drakea219b412001-10-22 16:57:49 +0000667 ($HAVE_TABLE_OF_CONTENTS
Fred Drake095f8172003-06-27 18:26:01 +0000668 ? ("\n<link rel='contents' href='$MY_CONTENTS_PAGE'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000669 . ' title="Contents" />')
Fred Drakea219b412001-10-22 16:57:49 +0000670 : ''),
671 ($HAVE_GENERAL_INDEX
Fred Drake2fc88a62003-08-05 03:45:37 +0000672 ? "\n<link rel='index' href='genindex.html' title='Index' />"
Fred Drakea219b412001-10-22 16:57:49 +0000673 : ''),
674 # disable for now -- Mozilla doesn't do well with multiple indexes
675 # ($HAVE_MODULE_INDEX
Fred Drake2fc88a62003-08-05 03:45:37 +0000676 # ? '<link rel="index" href="modindex.html" title="Module Index"'
677 # . " />\n"
Fred Drakea219b412001-10-22 16:57:49 +0000678 # : ''),
Fred Drake23949002002-10-30 21:51:18 +0000679 ($INFO
680 # XXX We can do this with the Python tools since the About...
681 # page always gets copied to about.html, even when we use the
682 # generated node###.html page names. Won't work with the
683 # rest of the Python doc tools.
Fred Drake98b25762003-05-02 18:21:22 +0000684 ? ("\n<link rel='last' href='about.html'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000685 . " title='About this document...' />"
Fred Drake98b25762003-05-02 18:21:22 +0000686 . "\n<link rel='help' href='about.html'"
Fred Drake2fc88a62003-08-05 03:45:37 +0000687 . " title='About this document...' />")
Fred Drake23949002002-10-30 21:51:18 +0000688 : ''),
Fred Drakedd3d6a02002-10-30 17:00:58 +0000689 $more_links_mark,
Fred Drake0e2e6872002-10-30 19:55:23 +0000690 "\n",
Fred Drakedd3d6a02002-10-30 17:00:58 +0000691 ($CHARSET && $HTML_VERSION ge "2.1"
692 ? ('<meta http-equiv="Content-Type" content="text/html; '
Fred Drake2fc88a62003-08-05 03:45:37 +0000693 . "charset=$CHARSET\" />\n")
Fred Drakedd3d6a02002-10-30 17:00:58 +0000694 : ''),
695 ($AESOP_META_TYPE
Fred Drake2fc88a62003-08-05 03:45:37 +0000696 ? "<meta name='aesop' content='$AESOP_META_TYPE' />\n" : ''));
Fred Drakea219b412001-10-22 16:57:49 +0000697 }
Fred Drake0e2e6872002-10-30 19:55:23 +0000698 if (!$charset && $CHARSET) {
699 $charset = $CHARSET;
700 $charset =~ s/_/\-/go;
701 }
Fred Drakef06b9052003-05-02 18:08:16 +0000702 # Remove section number from the title for use in the
703 # <meta name='description' ...> element in the document head.
704 my $metatitle = "$title";
705 $metatitle =~ s/^\d+(\.\d+)*\s*//;
Fred Drake2fc88a62003-08-05 03:45:37 +0000706 $metatitle = meta_information($metatitle);
707 $metatitle =~ s/ NAME=/ name=/g;
708 $metatitle =~ s/ CONTENT=/ content=/g;
Fred Drakef06b9052003-05-02 18:08:16 +0000709
Fred Drakedd3d6a02002-10-30 17:00:58 +0000710 join('',
711 $MY_PARTIAL_HEADER,
Fred Drake2fc88a62003-08-05 03:45:37 +0000712 $metatitle,
Fred Drakedd3d6a02002-10-30 17:00:58 +0000713 "<title>", $title, "</title>\n</head>\n<body$body>");
Fred Drakee15956b2000-04-03 04:51:13 +0000714}
715
Fred Drake2fc88a62003-08-05 03:45:37 +0000716sub replace_morelinks {
717 $more_links =~ s/ REL=/ rel=/g;
718 $more_links =~ s/ HREF=/ href=/g;
719 $_ =~ s/$more_links_mark/$more_links/e;
720}
721
Fred Drake7a556422003-09-04 22:21:17 +00007221; # This must be the last line