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