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