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