Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 1 | #LaTeX2HTML Version 96.1 : dot.latex2html-init -*- perl -*- |
| 2 | # |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 3 | # Significantly revised by Fred L. Drake, Jr. <fdrake@acm.org> for use |
| 4 | # with the Python documentation. |
| 5 | # |
| 6 | # New name to avoid distributing "dot" files with the Python documentation. |
| 7 | # |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 8 | |
Fred Drake | 41814bc | 1998-05-11 18:23:35 +0000 | [diff] [blame] | 9 | package Override; |
| 10 | |
| 11 | use Cwd qw(getcwd); |
| 12 | |
| 13 | |
| 14 | package main; |
| 15 | |
Fred Drake | 28e7b4c | 1998-10-20 18:14:20 +0000 | [diff] [blame] | 16 | $HTML_VERSION = 4.0; |
| 17 | |
Fred Drake | 6aa5d48 | 1998-08-11 03:14:50 +0000 | [diff] [blame] | 18 | $MAX_LINK_DEPTH = 2; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 19 | $MAX_SPLIT_DEPTH = 5; # split at subsections but not sub-subsections |
Fred Drake | d757165 | 1998-04-23 20:06:24 +0000 | [diff] [blame] | 20 | $ADDRESS = ''; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 21 | |
Fred Drake | e194beb | 1998-05-19 19:38:49 +0000 | [diff] [blame] | 22 | $NO_FOOTNODE = 1; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 23 | $NUMBERED_FOOTNOTES = 1; |
| 24 | |
| 25 | # Python documentation uses section numbers to support references to match |
| 26 | # in the printed and online versions. |
| 27 | # |
| 28 | $SHOW_SECTION_NUMBERS = 1; |
| 29 | |
| 30 | $ICONSERVER = '../icons'; |
| 31 | |
Fred Drake | 6aa5d48 | 1998-08-11 03:14:50 +0000 | [diff] [blame] | 32 | # Control where the navigation bars should show up: |
| 33 | $TOP_NAVIGATION = 1; |
| 34 | $BOTTOM_NAVIGATION = 1; |
| 35 | $AUTO_NAVIGATION = 0; |
| 36 | |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 37 | $SUPPRESS_CONTENTS = 0; |
| 38 | $SUPPRESS_INDEXES = 0; |
| 39 | |
| 40 | # these exactly match the python.org colors |
| 41 | $BODYTEXT = ('bgcolor="#ffffff" text="#000000"' |
| 42 | . ' link="#0000bb" vlink="#551a8b" alink="#ff0000"'); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 43 | $CHILDLINE = "\n<p><hr>\n"; |
| 44 | $VERBOSITY = 0; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 45 | |
Fred Drake | 4d10b43 | 1998-08-07 20:51:58 +0000 | [diff] [blame] | 46 | # default # of columns for the indexes |
Fred Drake | aa3f9fb | 1998-08-07 19:52:37 +0000 | [diff] [blame] | 47 | $INDEX_COLUMNS = 2; |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 48 | $MODULE_INDEX_COLUMNS = 4; |
Fred Drake | aa3f9fb | 1998-08-07 19:52:37 +0000 | [diff] [blame] | 49 | |
Fred Drake | c9f2c14 | 1998-03-11 12:08:21 +0000 | [diff] [blame] | 50 | |
Fred Drake | db34a1e | 1998-03-10 23:02:57 +0000 | [diff] [blame] | 51 | # A little painful, but lets us clean up the top level directory a little, |
| 52 | # and not be tied to the current directory (as far as I can tell). |
| 53 | # |
Fred Drake | c9f2c14 | 1998-03-11 12:08:21 +0000 | [diff] [blame] | 54 | use Cwd; |
| 55 | use File::Basename; |
| 56 | ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*'); |
| 57 | chop $mydir; # remove trailing '/' |
| 58 | $mydir = getcwd() . "$dd$mydir" |
| 59 | unless $mydir =~ s|^/|/|; |
Fred Drake | db34a1e | 1998-03-10 23:02:57 +0000 | [diff] [blame] | 60 | $LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES"; |
Fred Drake | b3a3ed8 | 1998-07-24 22:17:34 +0000 | [diff] [blame] | 61 | push (@INC, $mydir); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 62 | |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 63 | ($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*'); |
| 64 | chop $myrootdir; |
| 65 | |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 66 | |
Fred Drake | a4565b0 | 1998-05-15 17:14:17 +0000 | [diff] [blame] | 67 | # Hackish way to get the appropriate paper-*/ directory into $TEXINPUTS; |
| 68 | # pass in the paper size (a4 or letter) as the environment variable PAPER |
| 69 | # to add the right directory. If not given, the current directory is |
| 70 | # added instead for use with HOWTO processing. |
| 71 | # |
| 72 | if (defined $ENV{'PAPER'}) { |
| 73 | $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey"; |
| 74 | } |
| 75 | else { |
| 76 | $mytexinputs = getcwd() . $envkey; |
| 77 | } |
| 78 | $mytexinputs .= "$myrootdir${dd}texinputs"; |
| 79 | |
| 80 | |
Fred Drake | b35f2b7 | 1999-09-23 16:53:09 +0000 | [diff] [blame] | 81 | # Change this variable to change the text added in "About this document..."; |
| 82 | # this should be an absolute pathname to get it right. |
| 83 | # |
| 84 | $ABOUT_FILE = "$myrootdir${dd}html${dd}stdabout.dat"; |
| 85 | |
| 86 | |
Fred Drake | a4565b0 | 1998-05-15 17:14:17 +0000 | [diff] [blame] | 87 | sub custom_driver_hook{ |
| 88 | # |
| 89 | # This adds the directory of the main input file to $TEXINPUTS; it |
| 90 | # seems to be sufficiently general that it should be fine for HOWTO |
| 91 | # processing. |
| 92 | # |
| 93 | my $file = @_[0]; |
| 94 | my($jobname,$dir,$ext) = fileparse($file, '\..*'); |
| 95 | $dir = make_directory_absolute($dir); |
| 96 | $dir =~ s/$dd$//; |
| 97 | $TEXINPUTS = "$dir$envkey$mytexinputs"; |
| 98 | print "\nadding $dir to \$TEXINPUTS\n"; |
| 99 | } |
| 100 | |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 101 | # Defining this allows us to remove all table of contents and index |
| 102 | # processing using an init file; this is required to get rid of the |
| 103 | # Table of Contents or we'd get a blank page. Based on a suggestion |
| 104 | # from Ross Moore <ross@ics.mq.edu.au>. |
| 105 | # |
| 106 | # Seems to require a more recent version of LaTeX2HTML than I've |
| 107 | # been using, though. |
| 108 | # |
| 109 | sub preprocess{ |
| 110 | if ($SUPPRESS_CONTENTS) { |
| 111 | s/\\(tableofcontents|listof(figures|tables))/\2/g; |
| 112 | } |
| 113 | if ($SUPPRESS_INDEXES) { |
| 114 | s/\\(print|make)index//g; |
| 115 | } |
| 116 | } |
| 117 | |
Fred Drake | a4565b0 | 1998-05-15 17:14:17 +0000 | [diff] [blame] | 118 | |
Fred Drake | 062bc6e | 1998-08-13 22:03:46 +0000 | [diff] [blame] | 119 | sub set_icon_size{ |
| 120 | my($name, $w, $h) = @_; |
| 121 | $iconsizes{$name} = "width=$w height=$h"; |
| 122 | } |
| 123 | |
Fred Drake | 95474f9 | 1999-02-09 18:45:50 +0000 | [diff] [blame] | 124 | foreach $name (split(/ /, 'up next previous contents index modules blank')) { |
Fred Drake | 062bc6e | 1998-08-13 22:03:46 +0000 | [diff] [blame] | 125 | set_icon_size($name, 32, 32); |
| 126 | } |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 127 | sub adjust_icon_information{ |
| 128 | # The '_motif' is really annoying, and makes the HTML larger with no value |
| 129 | # added, so strip it off: |
| 130 | foreach $name (keys %icons) { |
| 131 | my $icon = $icons{$name}; |
| 132 | # Strip off the wasteful '_motif': |
| 133 | $icon =~ s/_motif//; |
| 134 | # Change the greyed-out icons to be blank: |
| 135 | $icon =~ s/[a-z]*_gr[.]/blank./; |
| 136 | # make sure we're using the latest $IMAGE_TYPE |
| 137 | $icon =~ s/[.](gif|png)$/.$IMAGE_TYPE/; |
| 138 | $icons{$name} = $icon; |
| 139 | } |
| 140 | $icons{'blank'} = 'blank.' . $IMAGE_TYPE; |
| 141 | |
| 142 | $CUSTOM_BUTTONS = ''; |
| 143 | $BLANK_ICON = "\n<td>" . img_tag('blank.' . $IMAGE_TYPE) . "</td>"; |
| 144 | $BLANK_ICON =~ s/alt="blank"/alt=""/; |
| 145 | $NAV_BGCOLOR = " bgcolor=\"#99CCFF\""; |
Fred Drake | 062bc6e | 1998-08-13 22:03:46 +0000 | [diff] [blame] | 146 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 147 | |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 148 | adjust_icon_information(); |
Fred Drake | 9f7adc4 | 1998-08-11 19:33:38 +0000 | [diff] [blame] | 149 | |
Fred Drake | 6aa5d48 | 1998-08-11 03:14:50 +0000 | [diff] [blame] | 150 | |
Fred Drake | beb27bf | 1999-02-16 17:22:32 +0000 | [diff] [blame] | 151 | sub make_nav_sectref{ |
| 152 | my($label,$title) = @_; |
| 153 | if ($title) { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 154 | return ("<b class='navlabel'>$label:</b> " |
| 155 | . "<span class='sectref'>$title</span>\n"); |
Fred Drake | beb27bf | 1999-02-16 17:22:32 +0000 | [diff] [blame] | 156 | } |
| 157 | return ''; |
| 158 | } |
| 159 | |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 160 | sub make_nav_panel{ |
Fred Drake | a007544 | 1999-04-29 19:06:56 +0000 | [diff] [blame] | 161 | my $s; |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 162 | $s = "<table align='center' width='100%' cellpadding='0' cellspacing='2'>" |
Fred Drake | a007544 | 1999-04-29 19:06:56 +0000 | [diff] [blame] | 163 | . "\n<tr>" |
| 164 | . "\n<td>$NEXT</td>" |
| 165 | . "\n<td>$UP</td>" |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 166 | . "\n<td>$PREVIOUS</td>"; |
| 167 | if ($SUPPRESS_CONTENTS && $SUPPRESS_INDEXES) { |
| 168 | $s .= ("\n<td align=right$NAV_BGCOLOR width=\"100%\">" |
| 169 | . "\n <b class=title>$t_title\ \ \ </b></td>"); |
| 170 | } |
| 171 | else { |
| 172 | $s .= ("\n<td align=center$NAV_BGCOLOR width=\"100%\">" |
| 173 | . "\n <b class=title>$t_title</b></td>" |
| 174 | . ($CONTENTS ? "\n<td>$CONTENTS</td>" : $BLANK_ICON) |
| 175 | . "\n<td>$CUSTOM_BUTTONS</td>" # module index |
| 176 | . ($INDEX ? "\n<td>$INDEX</td>" : $BLANK_ICON)); |
| 177 | } |
| 178 | $s .= ("\n</tr></table>" |
| 179 | . make_nav_sectref("Next", $NEXT_TITLE) |
| 180 | . make_nav_sectref("Up", $UP_TITLE) |
| 181 | . make_nav_sectref("Previous", $PREVIOUS_TITLE)); |
| 182 | # remove these; they are unnecessary and cause error from validation |
Fred Drake | a007544 | 1999-04-29 19:06:56 +0000 | [diff] [blame] | 183 | $s =~ s/ NAME="tex2html\d+"\n//g; |
| 184 | return $s; |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 185 | } |
| 186 | |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 187 | sub top_navigation_panel { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 188 | "<div class='navigation'>\n" |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 189 | . make_nav_panel() |
Fred Drake | 72e5a90 | 1999-02-10 17:35:41 +0000 | [diff] [blame] | 190 | . '<br><hr></div>'; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | sub bot_navigation_panel { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 194 | "<p>\n<div class='navigation'><hr>" |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 195 | . make_nav_panel() |
| 196 | . '</div>'; |
| 197 | } |
| 198 | |
| 199 | sub add_link { |
| 200 | # Returns a pair (iconic link, textual link) |
| 201 | my($icon, $current_file, @link) = @_; |
| 202 | my($dummy, $file, $title) = split($delim, |
Fred Drake | 28e7b4c | 1998-10-20 18:14:20 +0000 | [diff] [blame] | 203 | $section_info{join(' ',@link)}); |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 204 | if ($title && ($file ne $current_file)) { |
| 205 | $title = purify($title); |
| 206 | $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES); |
| 207 | return (make_href($file, $icon), make_href($file, "$title")) |
| 208 | } |
| 209 | elsif ($icon eq $up_visible_mark && $EXTERNAL_UP_LINK) { |
| 210 | return (make_href($EXTERNAL_UP_LINK, $icon), |
| 211 | make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE")) |
| 212 | } |
| 213 | elsif (($icon eq $previous_visible_mark |
| 214 | || $icon eq $previous_page_visible_mark) |
| 215 | && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) { |
| 216 | return (make_href($EXTERNAL_PREV_LINK, $icon), |
| 217 | make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE")) |
| 218 | } |
| 219 | elsif (($icon eq $next_visible_mark |
| 220 | || $icon eq $next_page_visible_mark) |
| 221 | && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) { |
| 222 | return (make_href($EXTERNAL_DOWN_LINK, $icon), |
| 223 | make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE")) |
| 224 | } |
| 225 | (&inactive_img($icon), ""); |
| 226 | } |
| 227 | |
| 228 | sub add_special_link { |
| 229 | my($icon, $file, $current_file) = @_; |
| 230 | (($file && ($file ne $current_file)) ? make_href($file, $icon) : undef) |
| 231 | } |
| 232 | |
| 233 | sub img_tag { |
| 234 | local($icon) = @_; |
| 235 | my $alt; |
| 236 | my $align = " align=bottom "; |
| 237 | |
Fred Drake | 062bc6e | 1998-08-13 22:03:46 +0000 | [diff] [blame] | 238 | # having this list hardcoded here is really bogus.... |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 239 | $alt = join('|', 'up', 'next_group', 'previous_group' |
| 240 | , 'next', 'previous', 'change_begin_right', 'change_begin' |
| 241 | , 'change_end_right', 'change_end', 'change_delete_right' |
Fred Drake | 95474f9 | 1999-02-09 18:45:50 +0000 | [diff] [blame] | 242 | , 'change_delete', 'contents', 'index', 'modules', 'blank'); |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 243 | |
| 244 | if ($icon =~ /(gif|png)$/) { |
| 245 | $used_icons{$icon} = 1; |
| 246 | if ($icon =~ /change_(begin|end|delete)_right/) { $align = ' ' }; |
| 247 | my $nav_border = "$NAV_BORDER"; |
| 248 | if ($icon =~ /($alt)/) { |
| 249 | $alt = $1; |
Fred Drake | aa99a50 | 1999-03-03 16:21:34 +0000 | [diff] [blame] | 250 | $alt = "" |
| 251 | if ($alt eq "blank"); |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 252 | } |
| 253 | else { |
| 254 | $nav_border = '1'; |
| 255 | $alt = '[*]'; |
| 256 | }; |
| 257 | if ($LOCAL_ICONS) { |
| 258 | return join('', '<img ', $iconsizes{$1}, $align |
| 259 | ,'border=', $nav_border, ' alt="', $alt |
| 260 | ,'" src="', $icon, '">' ); |
| 261 | } |
Fred Drake | d3d28d3 | 1999-09-23 15:29:45 +0000 | [diff] [blame] | 262 | my $s = join('', '<img ', $iconsizes{$1}, $align, |
| 263 | 'border=', $nav_border, ' alt="', $alt, "\"\n", |
| 264 | ' src="', $ICONSERVER, "/$icon", '">' ); |
| 265 | # if $ICONSERVER starts with "./", remove "./": |
| 266 | $s =~ s|src="(.\/)+|src="|; |
| 267 | return $s; |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 268 | } |
| 269 | else { |
| 270 | return $icon; |
| 271 | } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | |
Fred Drake | 50cdd97 | 1999-02-19 23:04:59 +0000 | [diff] [blame] | 275 | sub do_cmd_arabic { |
| 276 | # get rid of that nasty <SPAN CLASS="arabic">...</SPAN> |
| 277 | local($ctr, $val, $id, $_) = &read_counter_value(@_[0]); |
| 278 | return ($val ? &farabic($val) : "0") . $_; |
| 279 | } |
| 280 | |
| 281 | |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 282 | sub gen_index_id { |
| 283 | # this is used to ensure common index key generation and a stable sort |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 284 | my($str,$extra) = @_; |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 285 | sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'}); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 288 | sub insert_index{ |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 289 | my($mark,$datafile,$columns,$letters,$prefix) = @_; |
Fred Drake | 4d10b43 | 1998-08-07 20:51:58 +0000 | [diff] [blame] | 290 | my $prog = "$myrootdir/tools/buildindex.py"; |
| 291 | my $index; |
| 292 | if ($letters) { |
| 293 | $index = `$prog --columns $columns --letters $datafile`; |
| 294 | } |
| 295 | else { |
| 296 | $index = `$prog --columns $columns $datafile`; |
| 297 | } |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 298 | s/$mark/$prefix$index/; |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 299 | } |
| 300 | |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 301 | sub add_idx{ |
Fred Drake | 9bbdce5 | 1999-01-19 16:30:10 +0000 | [diff] [blame] | 302 | print "\nBuilding HTML for the index ..."; |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 303 | close(IDXFILE); |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 304 | insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, ''); |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 305 | } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 306 | |
| 307 | |
| 308 | $idx_module_mark = '<tex2html_idx_module_mark>'; |
| 309 | $idx_module_title = 'Module Index'; |
| 310 | |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 311 | sub add_module_idx{ |
Fred Drake | 9bbdce5 | 1999-01-19 16:30:10 +0000 | [diff] [blame] | 312 | print "\nBuilding HTML for the module index ..."; |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 313 | my $key; |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 314 | my $first = 1; |
| 315 | my $prevplat = ''; |
| 316 | my $allthesame = 1; |
| 317 | my $prefix = ''; |
| 318 | foreach $key (keys %Modules) { |
| 319 | $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/; |
| 320 | my $plat = "$ModulePlatforms{$key}"; |
| 321 | $plat = '' |
Fred Drake | 62cc360 | 1999-03-04 18:41:17 +0000 | [diff] [blame] | 322 | if ($plat eq $IGNORE_PLATFORM_ANNOTATION); |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 323 | if (!$first) { |
| 324 | $allthesame = 0 |
| 325 | if ($prevplat ne $plat); |
| 326 | } |
| 327 | else { $first = 0; } |
| 328 | $prevplat = $plat; |
| 329 | } |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 330 | open(MODIDXFILE, '>modindex.dat') || die "\n$!\n"; |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 331 | foreach $key (keys %Modules) { |
| 332 | # dump the line in the data file; just use a dummy seqno field |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 333 | my $nkey = $1; |
| 334 | my $moditem = "$Modules{$key}"; |
| 335 | my $plat = ''; |
| 336 | $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/; |
| 337 | if ($ModulePlatforms{$key} && !$allthesame) { |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 338 | $plat = (" <em>(<span class='platform'>$ModulePlatforms{$key}" |
Fred Drake | bb584d3 | 1999-03-25 22:18:30 +0000 | [diff] [blame] | 339 | . '</span>)</em>'); |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 340 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 341 | print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP |
| 342 | . "<tt class='module'>$key</tt>$plat###\n"; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 343 | } |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 344 | close(MODIDXFILE); |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 345 | if (!$allthesame) { |
| 346 | $prefix = <<PLAT_DISCUSS; |
| 347 | |
| 348 | |
| 349 | <p> Some module names are followed by an annotation indicating what |
| 350 | platform they are available on.</p> |
| 351 | |
| 352 | PLAT_DISCUSS |
| 353 | } |
| 354 | insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0, |
| 355 | $prefix); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 356 | } |
| 357 | |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 358 | # replace both indexes as needed: |
| 359 | sub add_idx_hook{ |
Fred Drake | b3a3ed8 | 1998-07-24 22:17:34 +0000 | [diff] [blame] | 360 | add_idx() if (/$idx_mark/); |
| 361 | add_module_idx() if (/$idx_module_mark/); |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 362 | process_python_state(); |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 363 | } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 364 | |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 365 | |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 366 | # In addition to the standard stuff, add label to allow named node files and |
| 367 | # support suppression of the page complete (for HTML Help use). |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 368 | sub do_cmd_tableofcontents { |
| 369 | local($_) = @_; |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 370 | # if ($SUPPRESS_CONTENTS) { |
| 371 | # return $_; |
| 372 | # } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 373 | $TITLE = $toc_title; |
| 374 | $tocfile = $CURRENT_FILE; |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 375 | my($closures,$reopens) = preserve_open_tags(); |
| 376 | anchor_label('contents', $CURRENT_FILE, $_); # this is added |
Fred Drake | beb27bf | 1999-02-16 17:22:32 +0000 | [diff] [blame] | 377 | join('', "<BR>\n\\tableofchildlinks[off]", $closures |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 378 | , make_section_heading($toc_title, 'H2'), $toc_mark |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 379 | , $reopens, $_); |
| 380 | } |
| 381 | # In addition to the standard stuff, add label to allow named node files. |
| 382 | sub do_cmd_listoffigures { |
| 383 | local($_) = @_; |
| 384 | $TITLE = $lof_title; |
| 385 | $loffile = $CURRENT_FILE; |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 386 | my($closures,$reopens) = preserve_open_tags(); |
| 387 | anchor_label('lof', $CURRENT_FILE, $_); # this is added |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 388 | join('', "<BR>\n", $closures |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 389 | , make_section_heading($lof_title, 'H2'), $lof_mark |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 390 | , $reopens, $_); |
| 391 | } |
| 392 | # In addition to the standard stuff, add label to allow named node files. |
| 393 | sub do_cmd_listoftables { |
| 394 | local($_) = @_; |
| 395 | $TITLE = $lot_title; |
| 396 | $lotfile = $CURRENT_FILE; |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 397 | my($closures,$reopens) = preserve_open_tags(); |
| 398 | anchor_label('lot', $CURRENT_FILE, $_); # this is added |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 399 | join('', "<BR>\n", $closures |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 400 | , make_section_heading($lot_title, 'H2'), $lot_mark |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 401 | , $reopens, $_); |
| 402 | } |
| 403 | # In addition to the standard stuff, add label to allow named node files. |
| 404 | sub do_cmd_textohtmlinfopage { |
| 405 | local($_) = @_; |
| 406 | if ($INFO) { # |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 407 | anchor_label("about",$CURRENT_FILE,$_); # this is added |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 408 | } # |
Fred Drake | 15796f7 | 1998-11-30 19:25:47 +0000 | [diff] [blame] | 409 | my $the_version = ''; # and the rest is |
| 410 | if ($t_date) { # mostly ours |
| 411 | $the_version = ",\n$t_date"; |
| 412 | if ($PYTHON_VERSION) { |
| 413 | $the_version .= ", Release $PYTHON_VERSION"; |
| 414 | } |
| 415 | } |
| 416 | $_ = (($INFO == 1) |
Fred Drake | b35f2b7 | 1999-09-23 16:53:09 +0000 | [diff] [blame] | 417 | ? join('', |
| 418 | $close_all, |
| 419 | "<strong>$t_title</strong>$the_version\n", |
| 420 | `cat $ABOUT_FILE`, |
| 421 | $open_all, $_) |
| 422 | : join('', $close_all, $INFO,"\n", $open_all, $_)); |
Fred Drake | 15796f7 | 1998-11-30 19:25:47 +0000 | [diff] [blame] | 423 | $_; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | # $idx_mark will be replaced with the real index at the end |
| 427 | sub do_cmd_textohtmlindex { |
| 428 | local($_) = @_; |
| 429 | $TITLE = $idx_title; |
| 430 | $idxfile = $CURRENT_FILE; |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 431 | if (%index_labels) { make_index_labels(); } |
| 432 | if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 433 | else { $preindex = ''; } |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 434 | my $heading = make_section_heading($idx_title, 'h2') . $idx_mark; |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 435 | my($pre,$post) = minimize_open_tags($heading); |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 436 | anchor_label('genindex',$CURRENT_FILE,$_); # this is added |
| 437 | '<br>\n' . $pre . $_; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | # $idx_module_mark will be replaced with the real index at the end |
| 441 | sub do_cmd_textohtmlmoduleindex { |
| 442 | local($_) = @_; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 443 | $TITLE = $idx_module_title; |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 444 | anchor_label("modindex",$CURRENT_FILE,$_); |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 445 | '<p>' . make_section_heading($idx_module_title, "h2") |
| 446 | . $idx_module_mark . $_; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | # The bibliography and the index should be treated as separate sections |
| 450 | # in their own HTML files. The \bibliography{} command acts as a sectioning command |
| 451 | # that has the desired effect. But when the bibliography is constructed |
| 452 | # manually using the thebibliography environment, or when using the |
| 453 | # theindex environment it is not possible to use the normal sectioning |
| 454 | # mechanism. This subroutine inserts a \bibliography{} or a dummy |
| 455 | # \textohtmlindex command just before the appropriate environments |
| 456 | # to force sectioning. |
| 457 | |
| 458 | # XXX This *assumes* that if there are two {theindex} environments, the |
| 459 | # first is the module index and the second is the standard index. This |
| 460 | # is sufficient for the current Python documentation, but that's about |
| 461 | # it. |
| 462 | |
| 463 | sub add_bbl_and_idx_dummy_commands { |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 464 | my $id = $global{'max_id'}; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 465 | |
| 466 | s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg; |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 467 | s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo; |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 468 | #---------------------------------------------------------------------- |
| 469 | # (FLD) This was added |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 470 | if ($SUPPRESS_INDEXES) { |
| 471 | $CUSTOM_BUTTONS .= img_tag('blank.' . $IMAGE_TYPE); |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 472 | } |
| 473 | else { |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 474 | my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/); |
| 475 | if (scalar(@parts) == 3) { |
| 476 | # Be careful to re-write the string in place, since $_ is *not* |
| 477 | # returned explicity; *** nasty side-effect dependency! *** |
| 478 | print "\nadd_bbl_and_idx_dummy_commands ==> adding module index"; |
| 479 | my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)" |
| 480 | . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)"; |
| 481 | s/$rx/\\textohtmlmoduleindex \1 \\textohtmlindex \2/o; |
| 482 | # Add a button to the navigation areas: |
| 483 | $CUSTOM_BUTTONS .= ("<a\n href=\"modindex.html\">" |
| 484 | . img_tag('modules.'.$IMAGE_TYPE) . "</a>"); |
| 485 | } |
| 486 | else { |
| 487 | $CUSTOM_BUTTONS .= img_tag('blank.' . $IMAGE_TYPE); |
| 488 | $global{'max_id'} = $id; # not sure why.... |
| 489 | s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o; |
| 490 | s/[\\]printindex/\\textohtmlindex /o; |
| 491 | } |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 492 | } |
| 493 | #---------------------------------------------------------------------- |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 494 | lib_add_bbl_and_idx_dummy_commands() |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 495 | if defined(&lib_add_bbl_and_idx_dummy_commands); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | # The bibliographic references, the appendices, the lists of figures and tables |
| 499 | # etc. must appear in the contents table at the same level as the outermost |
| 500 | # sectioning command. This subroutine finds what is the outermost level and |
| 501 | # sets the above to the same level; |
| 502 | |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 503 | sub set_depth_levels { |
| 504 | # Sets $outermost_level |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 505 | my $level; |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 506 | #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH |
| 507 | foreach $level ("part", "chapter", "section", "subsection", |
| 508 | "subsubsection", "paragraph") { |
| 509 | last if (($outermost_level) = /\\($level)$delimiter_rx/); |
| 510 | } |
| 511 | $level = ($outermost_level ? $section_commands{$outermost_level} : |
| 512 | do {$outermost_level = 'section'; 3;}); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 513 | |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 514 | #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given |
| 515 | if ($REL_DEPTH && $MAX_SPLIT_DEPTH) { |
| 516 | $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH; |
| 517 | } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 }; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 518 | |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 519 | %unnumbered_section_commands = ('tableofcontents' => $level, |
| 520 | 'listoffigures' => $level, |
| 521 | 'listoftables' => $level, |
| 522 | 'bibliography' => $level, |
| 523 | 'textohtmlindex' => $level, |
| 524 | 'textohtmlmoduleindex' => $level); |
| 525 | $section_headings{'textohtmlmoduleindex'} = 'h1'; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 526 | |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 527 | %section_commands = (%unnumbered_section_commands, |
| 528 | %section_commands); |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 529 | |
| 530 | make_sections_rx(); |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 531 | } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 532 | |
| 533 | |
| 534 | # Fix from Ross Moore for ']' in \item[...]; this can be removed once the next |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 535 | # patch to LaTeX2HTML is released and tested ... if the patch gets included. |
| 536 | # Be very careful to keep this around, just in case things break again! |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 537 | # |
| 538 | sub protect_useritems { |
| 539 | local(*_) = @_; |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 540 | local($preitems,$thisitem); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 541 | while (/\\item\s*\[/) { |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 542 | $preitems .= $`; |
| 543 | $_ = $'; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 544 | $thisitem = $&.'<<'.++$global{'max_id'}.'>>'; |
| 545 | s/^(((($O|$OP)\d+($C|$CP)).*\3|<[^<>]*>|[^\]<]+)*)\]/$thisitem.=$1;''/e; |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 546 | $preitems .= $thisitem . '<<' . $global{'max_id'} . '>>]'; |
| 547 | s/^]//; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 548 | } |
| 549 | $_ = $preitems . $_; |
| 550 | } |
| 551 | |
Fred Drake | 1072e46 | 1998-04-12 02:16:34 +0000 | [diff] [blame] | 552 | # This changes the markup used for {verbatim} environments, and is the |
Fred Drake | 95474f9 | 1999-02-09 18:45:50 +0000 | [diff] [blame] | 553 | # best way I've found that ensures the <dl> goes on the outside of the |
Fred Drake | 1072e46 | 1998-04-12 02:16:34 +0000 | [diff] [blame] | 554 | # <pre>...</pre>. |
| 555 | # |
| 556 | # Note that this *must* be done in the init file, not the python.perl |
| 557 | # style support file. The %declarations must be set before initialize() |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 558 | # is called in the main LaTeX2HTML script (which happens before style files |
| 559 | # are loaded). |
Fred Drake | 1072e46 | 1998-04-12 02:16:34 +0000 | [diff] [blame] | 560 | # |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 561 | %declarations = ('preform' => '<dl><dd><pre class="verbatim"></pre></dl>', |
Fred Drake | 1072e46 | 1998-04-12 02:16:34 +0000 | [diff] [blame] | 562 | %declarations); |
| 563 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 564 | |
| 565 | # This is added to get rid of the long comment that follows the doctype |
| 566 | # declaration; MSIE5 on NT4 SP4 barfs on it and drops the content of the |
| 567 | # page. |
| 568 | sub make_head_and_body { |
| 569 | local($title,$body) = @_; |
| 570 | local($DTDcomment) = ''; |
| 571 | local($version,$isolanguage) = ($HTML_VERSION, 'EN'); |
| 572 | local(%isolanguages) = ( 'english', 'EN' , 'USenglish', 'EN.US' |
| 573 | , 'original', 'EN' , 'german' , 'DE' |
| 574 | , 'austrian', 'DE.AT', 'french' , 'FR' |
| 575 | , 'spanish', 'ES' |
| 576 | , %isolanguages ); |
| 577 | $isolanguage = $isolanguages{$default_language}; |
| 578 | $isolanguage = 'EN' unless $isolanguage; |
| 579 | $title = &purify($title,1); |
| 580 | eval("\$title = ". $default_title ) unless ($title); |
| 581 | |
| 582 | # allow user-modification of the <TITLE> tag; thanks Dan Young |
| 583 | if (defined &custom_TITLE_hook) { |
| 584 | $title = &custom_TITLE_hook($title, $toc_sec_title); |
| 585 | } |
| 586 | |
| 587 | if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included |
| 588 | $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n"; |
| 589 | } else { |
| 590 | $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//" |
| 591 | . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n"; |
| 592 | } |
| 593 | |
| 594 | $STYLESHEET = $FILE.".css" unless $STYLESHEET; |
| 595 | if (!$charset && $CHARSET) { $charset = $CHARSET; $charset =~ s/_/\-/go; } |
| 596 | |
| 597 | join('', ($DOCTYPE ? $DTDcomment : '' ) |
| 598 | ,"<html>\n<head>\n<title>", $title, "</title>\n" |
| 599 | , &meta_information($title) |
| 600 | , ($CHARSET && $HTML_VERSION ge "2.1" ? |
| 601 | "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$charset\">\n" |
| 602 | : "" ) |
| 603 | , ($BASE ? "<base href=\"$BASE\">\n" : "" ) |
| 604 | , "<link rel=\"STYLESHEET\" href=\"$STYLESHEET\">" |
| 605 | , $more_links_mark |
| 606 | , "\n</head>\n<body $body>\n"); |
| 607 | } |
| 608 | |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 609 | 1; # This must be the last line |