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