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