blob: 35c1d8bf7f8af4e0a008811779dd4001a6b4846a [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
20$ICONSERVER = '../icons';
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 Drakebc7101d1998-03-06 21:18:55 +000029$CHILDLINE = "\n<p><hr>\n";
30$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 Drakec9f2c141998-03-11 12:08:21 +000040
Fred Drakedb34a1e1998-03-10 23:02:57 +000041# A little painful, but lets us clean up the top level directory a little,
Fred Drake85d14c92000-07-31 17:53:45 +000042# and not be tied to the current directory (as far as I can tell). Testing
43# an existing definition of $mydir is needed since it cannot be computed when
44# run under mkhowto with recent versions of LaTeX2HTML, since this file is
45# not read directly by LaTeX2HTML any more. mkhowto is required to prepend
46# the required definition at the top of the actual input file.
Fred Drakedb34a1e1998-03-10 23:02:57 +000047#
Fred Drake85d14c92000-07-31 17:53:45 +000048if (!defined $mydir) {
49 use Cwd;
50 use File::Basename;
51 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
52 chop $mydir; # remove trailing '/'
53 $mydir = getcwd() . "$dd$mydir"
54 unless $mydir =~ s|^/|/|;
55}
Fred Drakedb34a1e1998-03-10 23:02:57 +000056$LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES";
Fred Drakeb3a3ed81998-07-24 22:17:34 +000057push (@INC, $mydir);
Fred Drakebc7101d1998-03-06 21:18:55 +000058
Fred Drake235e6b11998-03-27 05:19:43 +000059($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*');
60chop $myrootdir;
61
Fred Drakebc7101d1998-03-06 21:18:55 +000062
Fred Drakea4565b01998-05-15 17:14:17 +000063# Hackish way to get the appropriate paper-*/ directory into $TEXINPUTS;
64# pass in the paper size (a4 or letter) as the environment variable PAPER
65# to add the right directory. If not given, the current directory is
66# added instead for use with HOWTO processing.
67#
68if (defined $ENV{'PAPER'}) {
69 $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey";
70}
71else {
72 $mytexinputs = getcwd() . $envkey;
73}
74$mytexinputs .= "$myrootdir${dd}texinputs";
75
76
Fred Drakeb35f2b71999-09-23 16:53:09 +000077# Change this variable to change the text added in "About this document...";
78# this should be an absolute pathname to get it right.
79#
80$ABOUT_FILE = "$myrootdir${dd}html${dd}stdabout.dat";
81
82
Fred Drake85d14c92000-07-31 17:53:45 +000083sub custom_driver_hook {
Fred Drakea4565b01998-05-15 17:14:17 +000084 #
85 # This adds the directory of the main input file to $TEXINPUTS; it
86 # seems to be sufficiently general that it should be fine for HOWTO
87 # processing.
88 #
89 my $file = @_[0];
Fred Drake85d14c92000-07-31 17:53:45 +000090 my($jobname, $dir, $ext) = fileparse($file, '\..*');
91 $dir = L2hos->Make_directory_absolute($dir);
Fred Drakea4565b01998-05-15 17:14:17 +000092 $dir =~ s/$dd$//;
93 $TEXINPUTS = "$dir$envkey$mytexinputs";
Fred Drake85d14c92000-07-31 17:53:45 +000094 print "\nAdding $dir to \$TEXINPUTS\n";
Fred Drake191439a1999-09-22 19:50:51 +000095}
96
Fred Drakea4565b01998-05-15 17:14:17 +000097
Fred Drake85d14c92000-07-31 17:53:45 +000098$CUSTOM_BUTTONS = '';
Fred Drake062bc6e1998-08-13 22:03:46 +000099
Fred Drake85d14c92000-07-31 17:53:45 +0000100sub make_nav_sectref {
Fred Drakebeb27bf1999-02-16 17:22:32 +0000101 my($label,$title) = @_;
102 if ($title) {
Fred Drake02c70822000-09-19 15:36:19 +0000103 if ($title =~ /\<[aA] /) {
104 $title =~ s/\<[aA] /<a class="sectref" /;
105 }
106 else {
107 $title = "<span class=\"sectref\">$title</span>";
108 }
109 return "<b class=\"navlabel\">$label:</b> $title\n";
Fred Drakebeb27bf1999-02-16 17:22:32 +0000110 }
111 return '';
112}
113
Fred Draked18722b2001-01-02 22:08:48 +0000114@my_icon_tags = ();
115$my_icon_tags{'next'} = 'Next Page';
116$my_icon_tags{'next_page'} = 'Next Page';
117$my_icon_tags{'previous'} = 'Previous Page';
118$my_icon_tags{'previous_page'} = 'Previous Page';
119$my_icon_tags{'up'} = 'Up One Level';
120$my_icon_tags{'contents'} = 'Contents';
121$my_icon_tags{'index'} = 'Index';
122$my_icon_tags{'modules'} = 'Module Index';
123
Fred Drakeb31d36c2001-01-04 15:16:01 +0000124@my_icon_names = ();
125$my_icon_names{'previous_page'} = 'previous';
126$my_icon_names{'next_page'} = 'next';
127
Fred Draked18722b2001-01-02 22:08:48 +0000128sub get_my_icon {
129 my $name = @_[0];
130 my $text = $my_icon_tags{$name};
Fred Drakeb31d36c2001-01-04 15:16:01 +0000131 if ($my_icon_names{$name}) {
132 $name = $my_icon_names{$name};
133 }
Fred Draked18722b2001-01-02 22:08:48 +0000134 if ($text eq '') {
135 $name = 'blank';
136 }
Fred Drake85d14c92000-07-31 17:53:45 +0000137 my $iconserver = ($ICONSERVER eq '.') ? '' : "$ICONSERVER/";
Fred Draked18722b2001-01-02 22:08:48 +0000138 return "<img src=\"$iconserver$name.$IMAGE_TYPE\"\n border=\"0\""
Fred Drake85d14c92000-07-31 17:53:45 +0000139 . " height=\"32\"\n alt=\"$text\" width=\"32\">";
140}
141
Fred Drake85d14c92000-07-31 17:53:45 +0000142sub use_my_icon {
143 my $s = @_[0];
Fred Draked18722b2001-01-02 22:08:48 +0000144 if ($s =~ /\<tex2html_([a-z_]+)_visible_mark\>/) {
145 my $r = get_my_icon($1);
146 $s =~ s/\<tex2html_[a-z_]+_visible_mark\>/$r/;
147 }
Fred Drakea0075441999-04-29 19:06:56 +0000148 return $s;
Fred Drake13210ed1998-03-17 06:28:05 +0000149}
150
Fred Drake85d14c92000-07-31 17:53:45 +0000151sub make_nav_panel {
152 my $s;
Fred Draked18722b2001-01-02 22:08:48 +0000153 my $BLANK_ICON = get_my_icon('blank');
Fred Drakef730fc32000-08-31 07:19:07 +0000154 $NEXT = $NEXT_TITLE ? use_my_icon("$NEXT") : $BLANK_ICON;
155 $UP = $UP_TITLE ? use_my_icon("$UP") : $BLANK_ICON;
156 $PREVIOUS = $PREVIOUS_TITLE ? use_my_icon("$PREVIOUS") : $BLANK_ICON;
Fred Drake85d14c92000-07-31 17:53:45 +0000157 $CONTENTS = use_my_icon("$CONTENTS");
158 $INDEX = $INDEX ? use_my_icon("$INDEX") : $BLANK_ICON;
159 if (!$CUSTOM_BUTTONS) {
160 $CUSTOM_BUTTONS = $BLANK_ICON;
161 }
162 $s = ('<table align="center" width="100%" cellpadding="0" cellspacing="2">'
163 . "\n<tr>"
164 # left-hand side
Fred Drake85d14c92000-07-31 17:53:45 +0000165 . "\n<td>$PREVIOUS</td>"
Fred Drake4640e132000-07-31 20:13:23 +0000166 . "\n<td>$UP</td>"
167 . "\n<td>$NEXT</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000168 # title box
Fred Drakef730fc32000-08-31 07:19:07 +0000169 . "\n<td align=\"center\" width=\"100%\">$t_title</td>"
Fred Drake85d14c92000-07-31 17:53:45 +0000170 # right-hand side
171 . "\n<td>$CONTENTS</td>"
172 . "\n<td>$CUSTOM_BUTTONS</td>" # module index
173 . "\n<td>$INDEX</td>"
174 . "\n</tr></table>\n"
175 # textual navigation
Fred Drake4640e132000-07-31 20:13:23 +0000176 . make_nav_sectref("Previous", $PREVIOUS_TITLE)
Fred Drake85d14c92000-07-31 17:53:45 +0000177 . make_nav_sectref("Up", $UP_TITLE)
Fred Drake4640e132000-07-31 20:13:23 +0000178 . make_nav_sectref("Next", $NEXT_TITLE)
179 );
Fred Drake85d14c92000-07-31 17:53:45 +0000180 # remove these; they are unnecessary and cause errors from validation
181 $s =~ s/ NAME="tex2html\d+"\n */ /g;
182 return $s;
183}
184
Fred Drake7497bd32000-10-25 16:18:10 +0000185sub get_version_text {
186 if ($PACKAGE_VERSION ne '' && $t_date) {
187 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000188 . "Release $PACKAGE_VERSION$RELEASE_INFO,"
Fred Drake7497bd32000-10-25 16:18:10 +0000189 . " documentation updated on $t_date.</span>");
190 }
191 if ($PACKAGE_VERSION ne '') {
192 return ("<span class=\"release-info\">"
Fred Drakedce975c2001-06-20 21:31:36 +0000193 . "Release $PACKAGE_VERSION$RELEASE_INFO.</span>");
Fred Drake7497bd32000-10-25 16:18:10 +0000194 }
195 if ($t_date) {
196 return ("<span class=\"release-info\">Documentation released on "
197 . "$t_date.</span>");
198 }
199 return '';
200}
201
Fred Drake85d14c92000-07-31 17:53:45 +0000202
Fred Drakebc7101d1998-03-06 21:18:55 +0000203sub top_navigation_panel {
Fred Drake7497bd32000-10-25 16:18:10 +0000204 return "\n"
205 . make_nav_panel()
206 . "<br><hr>\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000207}
208
209sub bot_navigation_panel {
Fred Drake7497bd32000-10-25 16:18:10 +0000210 return "\n<p><hr>\n"
211 . make_nav_panel()
212 . "<hr>\n"
213 . get_version_text()
214 . "\n";
Fred Drake64bdc241998-04-17 02:14:12 +0000215}
216
217sub add_link {
218 # Returns a pair (iconic link, textual link)
219 my($icon, $current_file, @link) = @_;
220 my($dummy, $file, $title) = split($delim,
Fred Drake28e7b4c1998-10-20 18:14:20 +0000221 $section_info{join(' ',@link)});
Fred Draked18722b2001-01-02 22:08:48 +0000222 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
223 my $r = get_my_icon($1);
224 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
225 }
Fred Drake64bdc241998-04-17 02:14:12 +0000226 if ($title && ($file ne $current_file)) {
227 $title = purify($title);
228 $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
229 return (make_href($file, $icon), make_href($file, "$title"))
230 }
Fred Draked18722b2001-01-02 22:08:48 +0000231 elsif ($icon eq get_my_icon('up') && $EXTERNAL_UP_LINK) {
Fred Drake64bdc241998-04-17 02:14:12 +0000232 return (make_href($EXTERNAL_UP_LINK, $icon),
233 make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
234 }
Fred Draked18722b2001-01-02 22:08:48 +0000235 elsif ($icon eq get_my_icon('previous')
Fred Drake64bdc241998-04-17 02:14:12 +0000236 && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
237 return (make_href($EXTERNAL_PREV_LINK, $icon),
238 make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
239 }
Fred Draked18722b2001-01-02 22:08:48 +0000240 elsif ($icon eq get_my_icon('next')
Fred Drake64bdc241998-04-17 02:14:12 +0000241 && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
242 return (make_href($EXTERNAL_DOWN_LINK, $icon),
243 make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
244 }
Fred Drake85d14c92000-07-31 17:53:45 +0000245 return (&inactive_img($icon), "");
Fred Drake64bdc241998-04-17 02:14:12 +0000246}
247
248sub add_special_link {
249 my($icon, $file, $current_file) = @_;
Fred Draked18722b2001-01-02 22:08:48 +0000250 if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) {
251 my $r = get_my_icon($1);
252 $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/;
253 }
Fred Drake85d14c92000-07-31 17:53:45 +0000254 return (($file && ($file ne $current_file))
255 ? make_href($file, $icon)
256 : undef)
Fred Drake64bdc241998-04-17 02:14:12 +0000257}
258
Fred Drake85d14c92000-07-31 17:53:45 +0000259# The img_tag() function seems only to be called with the parameter
260# 'anchor_invisible_mark', which we want to turn into ''. Since
261# replace_icon_marks() is the only interesting caller, and all it really
262# does is call img_tag(), we can just define the hook alternative to be
263# a no-op instead.
264#
265sub replace_icons_hook {}
Fred Drakebc7101d1998-03-06 21:18:55 +0000266
Fred Drake50cdd971999-02-19 23:04:59 +0000267sub do_cmd_arabic {
268 # get rid of that nasty <SPAN CLASS="arabic">...</SPAN>
Fred Drake85d14c92000-07-31 17:53:45 +0000269 my($ctr, $val, $id, $text) = &read_counter_value(@_[0]);
270 return ($val ? farabic($val) : "0") . $text;
Fred Drake50cdd971999-02-19 23:04:59 +0000271}
272
273
Fred Drakebc7101d1998-03-06 21:18:55 +0000274sub gen_index_id {
275 # this is used to ensure common index key generation and a stable sort
Fred Drake235e6b11998-03-27 05:19:43 +0000276 my($str,$extra) = @_;
Fred Drake64bdc241998-04-17 02:14:12 +0000277 sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
Fred Drakebc7101d1998-03-06 21:18:55 +0000278}
279
Fred Drake85d14c92000-07-31 17:53:45 +0000280sub insert_index {
Fred Drake2383f6d1999-03-02 16:00:37 +0000281 my($mark,$datafile,$columns,$letters,$prefix) = @_;
Fred Drake4d10b431998-08-07 20:51:58 +0000282 my $prog = "$myrootdir/tools/buildindex.py";
283 my $index;
284 if ($letters) {
285 $index = `$prog --columns $columns --letters $datafile`;
286 }
287 else {
288 $index = `$prog --columns $columns $datafile`;
289 }
Fred Drakec5681732000-09-12 20:13:04 +0000290 if (!s/$mark/$prefix$index/) {
291 print "\nCould not locate index mark: $mark";
292 }
Fred Drake64bdc241998-04-17 02:14:12 +0000293}
294
Fred Drake85d14c92000-07-31 17:53:45 +0000295sub add_idx {
Fred Drake9bbdce51999-01-19 16:30:10 +0000296 print "\nBuilding HTML for the index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000297 close(IDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000298 insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
Fred Drake13210ed1998-03-17 06:28:05 +0000299}
Fred Drakebc7101d1998-03-06 21:18:55 +0000300
301
302$idx_module_mark = '<tex2html_idx_module_mark>';
303$idx_module_title = 'Module Index';
304
Fred Drake85d14c92000-07-31 17:53:45 +0000305sub add_module_idx {
Fred Drake9bbdce51999-01-19 16:30:10 +0000306 print "\nBuilding HTML for the module index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000307 my $key;
Fred Drake2383f6d1999-03-02 16:00:37 +0000308 my $first = 1;
309 my $prevplat = '';
310 my $allthesame = 1;
311 my $prefix = '';
312 foreach $key (keys %Modules) {
313 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
314 my $plat = "$ModulePlatforms{$key}";
315 $plat = ''
Fred Drake62cc3601999-03-04 18:41:17 +0000316 if ($plat eq $IGNORE_PLATFORM_ANNOTATION);
Fred Drake2383f6d1999-03-02 16:00:37 +0000317 if (!$first) {
318 $allthesame = 0
319 if ($prevplat ne $plat);
320 }
321 else { $first = 0; }
322 $prevplat = $plat;
323 }
Fred Drake64bdc241998-04-17 02:14:12 +0000324 open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
Fred Drake235e6b11998-03-27 05:19:43 +0000325 foreach $key (keys %Modules) {
326 # dump the line in the data file; just use a dummy seqno field
Fred Drake2383f6d1999-03-02 16:00:37 +0000327 my $nkey = $1;
328 my $moditem = "$Modules{$key}";
329 my $plat = '';
330 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
331 if ($ModulePlatforms{$key} && !$allthesame) {
Fred Drakedce975c2001-06-20 21:31:36 +0000332 $plat = (" <em>(<span class=\"platform\">$ModulePlatforms{$key}"
Fred Drakebb584d31999-03-25 22:18:30 +0000333 . '</span>)</em>');
Fred Drake2383f6d1999-03-02 16:00:37 +0000334 }
Fred Drakee15956b2000-04-03 04:51:13 +0000335 print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP
Fred Drakedce975c2001-06-20 21:31:36 +0000336 . "<tt class=\"module\">$key</tt>$plat###\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000337 }
Fred Drake235e6b11998-03-27 05:19:43 +0000338 close(MODIDXFILE);
Fred Drake42181db2001-01-09 22:02:10 +0000339
340 if ($GLOBAL_MODULE_INDEX) {
341 $prefix = <<MODULE_INDEX_PREFIX;
342
343<p> This index only lists modules documented in this manual.
344 The <em class="citetitle"><a href="$GLOBAL_MODULE_INDEX">Global Module
345 Index</a></em> lists all modules that are documented in this set
346 of manuals.</p>
347MODULE_INDEX_PREFIX
348 }
Fred Drake2383f6d1999-03-02 16:00:37 +0000349 if (!$allthesame) {
Fred Draked18722b2001-01-02 22:08:48 +0000350 $prefix .= <<PLAT_DISCUSS;
Fred Drake2383f6d1999-03-02 16:00:37 +0000351
352<p> Some module names are followed by an annotation indicating what
353platform they are available on.</p>
354
355PLAT_DISCUSS
356 }
357 insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
358 $prefix);
Fred Drakebc7101d1998-03-06 21:18:55 +0000359}
360
Fred Drake235e6b11998-03-27 05:19:43 +0000361# replace both indexes as needed:
Fred Drake85d14c92000-07-31 17:53:45 +0000362sub add_idx_hook {
Fred Drakeb3a3ed81998-07-24 22:17:34 +0000363 add_idx() if (/$idx_mark/);
Fred Drake2383f6d1999-03-02 16:00:37 +0000364 process_python_state();
Fred Drakec5681732000-09-12 20:13:04 +0000365 if ($MODULE_INDEX_FILE) {
366 local ($_);
367 open(MYFILE, "<$MODULE_INDEX_FILE");
368 sysread(MYFILE, $_, 1024*1024);
369 close(MYFILE);
370 add_module_idx();
371 open(MYFILE,">$MODULE_INDEX_FILE");
372 print MYFILE $_;
373 close(MYFILE);
374 }
Fred Drake235e6b11998-03-27 05:19:43 +0000375}
Fred Drakebc7101d1998-03-06 21:18:55 +0000376
Fred Drakebc7101d1998-03-06 21:18:55 +0000377
Fred Drake191439a1999-09-22 19:50:51 +0000378# In addition to the standard stuff, add label to allow named node files and
379# support suppression of the page complete (for HTML Help use).
Fred Drakebc7101d1998-03-06 21:18:55 +0000380sub do_cmd_tableofcontents {
381 local($_) = @_;
382 $TITLE = $toc_title;
383 $tocfile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000384 my($closures,$reopens) = preserve_open_tags();
385 anchor_label('contents', $CURRENT_FILE, $_); # this is added
Fred Drakebeb27bf1999-02-16 17:22:32 +0000386 join('', "<BR>\n\\tableofchildlinks[off]", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000387 , make_section_heading($toc_title, 'H2'), $toc_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000388 , $reopens, $_);
389}
390# In addition to the standard stuff, add label to allow named node files.
391sub do_cmd_listoffigures {
392 local($_) = @_;
393 $TITLE = $lof_title;
394 $loffile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000395 my($closures,$reopens) = preserve_open_tags();
396 anchor_label('lof', $CURRENT_FILE, $_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000397 join('', "<BR>\n", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000398 , make_section_heading($lof_title, 'H2'), $lof_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000399 , $reopens, $_);
400}
401# In addition to the standard stuff, add label to allow named node files.
402sub do_cmd_listoftables {
403 local($_) = @_;
404 $TITLE = $lot_title;
405 $lotfile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000406 my($closures,$reopens) = preserve_open_tags();
407 anchor_label('lot', $CURRENT_FILE, $_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000408 join('', "<BR>\n", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000409 , make_section_heading($lot_title, 'H2'), $lot_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000410 , $reopens, $_);
411}
412# In addition to the standard stuff, add label to allow named node files.
413sub do_cmd_textohtmlinfopage {
414 local($_) = @_;
415 if ($INFO) { #
Fred Drake64bdc241998-04-17 02:14:12 +0000416 anchor_label("about",$CURRENT_FILE,$_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000417 } #
Fred Drake15796f71998-11-30 19:25:47 +0000418 my $the_version = ''; # and the rest is
419 if ($t_date) { # mostly ours
420 $the_version = ",\n$t_date";
Fred Drake7497bd32000-10-25 16:18:10 +0000421 if ($PACKAGE_VERSION) {
Fred Drakedce975c2001-06-20 21:31:36 +0000422 $the_version .= ", Release $PACKAGE_VERSION$RELEASE_INFO";
Fred Drake15796f71998-11-30 19:25:47 +0000423 }
424 }
Fred Drake9443dc32001-08-10 20:12:09 +0000425 my $about;
426 open(ABOUT, "<$ABOUT_FILE") || die "\n$!\n";
427 sysread(ABOUT, $about, 1024*1024);
428 close(ABOUT);
Fred Drake15796f71998-11-30 19:25:47 +0000429 $_ = (($INFO == 1)
Fred Drakeb35f2b71999-09-23 16:53:09 +0000430 ? join('',
431 $close_all,
432 "<strong>$t_title</strong>$the_version\n",
Fred Drake9443dc32001-08-10 20:12:09 +0000433 $about,
Fred Drakeb35f2b71999-09-23 16:53:09 +0000434 $open_all, $_)
435 : join('', $close_all, $INFO,"\n", $open_all, $_));
Fred Drake15796f71998-11-30 19:25:47 +0000436 $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000437}
438
439# $idx_mark will be replaced with the real index at the end
440sub do_cmd_textohtmlindex {
441 local($_) = @_;
442 $TITLE = $idx_title;
443 $idxfile = $CURRENT_FILE;
Fred Drake235e6b11998-03-27 05:19:43 +0000444 if (%index_labels) { make_index_labels(); }
445 if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); }
Fred Drakebc7101d1998-03-06 21:18:55 +0000446 else { $preindex = ''; }
Fred Drake235e6b11998-03-27 05:19:43 +0000447 my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
Fred Drake11916921998-04-02 22:30:57 +0000448 my($pre,$post) = minimize_open_tags($heading);
Fred Drake235e6b11998-03-27 05:19:43 +0000449 anchor_label('genindex',$CURRENT_FILE,$_); # this is added
Fred Drakec5681732000-09-12 20:13:04 +0000450 return "<br>\n" . $pre . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000451}
452
Fred Drakec5681732000-09-12 20:13:04 +0000453$MODULE_INDEX_FILE = '';
454
Fred Drakebc7101d1998-03-06 21:18:55 +0000455# $idx_module_mark will be replaced with the real index at the end
456sub do_cmd_textohtmlmoduleindex {
457 local($_) = @_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000458 $TITLE = $idx_module_title;
Fred Drakec5681732000-09-12 20:13:04 +0000459 anchor_label('modindex', $CURRENT_FILE, $_);
460 $MODULE_INDEX_FILE = "$CURRENT_FILE";
461 $_ = ('<p>' . make_section_heading($idx_module_title, 'h2')
462 . $idx_module_mark . $_);
463 return $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000464}
465
Fred Drakec5681732000-09-12 20:13:04 +0000466# The bibliography and the index should be treated as separate
467# sections in their own HTML files. The \bibliography{} command acts
468# as a sectioning command that has the desired effect. But when the
469# bibliography is constructed manually using the thebibliography
470# environment, or when using the theindex environment it is not
471# possible to use the normal sectioning mechanism. This subroutine
472# inserts a \bibliography{} or a dummy \textohtmlindex command just
473# before the appropriate environments to force sectioning.
Fred Drakebc7101d1998-03-06 21:18:55 +0000474
Fred Drakec5681732000-09-12 20:13:04 +0000475# XXX This *assumes* that if there are two {theindex} environments,
476# the first is the module index and the second is the standard
477# index. This is sufficient for the current Python documentation,
478# but that's about it.
Fred Drakebc7101d1998-03-06 21:18:55 +0000479
480sub add_bbl_and_idx_dummy_commands {
Fred Drake11916921998-04-02 22:30:57 +0000481 my $id = $global{'max_id'};
Fred Drakebc7101d1998-03-06 21:18:55 +0000482
Fred Drakea219b412001-10-22 16:57:49 +0000483 if (/[\\]tableofcontents/) {
484 $HAVE_TABLE_OF_CONTENTS = 1;
485 }
Fred Drakebc7101d1998-03-06 21:18:55 +0000486 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
Fred Drake191439a1999-09-22 19:50:51 +0000487 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 +0000488 my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/);
489 if (scalar(@parts) == 3) {
490 # Be careful to re-write the string in place, since $_ is *not*
491 # returned explicity; *** nasty side-effect dependency! ***
492 print "\nadd_bbl_and_idx_dummy_commands ==> adding module index";
493 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)"
494 . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
495 s/$rx/\\textohtmlmoduleindex \1 \\textohtmlindex \2/o;
496 # Add a button to the navigation areas:
Fred Drakeaaa23852000-09-14 22:20:41 +0000497 $CUSTOM_BUTTONS .= ('<a href="modindex.html" title="Module Index">'
Fred Draked18722b2001-01-02 22:08:48 +0000498 . get_my_icon('modules')
Fred Drakeaaa23852000-09-14 22:20:41 +0000499 . '</a>');
Fred Drakea219b412001-10-22 16:57:49 +0000500 $HAVE_MODULE_INDEX = 1;
501 $HAVE_GENERAL_INDEX = 1;
502 }
503 elsif (scalar(@parts) == 2) {
504 $HAVE_GENERAL_INDEX = 1;
Fred Drake11916921998-04-02 22:30:57 +0000505 }
506 else {
Fred Draked18722b2001-01-02 22:08:48 +0000507 $CUSTOM_BUTTONS .= get_my_icon('blank');
Fred Drake85d14c92000-07-31 17:53:45 +0000508 $global{'max_id'} = $id; # not sure why....
509 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
Fred Drake191439a1999-09-22 19:50:51 +0000510 s/[\\]printindex/\\textohtmlindex /o;
511 }
Fred Drake11916921998-04-02 22:30:57 +0000512 #----------------------------------------------------------------------
Fred Drake64bdc241998-04-17 02:14:12 +0000513 lib_add_bbl_and_idx_dummy_commands()
Fred Drake11916921998-04-02 22:30:57 +0000514 if defined(&lib_add_bbl_and_idx_dummy_commands);
Fred Drakebc7101d1998-03-06 21:18:55 +0000515}
516
Fred Drakec5681732000-09-12 20:13:04 +0000517# The bibliographic references, the appendices, the lists of figures
518# and tables etc. must appear in the contents table at the same level
519# as the outermost sectioning command. This subroutine finds what is
520# the outermost level and sets the above to the same level;
Fred Drakebc7101d1998-03-06 21:18:55 +0000521
Fred Drake13210ed1998-03-17 06:28:05 +0000522sub set_depth_levels {
523 # Sets $outermost_level
Fred Drake11916921998-04-02 22:30:57 +0000524 my $level;
Fred Drake13210ed1998-03-17 06:28:05 +0000525 #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
526 foreach $level ("part", "chapter", "section", "subsection",
527 "subsubsection", "paragraph") {
528 last if (($outermost_level) = /\\($level)$delimiter_rx/);
529 }
530 $level = ($outermost_level ? $section_commands{$outermost_level} :
531 do {$outermost_level = 'section'; 3;});
Fred Drakebc7101d1998-03-06 21:18:55 +0000532
Fred Drake13210ed1998-03-17 06:28:05 +0000533 #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
534 if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
535 $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
536 } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
Fred Drakebc7101d1998-03-06 21:18:55 +0000537
Fred Drake64bdc241998-04-17 02:14:12 +0000538 %unnumbered_section_commands = ('tableofcontents' => $level,
539 'listoffigures' => $level,
540 'listoftables' => $level,
541 'bibliography' => $level,
542 'textohtmlindex' => $level,
543 'textohtmlmoduleindex' => $level);
544 $section_headings{'textohtmlmoduleindex'} = 'h1';
Fred Drakebc7101d1998-03-06 21:18:55 +0000545
Fred Drake64bdc241998-04-17 02:14:12 +0000546 %section_commands = (%unnumbered_section_commands,
547 %section_commands);
Fred Drake11916921998-04-02 22:30:57 +0000548
549 make_sections_rx();
Fred Drake13210ed1998-03-17 06:28:05 +0000550}
Fred Drakebc7101d1998-03-06 21:18:55 +0000551
552
Fred Drake1072e461998-04-12 02:16:34 +0000553# This changes the markup used for {verbatim} environments, and is the
Fred Drake95474f91999-02-09 18:45:50 +0000554# best way I've found that ensures the <dl> goes on the outside of the
Fred Drake1072e461998-04-12 02:16:34 +0000555# <pre>...</pre>.
556#
557# Note that this *must* be done in the init file, not the python.perl
Fred Drakec5681732000-09-12 20:13:04 +0000558# style support file. The %declarations must be set before
559# initialize() is called in the main LaTeX2HTML script (which happens
560# before style files are loaded).
Fred Drake1072e461998-04-12 02:16:34 +0000561#
Fred Drakee15956b2000-04-03 04:51:13 +0000562%declarations = ('preform' => '<dl><dd><pre class="verbatim"></pre></dl>',
Fred Drake1072e461998-04-12 02:16:34 +0000563 %declarations);
564
Fred Drakee15956b2000-04-03 04:51:13 +0000565
Fred Drakec5681732000-09-12 20:13:04 +0000566# This is added to get rid of the long comment that follows the
567# doctype declaration; MSIE5 on NT4 SP4 barfs on it and drops the
568# content of the page.
Fred Drakea219b412001-10-22 16:57:49 +0000569$MY_PARTIAL_HEADER = '';
Fred Drakee15956b2000-04-03 04:51:13 +0000570sub make_head_and_body {
Fred Drake85d14c92000-07-31 17:53:45 +0000571 my($title, $body) = @_;
Fred Drake16816272000-09-16 20:40:44 +0000572 $body = " $body" unless ($body eq '');
Fred Drake85d14c92000-07-31 17:53:45 +0000573 my $DTDcomment = '';
574 my($version, $isolanguage) = ($HTML_VERSION, 'EN');
575 my %isolanguages = ( 'english', 'EN' , 'USenglish', 'EN.US'
576 , 'original', 'EN' , 'german' , 'DE'
577 , 'austrian', 'DE.AT', 'french' , 'FR'
578 , 'spanish', 'ES');
Fred Drakee15956b2000-04-03 04:51:13 +0000579 $isolanguage = $isolanguages{$default_language};
580 $isolanguage = 'EN' unless $isolanguage;
581 $title = &purify($title,1);
582 eval("\$title = ". $default_title ) unless ($title);
583
584 # allow user-modification of the <TITLE> tag; thanks Dan Young
585 if (defined &custom_TITLE_hook) {
586 $title = &custom_TITLE_hook($title, $toc_sec_title);
587 }
588
589 if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included
590 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n";
591 } else {
592 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//"
593 . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n";
594 }
Fred Drakea219b412001-10-22 16:57:49 +0000595 if ($MY_PARTIAL_HEADER eq '') {
596 $STYLESHEET = $FILE.".css" unless $STYLESHEET;
597 $MY_PARTIAL_HEADER = join('',
598 ($CHARSET && $HTML_VERSION ge "2.1"
599 ? ('<meta http-equiv="Content-Type" content="text/html; '
600 . "charset=$charset\">\n")
601 : ''),
602 ($BASE ? "<base href=\"$BASE\">\n" : ''),
603 "<link rel=\"STYLESHEET\" href=\"$STYLESHEET\">\n",
604 "<link rel=\"first\" href=\"$FILE.html\">\n",
605 ($HAVE_TABLE_OF_CONTENTS
606 ? ('<link rel="contents" href="contents.html" title="Contents">'
607 . "\n")
608 : ''),
609 ($HAVE_GENERAL_INDEX
610 ? '<link rel="index" href="genindex.html" title="Index">'
611 : ''),
612 # disable for now -- Mozilla doesn't do well with multiple indexes
613 # ($HAVE_MODULE_INDEX
614 # ? '<link rel="index" href="modindex.html" title="Module Index">'
615 # . "\n"
616 # : ''),
617 $more_links_mark);
618 }
Fred Drakee15956b2000-04-03 04:51:13 +0000619
Fred Drakee15956b2000-04-03 04:51:13 +0000620 if (!$charset && $CHARSET) { $charset = $CHARSET; $charset =~ s/_/\-/go; }
621
622 join('', ($DOCTYPE ? $DTDcomment : '' )
Fred Drakea219b412001-10-22 16:57:49 +0000623 , "<html>\n<head>\n<title>", $title, "</title>\n"
624 , &meta_information($title)
625 , $MY_PARTIAL_HEADER
626 , "\n</head>\n<body$body>");
Fred Drakee15956b2000-04-03 04:51:13 +0000627}
628
Fred Drakebc7101d1998-03-06 21:18:55 +00006291; # This must be the last line