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