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