blob: 23279215228ab8e296f8db4431adb4ac97b18cc2 [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';
21
Fred Drake6aa5d481998-08-11 03:14:50 +000022# Control where the navigation bars should show up:
23$TOP_NAVIGATION = 1;
24$BOTTOM_NAVIGATION = 1;
25$AUTO_NAVIGATION = 0;
26
Fred Drake191439a1999-09-22 19:50:51 +000027# these exactly match the python.org colors
28$BODYTEXT = ('bgcolor="#ffffff" text="#000000"'
29 . ' link="#0000bb" vlink="#551a8b" alink="#ff0000"');
Fred Drakebc7101d1998-03-06 21:18:55 +000030$CHILDLINE = "\n<p><hr>\n";
31$VERBOSITY = 0;
Fred Drakebc7101d1998-03-06 21:18:55 +000032
Fred Drake4d10b431998-08-07 20:51:58 +000033# default # of columns for the indexes
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000034$INDEX_COLUMNS = 2;
Fred Drake2383f6d1999-03-02 16:00:37 +000035$MODULE_INDEX_COLUMNS = 4;
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000036
Fred Drakec9f2c141998-03-11 12:08:21 +000037
Fred Drakedb34a1e1998-03-10 23:02:57 +000038# A little painful, but lets us clean up the top level directory a little,
Fred Drake85d14c92000-07-31 17:53:45 +000039# and not be tied to the current directory (as far as I can tell). Testing
40# an existing definition of $mydir is needed since it cannot be computed when
41# run under mkhowto with recent versions of LaTeX2HTML, since this file is
42# not read directly by LaTeX2HTML any more. mkhowto is required to prepend
43# the required definition at the top of the actual input file.
Fred Drakedb34a1e1998-03-10 23:02:57 +000044#
Fred Drake85d14c92000-07-31 17:53:45 +000045if (!defined $mydir) {
46 use Cwd;
47 use File::Basename;
48 ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
49 chop $mydir; # remove trailing '/'
50 $mydir = getcwd() . "$dd$mydir"
51 unless $mydir =~ s|^/|/|;
52}
Fred Drakedb34a1e1998-03-10 23:02:57 +000053$LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES";
Fred Drakeb3a3ed81998-07-24 22:17:34 +000054push (@INC, $mydir);
Fred Drakebc7101d1998-03-06 21:18:55 +000055
Fred Drake235e6b11998-03-27 05:19:43 +000056($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*');
57chop $myrootdir;
58
Fred Drakebc7101d1998-03-06 21:18:55 +000059
Fred Drakea4565b01998-05-15 17:14:17 +000060# Hackish way to get the appropriate paper-*/ directory into $TEXINPUTS;
61# pass in the paper size (a4 or letter) as the environment variable PAPER
62# to add the right directory. If not given, the current directory is
63# added instead for use with HOWTO processing.
64#
65if (defined $ENV{'PAPER'}) {
66 $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey";
67}
68else {
69 $mytexinputs = getcwd() . $envkey;
70}
71$mytexinputs .= "$myrootdir${dd}texinputs";
72
73
Fred Drakeb35f2b71999-09-23 16:53:09 +000074# Change this variable to change the text added in "About this document...";
75# this should be an absolute pathname to get it right.
76#
77$ABOUT_FILE = "$myrootdir${dd}html${dd}stdabout.dat";
78
79
Fred Drake85d14c92000-07-31 17:53:45 +000080sub custom_driver_hook {
Fred Drakea4565b01998-05-15 17:14:17 +000081 #
82 # This adds the directory of the main input file to $TEXINPUTS; it
83 # seems to be sufficiently general that it should be fine for HOWTO
84 # processing.
85 #
86 my $file = @_[0];
Fred Drake85d14c92000-07-31 17:53:45 +000087 my($jobname, $dir, $ext) = fileparse($file, '\..*');
88 $dir = L2hos->Make_directory_absolute($dir);
Fred Drakea4565b01998-05-15 17:14:17 +000089 $dir =~ s/$dd$//;
90 $TEXINPUTS = "$dir$envkey$mytexinputs";
Fred Drake85d14c92000-07-31 17:53:45 +000091 print "\nAdding $dir to \$TEXINPUTS\n";
Fred Drake191439a1999-09-22 19:50:51 +000092}
93
Fred Drakea4565b01998-05-15 17:14:17 +000094
Fred Drake85d14c92000-07-31 17:53:45 +000095$CUSTOM_BUTTONS = '';
96$NAV_BGCOLOR = " bgcolor=\"#99CCFF\"";
Fred Drake062bc6e1998-08-13 22:03:46 +000097
Fred Drake85d14c92000-07-31 17:53:45 +000098sub make_nav_sectref {
Fred Drakebeb27bf1999-02-16 17:22:32 +000099 my($label,$title) = @_;
100 if ($title) {
Fred Drakee15956b2000-04-03 04:51:13 +0000101 return ("<b class='navlabel'>$label:</b> "
102 . "<span class='sectref'>$title</span>\n");
Fred Drakebeb27bf1999-02-16 17:22:32 +0000103 }
104 return '';
105}
106
Fred Drake85d14c92000-07-31 17:53:45 +0000107sub make_my_icon {
108 my($name, $text) = @_;
109 my $iconserver = ($ICONSERVER eq '.') ? '' : "$ICONSERVER/";
110 return "<img src=\"$iconserver$name.$IMAGE_TYPE\" border=\"0\""
111 . " height=\"32\"\n alt=\"$text\" width=\"32\">";
112}
113
114$BLANK_ICON = make_my_icon("blank", "");
115
116@my_icons = ();
117$my_icons{'next_page_inactive'} = $BLANK_ICON;
118$my_icons{'previous_page_inactive'} = $BLANK_ICON;
119$my_icons{'up_page_inactive'} = $BLANK_ICON;
120$x = make_my_icon("next", "Next Page");
121$my_icons{'next_page'} = $x;
122$my_icons{'next'} = $x;
123$x = make_my_icon("previous", "Previous Page");
124$my_icons{'previous_page'} = $x;
125$my_icons{'previous'} = $x;
126$my_icons{'up'} = make_my_icon("up", "Up One Level");
127$my_icons{'contents'} = make_my_icon("contents", "Contents");
128$my_icons{'index'} = make_my_icon("index", "Index");
129$my_icons{'modules'} = make_my_icon("modules", "Module Index");
130
131
132sub use_my_icon {
133 my $s = @_[0];
134 $s =~ s/\<tex2html_([a-z_]+)_visible_mark\>/$my_icons{$1}/;
Fred Drakea0075441999-04-29 19:06:56 +0000135 return $s;
Fred Drake13210ed1998-03-17 06:28:05 +0000136}
137
Fred Drake85d14c92000-07-31 17:53:45 +0000138sub make_nav_panel {
139 my $s;
140 $NEXT = use_my_icon("$NEXT");
141 $UP = use_my_icon("$UP");
142 $PREVIOUS = use_my_icon("$PREVIOUS");
143 $CONTENTS = use_my_icon("$CONTENTS");
144 $INDEX = $INDEX ? use_my_icon("$INDEX") : $BLANK_ICON;
145 if (!$CUSTOM_BUTTONS) {
146 $CUSTOM_BUTTONS = $BLANK_ICON;
147 }
148 $s = ('<table align="center" width="100%" cellpadding="0" cellspacing="2">'
149 . "\n<tr>"
150 # left-hand side
151 . "\n<td>$NEXT</td>"
152 . "\n<td>$UP</td>"
153 . "\n<td>$PREVIOUS</td>"
154 # title box
155 . "\n<td align=\"center\"$NAV_BGCOLOR width=\"100%\">"
156 . "\n <b class=\"title\">$t_title</b></td>"
157 # right-hand side
158 . "\n<td>$CONTENTS</td>"
159 . "\n<td>$CUSTOM_BUTTONS</td>" # module index
160 . "\n<td>$INDEX</td>"
161 . "\n</tr></table>\n"
162 # textual navigation
163 . make_nav_sectref("Next", $NEXT_TITLE)
164 . make_nav_sectref("Up", $UP_TITLE)
165 . make_nav_sectref("Previous", $PREVIOUS_TITLE));
166 # remove these; they are unnecessary and cause errors from validation
167 $s =~ s/ NAME="tex2html\d+"\n */ /g;
168 return $s;
169}
170
171
Fred Drakebc7101d1998-03-06 21:18:55 +0000172sub top_navigation_panel {
Fred Drake85d14c92000-07-31 17:53:45 +0000173 return make_nav_panel()
174 . '<br><hr>';
Fred Drakebc7101d1998-03-06 21:18:55 +0000175}
176
177sub bot_navigation_panel {
Fred Drake85d14c92000-07-31 17:53:45 +0000178 return "<p><hr>"
179 . make_nav_panel();
Fred Drake64bdc241998-04-17 02:14:12 +0000180}
181
182sub add_link {
183 # Returns a pair (iconic link, textual link)
184 my($icon, $current_file, @link) = @_;
185 my($dummy, $file, $title) = split($delim,
Fred Drake28e7b4c1998-10-20 18:14:20 +0000186 $section_info{join(' ',@link)});
Fred Drake85d14c92000-07-31 17:53:45 +0000187 $icon =~ s/\<tex2html_([_a-z]+)_visible_mark\>/$my_icons{$1}/;
Fred Drake64bdc241998-04-17 02:14:12 +0000188 if ($title && ($file ne $current_file)) {
189 $title = purify($title);
190 $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
191 return (make_href($file, $icon), make_href($file, "$title"))
192 }
Fred Drake85d14c92000-07-31 17:53:45 +0000193 elsif ($icon eq $my_icons{"up"} && $EXTERNAL_UP_LINK) {
Fred Drake64bdc241998-04-17 02:14:12 +0000194 return (make_href($EXTERNAL_UP_LINK, $icon),
195 make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
196 }
Fred Drake85d14c92000-07-31 17:53:45 +0000197 elsif ($icon eq $my_icons{"previous"}
Fred Drake64bdc241998-04-17 02:14:12 +0000198 && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
199 return (make_href($EXTERNAL_PREV_LINK, $icon),
200 make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
201 }
Fred Drake85d14c92000-07-31 17:53:45 +0000202 elsif ($icon eq $my_icons{"next"}
Fred Drake64bdc241998-04-17 02:14:12 +0000203 && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
204 return (make_href($EXTERNAL_DOWN_LINK, $icon),
205 make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
206 }
Fred Drake85d14c92000-07-31 17:53:45 +0000207 return (&inactive_img($icon), "");
Fred Drake64bdc241998-04-17 02:14:12 +0000208}
209
210sub add_special_link {
211 my($icon, $file, $current_file) = @_;
Fred Drake85d14c92000-07-31 17:53:45 +0000212 $icon =~ s/\<tex2html_([_a-z]+)_visible_mark\>/$my_icons{$1}/;
213 return (($file && ($file ne $current_file))
214 ? make_href($file, $icon)
215 : undef)
Fred Drake64bdc241998-04-17 02:14:12 +0000216}
217
Fred Drake85d14c92000-07-31 17:53:45 +0000218# The img_tag() function seems only to be called with the parameter
219# 'anchor_invisible_mark', which we want to turn into ''. Since
220# replace_icon_marks() is the only interesting caller, and all it really
221# does is call img_tag(), we can just define the hook alternative to be
222# a no-op instead.
223#
224sub replace_icons_hook {}
Fred Drakebc7101d1998-03-06 21:18:55 +0000225
Fred Drake50cdd971999-02-19 23:04:59 +0000226sub do_cmd_arabic {
227 # get rid of that nasty <SPAN CLASS="arabic">...</SPAN>
Fred Drake85d14c92000-07-31 17:53:45 +0000228 my($ctr, $val, $id, $text) = &read_counter_value(@_[0]);
229 return ($val ? farabic($val) : "0") . $text;
Fred Drake50cdd971999-02-19 23:04:59 +0000230}
231
232
Fred Drakebc7101d1998-03-06 21:18:55 +0000233sub gen_index_id {
234 # this is used to ensure common index key generation and a stable sort
Fred Drake235e6b11998-03-27 05:19:43 +0000235 my($str,$extra) = @_;
Fred Drake64bdc241998-04-17 02:14:12 +0000236 sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
Fred Drakebc7101d1998-03-06 21:18:55 +0000237}
238
Fred Drake85d14c92000-07-31 17:53:45 +0000239sub insert_index {
Fred Drake2383f6d1999-03-02 16:00:37 +0000240 my($mark,$datafile,$columns,$letters,$prefix) = @_;
Fred Drake4d10b431998-08-07 20:51:58 +0000241 my $prog = "$myrootdir/tools/buildindex.py";
242 my $index;
243 if ($letters) {
244 $index = `$prog --columns $columns --letters $datafile`;
245 }
246 else {
247 $index = `$prog --columns $columns $datafile`;
248 }
Fred Drake2383f6d1999-03-02 16:00:37 +0000249 s/$mark/$prefix$index/;
Fred Drake64bdc241998-04-17 02:14:12 +0000250}
251
Fred Drake85d14c92000-07-31 17:53:45 +0000252sub add_idx {
Fred Drake9bbdce51999-01-19 16:30:10 +0000253 print "\nBuilding HTML for the index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000254 close(IDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000255 insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
Fred Drake13210ed1998-03-17 06:28:05 +0000256}
Fred Drakebc7101d1998-03-06 21:18:55 +0000257
258
259$idx_module_mark = '<tex2html_idx_module_mark>';
260$idx_module_title = 'Module Index';
261
Fred Drake85d14c92000-07-31 17:53:45 +0000262sub add_module_idx {
Fred Drake9bbdce51999-01-19 16:30:10 +0000263 print "\nBuilding HTML for the module index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000264 my $key;
Fred Drake2383f6d1999-03-02 16:00:37 +0000265 my $first = 1;
266 my $prevplat = '';
267 my $allthesame = 1;
268 my $prefix = '';
269 foreach $key (keys %Modules) {
270 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
271 my $plat = "$ModulePlatforms{$key}";
272 $plat = ''
Fred Drake62cc3601999-03-04 18:41:17 +0000273 if ($plat eq $IGNORE_PLATFORM_ANNOTATION);
Fred Drake2383f6d1999-03-02 16:00:37 +0000274 if (!$first) {
275 $allthesame = 0
276 if ($prevplat ne $plat);
277 }
278 else { $first = 0; }
279 $prevplat = $plat;
280 }
Fred Drake64bdc241998-04-17 02:14:12 +0000281 open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
Fred Drake235e6b11998-03-27 05:19:43 +0000282 foreach $key (keys %Modules) {
283 # dump the line in the data file; just use a dummy seqno field
Fred Drake2383f6d1999-03-02 16:00:37 +0000284 my $nkey = $1;
285 my $moditem = "$Modules{$key}";
286 my $plat = '';
287 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
288 if ($ModulePlatforms{$key} && !$allthesame) {
Fred Drakee15956b2000-04-03 04:51:13 +0000289 $plat = (" <em>(<span class='platform'>$ModulePlatforms{$key}"
Fred Drakebb584d31999-03-25 22:18:30 +0000290 . '</span>)</em>');
Fred Drake2383f6d1999-03-02 16:00:37 +0000291 }
Fred Drakee15956b2000-04-03 04:51:13 +0000292 print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP
293 . "<tt class='module'>$key</tt>$plat###\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000294 }
Fred Drake235e6b11998-03-27 05:19:43 +0000295 close(MODIDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000296 if (!$allthesame) {
297 $prefix = <<PLAT_DISCUSS;
298
299
300<p> Some module names are followed by an annotation indicating what
301platform they are available on.</p>
302
303PLAT_DISCUSS
304 }
305 insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
306 $prefix);
Fred Drakebc7101d1998-03-06 21:18:55 +0000307}
308
Fred Drake235e6b11998-03-27 05:19:43 +0000309# replace both indexes as needed:
Fred Drake85d14c92000-07-31 17:53:45 +0000310sub add_idx_hook {
Fred Drakeb3a3ed81998-07-24 22:17:34 +0000311 add_idx() if (/$idx_mark/);
312 add_module_idx() if (/$idx_module_mark/);
Fred Drake2383f6d1999-03-02 16:00:37 +0000313 process_python_state();
Fred Drake235e6b11998-03-27 05:19:43 +0000314}
Fred Drakebc7101d1998-03-06 21:18:55 +0000315
Fred Drakebc7101d1998-03-06 21:18:55 +0000316
Fred Drake191439a1999-09-22 19:50:51 +0000317# In addition to the standard stuff, add label to allow named node files and
318# support suppression of the page complete (for HTML Help use).
Fred Drakebc7101d1998-03-06 21:18:55 +0000319sub do_cmd_tableofcontents {
320 local($_) = @_;
321 $TITLE = $toc_title;
322 $tocfile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000323 my($closures,$reopens) = preserve_open_tags();
324 anchor_label('contents', $CURRENT_FILE, $_); # this is added
Fred Drakebeb27bf1999-02-16 17:22:32 +0000325 join('', "<BR>\n\\tableofchildlinks[off]", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000326 , make_section_heading($toc_title, 'H2'), $toc_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000327 , $reopens, $_);
328}
329# In addition to the standard stuff, add label to allow named node files.
330sub do_cmd_listoffigures {
331 local($_) = @_;
332 $TITLE = $lof_title;
333 $loffile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000334 my($closures,$reopens) = preserve_open_tags();
335 anchor_label('lof', $CURRENT_FILE, $_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000336 join('', "<BR>\n", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000337 , make_section_heading($lof_title, 'H2'), $lof_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000338 , $reopens, $_);
339}
340# In addition to the standard stuff, add label to allow named node files.
341sub do_cmd_listoftables {
342 local($_) = @_;
343 $TITLE = $lot_title;
344 $lotfile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000345 my($closures,$reopens) = preserve_open_tags();
346 anchor_label('lot', $CURRENT_FILE, $_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000347 join('', "<BR>\n", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000348 , make_section_heading($lot_title, 'H2'), $lot_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000349 , $reopens, $_);
350}
351# In addition to the standard stuff, add label to allow named node files.
352sub do_cmd_textohtmlinfopage {
353 local($_) = @_;
354 if ($INFO) { #
Fred Drake64bdc241998-04-17 02:14:12 +0000355 anchor_label("about",$CURRENT_FILE,$_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000356 } #
Fred Drake15796f71998-11-30 19:25:47 +0000357 my $the_version = ''; # and the rest is
358 if ($t_date) { # mostly ours
359 $the_version = ",\n$t_date";
360 if ($PYTHON_VERSION) {
361 $the_version .= ", Release $PYTHON_VERSION";
362 }
363 }
364 $_ = (($INFO == 1)
Fred Drakeb35f2b71999-09-23 16:53:09 +0000365 ? join('',
366 $close_all,
367 "<strong>$t_title</strong>$the_version\n",
368 `cat $ABOUT_FILE`,
369 $open_all, $_)
370 : join('', $close_all, $INFO,"\n", $open_all, $_));
Fred Drake15796f71998-11-30 19:25:47 +0000371 $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000372}
373
374# $idx_mark will be replaced with the real index at the end
375sub do_cmd_textohtmlindex {
376 local($_) = @_;
377 $TITLE = $idx_title;
378 $idxfile = $CURRENT_FILE;
Fred Drake235e6b11998-03-27 05:19:43 +0000379 if (%index_labels) { make_index_labels(); }
380 if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); }
Fred Drakebc7101d1998-03-06 21:18:55 +0000381 else { $preindex = ''; }
Fred Drake235e6b11998-03-27 05:19:43 +0000382 my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
Fred Drake11916921998-04-02 22:30:57 +0000383 my($pre,$post) = minimize_open_tags($heading);
Fred Drake235e6b11998-03-27 05:19:43 +0000384 anchor_label('genindex',$CURRENT_FILE,$_); # this is added
385 '<br>\n' . $pre . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000386}
387
388# $idx_module_mark will be replaced with the real index at the end
389sub do_cmd_textohtmlmoduleindex {
390 local($_) = @_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000391 $TITLE = $idx_module_title;
Fred Drake64bdc241998-04-17 02:14:12 +0000392 anchor_label("modindex",$CURRENT_FILE,$_);
Fred Drake235e6b11998-03-27 05:19:43 +0000393 '<p>' . make_section_heading($idx_module_title, "h2")
394 . $idx_module_mark . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000395}
396
397# The bibliography and the index should be treated as separate sections
398# in their own HTML files. The \bibliography{} command acts as a sectioning command
399# that has the desired effect. But when the bibliography is constructed
400# manually using the thebibliography environment, or when using the
401# theindex environment it is not possible to use the normal sectioning
402# mechanism. This subroutine inserts a \bibliography{} or a dummy
403# \textohtmlindex command just before the appropriate environments
404# to force sectioning.
405
406# XXX This *assumes* that if there are two {theindex} environments, the
407# first is the module index and the second is the standard index. This
408# is sufficient for the current Python documentation, but that's about
409# it.
410
411sub add_bbl_and_idx_dummy_commands {
Fred Drake11916921998-04-02 22:30:57 +0000412 my $id = $global{'max_id'};
Fred Drakebc7101d1998-03-06 21:18:55 +0000413
414 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
Fred Drake191439a1999-09-22 19:50:51 +0000415 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 +0000416 my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/);
417 if (scalar(@parts) == 3) {
418 # Be careful to re-write the string in place, since $_ is *not*
419 # returned explicity; *** nasty side-effect dependency! ***
420 print "\nadd_bbl_and_idx_dummy_commands ==> adding module index";
421 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)"
422 . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
423 s/$rx/\\textohtmlmoduleindex \1 \\textohtmlindex \2/o;
424 # Add a button to the navigation areas:
425 $CUSTOM_BUTTONS .= $my_icons{'modules'};
Fred Drake11916921998-04-02 22:30:57 +0000426 }
427 else {
Fred Drake85d14c92000-07-31 17:53:45 +0000428 $CUSTOM_BUTTONS .= $BLANK_ICON;
429 $global{'max_id'} = $id; # not sure why....
430 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
Fred Drake191439a1999-09-22 19:50:51 +0000431 s/[\\]printindex/\\textohtmlindex /o;
432 }
Fred Drake11916921998-04-02 22:30:57 +0000433 #----------------------------------------------------------------------
Fred Drake64bdc241998-04-17 02:14:12 +0000434 lib_add_bbl_and_idx_dummy_commands()
Fred Drake11916921998-04-02 22:30:57 +0000435 if defined(&lib_add_bbl_and_idx_dummy_commands);
Fred Drakebc7101d1998-03-06 21:18:55 +0000436}
437
438# The bibliographic references, the appendices, the lists of figures and tables
439# etc. must appear in the contents table at the same level as the outermost
440# sectioning command. This subroutine finds what is the outermost level and
441# sets the above to the same level;
442
Fred Drake13210ed1998-03-17 06:28:05 +0000443sub set_depth_levels {
444 # Sets $outermost_level
Fred Drake11916921998-04-02 22:30:57 +0000445 my $level;
Fred Drake13210ed1998-03-17 06:28:05 +0000446 #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
447 foreach $level ("part", "chapter", "section", "subsection",
448 "subsubsection", "paragraph") {
449 last if (($outermost_level) = /\\($level)$delimiter_rx/);
450 }
451 $level = ($outermost_level ? $section_commands{$outermost_level} :
452 do {$outermost_level = 'section'; 3;});
Fred Drakebc7101d1998-03-06 21:18:55 +0000453
Fred Drake13210ed1998-03-17 06:28:05 +0000454 #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
455 if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
456 $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
457 } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
Fred Drakebc7101d1998-03-06 21:18:55 +0000458
Fred Drake64bdc241998-04-17 02:14:12 +0000459 %unnumbered_section_commands = ('tableofcontents' => $level,
460 'listoffigures' => $level,
461 'listoftables' => $level,
462 'bibliography' => $level,
463 'textohtmlindex' => $level,
464 'textohtmlmoduleindex' => $level);
465 $section_headings{'textohtmlmoduleindex'} = 'h1';
Fred Drakebc7101d1998-03-06 21:18:55 +0000466
Fred Drake64bdc241998-04-17 02:14:12 +0000467 %section_commands = (%unnumbered_section_commands,
468 %section_commands);
Fred Drake11916921998-04-02 22:30:57 +0000469
470 make_sections_rx();
Fred Drake13210ed1998-03-17 06:28:05 +0000471}
Fred Drakebc7101d1998-03-06 21:18:55 +0000472
473
Fred Drake1072e461998-04-12 02:16:34 +0000474# This changes the markup used for {verbatim} environments, and is the
Fred Drake95474f91999-02-09 18:45:50 +0000475# best way I've found that ensures the <dl> goes on the outside of the
Fred Drake1072e461998-04-12 02:16:34 +0000476# <pre>...</pre>.
477#
478# Note that this *must* be done in the init file, not the python.perl
479# style support file. The %declarations must be set before initialize()
Fred Drakee15956b2000-04-03 04:51:13 +0000480# is called in the main LaTeX2HTML script (which happens before style files
481# are loaded).
Fred Drake1072e461998-04-12 02:16:34 +0000482#
Fred Drakee15956b2000-04-03 04:51:13 +0000483%declarations = ('preform' => '<dl><dd><pre class="verbatim"></pre></dl>',
Fred Drake1072e461998-04-12 02:16:34 +0000484 %declarations);
485
Fred Drakee15956b2000-04-03 04:51:13 +0000486
487# This is added to get rid of the long comment that follows the doctype
488# declaration; MSIE5 on NT4 SP4 barfs on it and drops the content of the
489# page.
490sub make_head_and_body {
Fred Drake85d14c92000-07-31 17:53:45 +0000491 my($title, $body) = @_;
492 my $DTDcomment = '';
493 my($version, $isolanguage) = ($HTML_VERSION, 'EN');
494 my %isolanguages = ( 'english', 'EN' , 'USenglish', 'EN.US'
495 , 'original', 'EN' , 'german' , 'DE'
496 , 'austrian', 'DE.AT', 'french' , 'FR'
497 , 'spanish', 'ES');
Fred Drakee15956b2000-04-03 04:51:13 +0000498 $isolanguage = $isolanguages{$default_language};
499 $isolanguage = 'EN' unless $isolanguage;
500 $title = &purify($title,1);
501 eval("\$title = ". $default_title ) unless ($title);
502
503 # allow user-modification of the <TITLE> tag; thanks Dan Young
504 if (defined &custom_TITLE_hook) {
505 $title = &custom_TITLE_hook($title, $toc_sec_title);
506 }
507
508 if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included
509 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n";
510 } else {
511 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//"
512 . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n";
513 }
514
515 $STYLESHEET = $FILE.".css" unless $STYLESHEET;
516 if (!$charset && $CHARSET) { $charset = $CHARSET; $charset =~ s/_/\-/go; }
517
518 join('', ($DOCTYPE ? $DTDcomment : '' )
519 ,"<html>\n<head>\n<title>", $title, "</title>\n"
520 , &meta_information($title)
521 , ($CHARSET && $HTML_VERSION ge "2.1" ?
522 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$charset\">\n"
523 : "" )
524 , ($BASE ? "<base href=\"$BASE\">\n" : "" )
525 , "<link rel=\"STYLESHEET\" href=\"$STYLESHEET\">"
526 , $more_links_mark
527 , "\n</head>\n<body $body>\n");
528}
529
Fred Drakebc7101d1998-03-06 21:18:55 +00005301; # This must be the last line