Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 1 | # LaTeX2HTML support base for use with Python documentation. |
Fred Drake | 41814bc | 1998-05-11 18:23:35 +0000 | [diff] [blame] | 2 | |
| 3 | package main; |
| 4 | |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 5 | use L2hos; |
| 6 | |
Fred Drake | 28e7b4c | 1998-10-20 18:14:20 +0000 | [diff] [blame] | 7 | $HTML_VERSION = 4.0; |
| 8 | |
Fred Drake | 6aa5d48 | 1998-08-11 03:14:50 +0000 | [diff] [blame] | 9 | $MAX_LINK_DEPTH = 2; |
Fred Drake | d757165 | 1998-04-23 20:06:24 +0000 | [diff] [blame] | 10 | $ADDRESS = ''; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 11 | |
Fred Drake | e194beb | 1998-05-19 19:38:49 +0000 | [diff] [blame] | 12 | $NO_FOOTNODE = 1; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 13 | $NUMBERED_FOOTNOTES = 1; |
| 14 | |
| 15 | # Python documentation uses section numbers to support references to match |
| 16 | # in the printed and online versions. |
| 17 | # |
| 18 | $SHOW_SECTION_NUMBERS = 1; |
| 19 | |
Fred Drake | 15a159c | 2002-10-01 15:20:20 +0000 | [diff] [blame] | 20 | $ICONSERVER = '.'; |
Fred Drake | f730fc3 | 2000-08-31 07:19:07 +0000 | [diff] [blame] | 21 | $IMAGE_TYPE = 'gif'; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 22 | |
Fred Drake | 6aa5d48 | 1998-08-11 03:14:50 +0000 | [diff] [blame] | 23 | # Control where the navigation bars should show up: |
| 24 | $TOP_NAVIGATION = 1; |
| 25 | $BOTTOM_NAVIGATION = 1; |
| 26 | $AUTO_NAVIGATION = 0; |
| 27 | |
Fred Drake | 1681627 | 2000-09-16 20:40:44 +0000 | [diff] [blame] | 28 | $BODYTEXT = ''; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 29 | $CHILDLINE = "\n<p></p><hr />\n"; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 30 | $VERBOSITY = 0; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 31 | |
Fred Drake | 4d10b43 | 1998-08-07 20:51:58 +0000 | [diff] [blame] | 32 | # default # of columns for the indexes |
Fred Drake | aa3f9fb | 1998-08-07 19:52:37 +0000 | [diff] [blame] | 33 | $INDEX_COLUMNS = 2; |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 34 | $MODULE_INDEX_COLUMNS = 4; |
Fred Drake | aa3f9fb | 1998-08-07 19:52:37 +0000 | [diff] [blame] | 35 | |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 36 | $HAVE_MODULE_INDEX = 0; |
| 37 | $HAVE_GENERAL_INDEX = 0; |
| 38 | $HAVE_TABLE_OF_CONTENTS = 0; |
| 39 | |
Fred Drake | e03e1fe | 2002-04-05 17:34:50 +0000 | [diff] [blame] | 40 | $AESOP_META_TYPE = 'information'; |
| 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, |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 44 | # and not be tied to the current directory (as far as I can tell). Testing |
| 45 | # an existing definition of $mydir is needed since it cannot be computed when |
| 46 | # run under mkhowto with recent versions of LaTeX2HTML, since this file is |
| 47 | # not read directly by LaTeX2HTML any more. mkhowto is required to prepend |
| 48 | # the required definition at the top of the actual input file. |
Fred Drake | db34a1e | 1998-03-10 23:02:57 +0000 | [diff] [blame] | 49 | # |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 50 | if (!defined $mydir) { |
| 51 | use Cwd; |
| 52 | use File::Basename; |
| 53 | ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*'); |
| 54 | chop $mydir; # remove trailing '/' |
| 55 | $mydir = getcwd() . "$dd$mydir" |
| 56 | unless $mydir =~ s|^/|/|; |
| 57 | } |
Fred Drake | db34a1e | 1998-03-10 23:02:57 +0000 | [diff] [blame] | 58 | $LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES"; |
Fred Drake | b3a3ed8 | 1998-07-24 22:17:34 +0000 | [diff] [blame] | 59 | push (@INC, $mydir); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 60 | |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 61 | ($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*'); |
| 62 | chop $myrootdir; |
| 63 | |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 64 | |
Fred Drake | a4565b0 | 1998-05-15 17:14:17 +0000 | [diff] [blame] | 65 | # Hackish way to get the appropriate paper-*/ directory into $TEXINPUTS; |
| 66 | # pass in the paper size (a4 or letter) as the environment variable PAPER |
| 67 | # to add the right directory. If not given, the current directory is |
| 68 | # added instead for use with HOWTO processing. |
| 69 | # |
| 70 | if (defined $ENV{'PAPER'}) { |
| 71 | $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey"; |
| 72 | } |
| 73 | else { |
| 74 | $mytexinputs = getcwd() . $envkey; |
| 75 | } |
| 76 | $mytexinputs .= "$myrootdir${dd}texinputs"; |
| 77 | |
| 78 | |
Fred Drake | b35f2b7 | 1999-09-23 16:53:09 +0000 | [diff] [blame] | 79 | # Change this variable to change the text added in "About this document..."; |
| 80 | # this should be an absolute pathname to get it right. |
| 81 | # |
| 82 | $ABOUT_FILE = "$myrootdir${dd}html${dd}stdabout.dat"; |
| 83 | |
| 84 | |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 85 | sub custom_driver_hook { |
Fred Drake | a4565b0 | 1998-05-15 17:14:17 +0000 | [diff] [blame] | 86 | # |
| 87 | # This adds the directory of the main input file to $TEXINPUTS; it |
| 88 | # seems to be sufficiently general that it should be fine for HOWTO |
| 89 | # processing. |
| 90 | # |
Fred Drake | 73c5b660 | 2002-10-24 16:36:05 +0000 | [diff] [blame] | 91 | my $file = $_[0]; |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 92 | my($jobname, $dir, $ext) = fileparse($file, '\..*'); |
| 93 | $dir = L2hos->Make_directory_absolute($dir); |
Fred Drake | a4565b0 | 1998-05-15 17:14:17 +0000 | [diff] [blame] | 94 | $dir =~ s/$dd$//; |
| 95 | $TEXINPUTS = "$dir$envkey$mytexinputs"; |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 96 | print "\nAdding $dir to \$TEXINPUTS\n"; |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Fred Drake | a4565b0 | 1998-05-15 17:14:17 +0000 | [diff] [blame] | 99 | |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 100 | $CUSTOM_BUTTONS = ''; |
Fred Drake | 062bc6e | 1998-08-13 22:03:46 +0000 | [diff] [blame] | 101 | |
Fred Drake | bf8ec3e | 2003-05-02 20:18:01 +0000 | [diff] [blame] | 102 | sub make_nav_sectref($$$) { |
| 103 | my($label, $linktype, $title) = @_; |
Fred Drake | beb27bf | 1999-02-16 17:22:32 +0000 | [diff] [blame] | 104 | if ($title) { |
Fred Drake | 02c7082 | 2000-09-19 15:36:19 +0000 | [diff] [blame] | 105 | if ($title =~ /\<[aA] /) { |
Fred Drake | bf8ec3e | 2003-05-02 20:18:01 +0000 | [diff] [blame] | 106 | $title =~ s/\<[aA] /<a class="sectref" rel="$linktype" /; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 107 | $title =~ s/ HREF=/ href=/; |
Fred Drake | 02c7082 | 2000-09-19 15:36:19 +0000 | [diff] [blame] | 108 | } |
| 109 | else { |
| 110 | $title = "<span class=\"sectref\">$title</span>"; |
| 111 | } |
Fred Drake | bf8ec3e | 2003-05-02 20:18:01 +0000 | [diff] [blame] | 112 | return "<b class=\"navlabel\">$label:</b>\n$title\n"; |
Fred Drake | beb27bf | 1999-02-16 17:22:32 +0000 | [diff] [blame] | 113 | } |
| 114 | return ''; |
| 115 | } |
| 116 | |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 117 | @my_icon_tags = (); |
| 118 | $my_icon_tags{'next'} = 'Next Page'; |
| 119 | $my_icon_tags{'next_page'} = 'Next Page'; |
| 120 | $my_icon_tags{'previous'} = 'Previous Page'; |
| 121 | $my_icon_tags{'previous_page'} = 'Previous Page'; |
| 122 | $my_icon_tags{'up'} = 'Up One Level'; |
| 123 | $my_icon_tags{'contents'} = 'Contents'; |
| 124 | $my_icon_tags{'index'} = 'Index'; |
| 125 | $my_icon_tags{'modules'} = 'Module Index'; |
| 126 | |
Fred Drake | b31d36c | 2001-01-04 15:16:01 +0000 | [diff] [blame] | 127 | @my_icon_names = (); |
| 128 | $my_icon_names{'previous_page'} = 'previous'; |
| 129 | $my_icon_names{'next_page'} = 'next'; |
| 130 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 131 | sub get_my_icon($) { |
Fred Drake | 73c5b660 | 2002-10-24 16:36:05 +0000 | [diff] [blame] | 132 | my $name = $_[0]; |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 133 | my $text = $my_icon_tags{$name}; |
Fred Drake | b31d36c | 2001-01-04 15:16:01 +0000 | [diff] [blame] | 134 | if ($my_icon_names{$name}) { |
| 135 | $name = $my_icon_names{$name}; |
| 136 | } |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 137 | if ($text eq '') { |
| 138 | $name = 'blank'; |
| 139 | } |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 140 | my $iconserver = ($ICONSERVER eq '.') ? '' : "$ICONSERVER/"; |
Fred Drake | dd3d6a0 | 2002-10-30 17:00:58 +0000 | [diff] [blame] | 141 | return "<img src='$iconserver$name.$IMAGE_TYPE'\n border='0'" |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 142 | . " height='32' alt='$text' width='32' />"; |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Fred Drake | 8b34e7c | 2003-05-03 02:07:22 +0000 | [diff] [blame] | 145 | sub unlinkify($) { |
| 146 | my $text = "$_[0]"; |
| 147 | $text =~ s|</[aA]>||; |
| 148 | $text =~ s|<a\s+[^>]*>||i; |
| 149 | return $text; |
| 150 | } |
| 151 | |
| 152 | sub use_icon($$$) { |
| 153 | my($rel,$str,$title) = @_; |
| 154 | if ($title) { |
| 155 | my $s = "$str"; |
| 156 | if ($s =~ /\<tex2html_([a-z_]+)_visible_mark\>/) { |
| 157 | my $r = get_my_icon($1); |
| 158 | $s =~ s/\<tex2html_[a-z_]+_visible_mark\>/$r/; |
| 159 | } |
| 160 | $s =~ s/<[aA] /<a rel="$rel" title="$title" \n /; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 161 | $s =~ s/ HREF=/ href=/; |
Fred Drake | 8b34e7c | 2003-05-03 02:07:22 +0000 | [diff] [blame] | 162 | return $s; |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 163 | } |
Fred Drake | 8b34e7c | 2003-05-03 02:07:22 +0000 | [diff] [blame] | 164 | else { |
| 165 | return get_my_icon('blank'); |
| 166 | } |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 169 | sub make_nav_panel() { |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 170 | my $s; |
Fred Drake | 8b34e7c | 2003-05-03 02:07:22 +0000 | [diff] [blame] | 171 | # new iconic rel iconic page title |
| 172 | $NEXT = use_icon('next', $NEXT, unlinkify($NEXT_TITLE)); |
| 173 | $UP = use_icon('parent', $UP, unlinkify($UP_TITLE)); |
| 174 | $PREVIOUS = use_icon('prev', $PREVIOUS, unlinkify($PREVIOUS_TITLE)); |
| 175 | $CONTENTS = use_icon('contents', $CONTENTS, 'Table of Contents'); |
| 176 | $INDEX = use_icon('index', $INDEX, 'Index'); |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 177 | if (!$CUSTOM_BUTTONS) { |
Fred Drake | 8b34e7c | 2003-05-03 02:07:22 +0000 | [diff] [blame] | 178 | $CUSTOM_BUTTONS = get_my_icon('blank'); |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 179 | } |
| 180 | $s = ('<table align="center" width="100%" cellpadding="0" cellspacing="2">' |
| 181 | . "\n<tr>" |
| 182 | # left-hand side |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 183 | . "\n<td>$PREVIOUS</td>" |
Fred Drake | 4640e13 | 2000-07-31 20:13:23 +0000 | [diff] [blame] | 184 | . "\n<td>$UP</td>" |
| 185 | . "\n<td>$NEXT</td>" |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 186 | # title box |
Fred Drake | f730fc3 | 2000-08-31 07:19:07 +0000 | [diff] [blame] | 187 | . "\n<td align=\"center\" width=\"100%\">$t_title</td>" |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 188 | # right-hand side |
| 189 | . "\n<td>$CONTENTS</td>" |
| 190 | . "\n<td>$CUSTOM_BUTTONS</td>" # module index |
| 191 | . "\n<td>$INDEX</td>" |
| 192 | . "\n</tr></table>\n" |
| 193 | # textual navigation |
Fred Drake | bf8ec3e | 2003-05-02 20:18:01 +0000 | [diff] [blame] | 194 | . make_nav_sectref("Previous", "prev", $PREVIOUS_TITLE) |
| 195 | . make_nav_sectref("Up", "parent", $UP_TITLE) |
| 196 | . make_nav_sectref("Next", "next", $NEXT_TITLE) |
Fred Drake | 4640e13 | 2000-07-31 20:13:23 +0000 | [diff] [blame] | 197 | ); |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 198 | # remove these; they are unnecessary and cause errors from validation |
| 199 | $s =~ s/ NAME="tex2html\d+"\n */ /g; |
| 200 | return $s; |
| 201 | } |
| 202 | |
Fred Drake | fb6499f | 2001-10-26 14:16:23 +0000 | [diff] [blame] | 203 | sub add_child_links { |
| 204 | my $toc = add_real_child_links(@_); |
| 205 | $toc =~ s|\s*</[aA]>|</a>|g; |
| 206 | $toc =~ s/ NAME=\"tex2html\d+\"\s*href=/ href=/gi; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 207 | $toc =~ s|</UL>(\s*<BR( /)?>)?|</ul>|gi; |
Fred Drake | fb6499f | 2001-10-26 14:16:23 +0000 | [diff] [blame] | 208 | return $toc; |
| 209 | } |
| 210 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 211 | sub get_version_text() { |
Fred Drake | 7497bd3 | 2000-10-25 16:18:10 +0000 | [diff] [blame] | 212 | if ($PACKAGE_VERSION ne '' && $t_date) { |
| 213 | return ("<span class=\"release-info\">" |
Fred Drake | dce975c | 2001-06-20 21:31:36 +0000 | [diff] [blame] | 214 | . "Release $PACKAGE_VERSION$RELEASE_INFO," |
Fred Drake | 7497bd3 | 2000-10-25 16:18:10 +0000 | [diff] [blame] | 215 | . " documentation updated on $t_date.</span>"); |
| 216 | } |
| 217 | if ($PACKAGE_VERSION ne '') { |
| 218 | return ("<span class=\"release-info\">" |
Fred Drake | dce975c | 2001-06-20 21:31:36 +0000 | [diff] [blame] | 219 | . "Release $PACKAGE_VERSION$RELEASE_INFO.</span>"); |
Fred Drake | 7497bd3 | 2000-10-25 16:18:10 +0000 | [diff] [blame] | 220 | } |
| 221 | if ($t_date) { |
| 222 | return ("<span class=\"release-info\">Documentation released on " |
| 223 | . "$t_date.</span>"); |
| 224 | } |
| 225 | return ''; |
| 226 | } |
| 227 | |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 228 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 229 | sub top_navigation_panel() { |
Fred Drake | 7497bd3 | 2000-10-25 16:18:10 +0000 | [diff] [blame] | 230 | return "\n" |
| 231 | . make_nav_panel() |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 232 | . "<br /><hr />\n"; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 233 | } |
| 234 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 235 | sub bot_navigation_panel() { |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 236 | return "\n<p></p><hr />\n" |
Fred Drake | 7497bd3 | 2000-10-25 16:18:10 +0000 | [diff] [blame] | 237 | . make_nav_panel() |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 238 | . "<hr />\n" |
Fred Drake | 7497bd3 | 2000-10-25 16:18:10 +0000 | [diff] [blame] | 239 | . get_version_text() |
| 240 | . "\n"; |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | sub add_link { |
| 244 | # Returns a pair (iconic link, textual link) |
| 245 | my($icon, $current_file, @link) = @_; |
| 246 | my($dummy, $file, $title) = split($delim, |
Fred Drake | 28e7b4c | 1998-10-20 18:14:20 +0000 | [diff] [blame] | 247 | $section_info{join(' ',@link)}); |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 248 | if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) { |
| 249 | my $r = get_my_icon($1); |
| 250 | $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/; |
| 251 | } |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 252 | if ($title && ($file ne $current_file)) { |
| 253 | $title = purify($title); |
| 254 | $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES); |
| 255 | return (make_href($file, $icon), make_href($file, "$title")) |
| 256 | } |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 257 | elsif ($icon eq get_my_icon('up') && $EXTERNAL_UP_LINK) { |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 258 | return (make_href($EXTERNAL_UP_LINK, $icon), |
| 259 | make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE")) |
| 260 | } |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 261 | elsif ($icon eq get_my_icon('previous') |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 262 | && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) { |
| 263 | return (make_href($EXTERNAL_PREV_LINK, $icon), |
| 264 | make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE")) |
| 265 | } |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 266 | elsif ($icon eq get_my_icon('next') |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 267 | && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) { |
| 268 | return (make_href($EXTERNAL_DOWN_LINK, $icon), |
| 269 | make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE")) |
| 270 | } |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 271 | return (&inactive_img($icon), ""); |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 272 | } |
| 273 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 274 | sub add_special_link($$$) { |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 275 | my($icon, $file, $current_file) = @_; |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 276 | if ($icon =~ /\<tex2html_([_a-z]+)_visible_mark\>/) { |
| 277 | my $r = get_my_icon($1); |
| 278 | $icon =~ s/\<tex2html_[_a-z]+_visible_mark\>/$r/; |
| 279 | } |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 280 | return (($file && ($file ne $current_file)) |
| 281 | ? make_href($file, $icon) |
| 282 | : undef) |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 283 | } |
| 284 | |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 285 | # The img_tag() function seems only to be called with the parameter |
| 286 | # 'anchor_invisible_mark', which we want to turn into ''. Since |
| 287 | # replace_icon_marks() is the only interesting caller, and all it really |
| 288 | # does is call img_tag(), we can just define the hook alternative to be |
| 289 | # a no-op instead. |
| 290 | # |
| 291 | sub replace_icons_hook {} |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 292 | |
Fred Drake | 50cdd97 | 1999-02-19 23:04:59 +0000 | [diff] [blame] | 293 | sub do_cmd_arabic { |
| 294 | # get rid of that nasty <SPAN CLASS="arabic">...</SPAN> |
Fred Drake | 73c5b660 | 2002-10-24 16:36:05 +0000 | [diff] [blame] | 295 | my($ctr, $val, $id, $text) = &read_counter_value($_[0]); |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 296 | return ($val ? farabic($val) : "0") . $text; |
Fred Drake | 50cdd97 | 1999-02-19 23:04:59 +0000 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 300 | sub gen_index_id($$) { |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 301 | # this is used to ensure common index key generation and a stable sort |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 302 | my($str, $extra) = @_; |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 303 | sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'}); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 304 | } |
| 305 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 306 | sub insert_index($$$$$) { |
| 307 | my($mark, $datafile, $columns, $letters, $prefix) = @_; |
Fred Drake | 4d10b43 | 1998-08-07 20:51:58 +0000 | [diff] [blame] | 308 | my $prog = "$myrootdir/tools/buildindex.py"; |
| 309 | my $index; |
| 310 | if ($letters) { |
| 311 | $index = `$prog --columns $columns --letters $datafile`; |
| 312 | } |
| 313 | else { |
| 314 | $index = `$prog --columns $columns $datafile`; |
| 315 | } |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 316 | if (!s/$mark/$prefix$index/) { |
| 317 | print "\nCould not locate index mark: $mark"; |
| 318 | } |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 319 | } |
| 320 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 321 | sub add_idx() { |
Fred Drake | 9bbdce5 | 1999-01-19 16:30:10 +0000 | [diff] [blame] | 322 | print "\nBuilding HTML for the index ..."; |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 323 | close(IDXFILE); |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 324 | insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, ''); |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 325 | } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 326 | |
| 327 | |
| 328 | $idx_module_mark = '<tex2html_idx_module_mark>'; |
| 329 | $idx_module_title = 'Module Index'; |
| 330 | |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 331 | sub add_module_idx() { |
Fred Drake | 9bbdce5 | 1999-01-19 16:30:10 +0000 | [diff] [blame] | 332 | print "\nBuilding HTML for the module index ..."; |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 333 | my $key; |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 334 | my $first = 1; |
| 335 | my $prevplat = ''; |
| 336 | my $allthesame = 1; |
| 337 | my $prefix = ''; |
| 338 | foreach $key (keys %Modules) { |
Fred Drake | 73c5b660 | 2002-10-24 16:36:05 +0000 | [diff] [blame] | 339 | $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/; |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 340 | my $plat = "$ModulePlatforms{$key}"; |
| 341 | $plat = '' |
Fred Drake | 62cc360 | 1999-03-04 18:41:17 +0000 | [diff] [blame] | 342 | if ($plat eq $IGNORE_PLATFORM_ANNOTATION); |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 343 | if (!$first) { |
| 344 | $allthesame = 0 |
| 345 | if ($prevplat ne $plat); |
| 346 | } |
| 347 | else { $first = 0; } |
| 348 | $prevplat = $plat; |
| 349 | } |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 350 | open(MODIDXFILE, '>modindex.dat') || die "\n$!\n"; |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 351 | foreach $key (keys %Modules) { |
| 352 | # dump the line in the data file; just use a dummy seqno field |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 353 | my $nkey = $1; |
| 354 | my $moditem = "$Modules{$key}"; |
| 355 | my $plat = ''; |
Fred Drake | 73c5b660 | 2002-10-24 16:36:05 +0000 | [diff] [blame] | 356 | $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/$1/; |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 357 | if ($ModulePlatforms{$key} && !$allthesame) { |
Fred Drake | dce975c | 2001-06-20 21:31:36 +0000 | [diff] [blame] | 358 | $plat = (" <em>(<span class=\"platform\">$ModulePlatforms{$key}" |
Fred Drake | bb584d3 | 1999-03-25 22:18:30 +0000 | [diff] [blame] | 359 | . '</span>)</em>'); |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 360 | } |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 361 | print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP |
Fred Drake | dce975c | 2001-06-20 21:31:36 +0000 | [diff] [blame] | 362 | . "<tt class=\"module\">$key</tt>$plat###\n"; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 363 | } |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 364 | close(MODIDXFILE); |
Fred Drake | 42181db | 2001-01-09 22:02:10 +0000 | [diff] [blame] | 365 | |
| 366 | if ($GLOBAL_MODULE_INDEX) { |
| 367 | $prefix = <<MODULE_INDEX_PREFIX; |
| 368 | |
| 369 | <p> This index only lists modules documented in this manual. |
| 370 | The <em class="citetitle"><a href="$GLOBAL_MODULE_INDEX">Global Module |
| 371 | Index</a></em> lists all modules that are documented in this set |
| 372 | of manuals.</p> |
| 373 | MODULE_INDEX_PREFIX |
| 374 | } |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 375 | if (!$allthesame) { |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 376 | $prefix .= <<PLAT_DISCUSS; |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 377 | |
| 378 | <p> Some module names are followed by an annotation indicating what |
| 379 | platform they are available on.</p> |
| 380 | |
| 381 | PLAT_DISCUSS |
| 382 | } |
| 383 | insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0, |
| 384 | $prefix); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 385 | } |
| 386 | |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 387 | # replace both indexes as needed: |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 388 | sub add_idx_hook { |
Fred Drake | b3a3ed8 | 1998-07-24 22:17:34 +0000 | [diff] [blame] | 389 | add_idx() if (/$idx_mark/); |
Fred Drake | 2383f6d | 1999-03-02 16:00:37 +0000 | [diff] [blame] | 390 | process_python_state(); |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 391 | if ($MODULE_INDEX_FILE) { |
| 392 | local ($_); |
| 393 | open(MYFILE, "<$MODULE_INDEX_FILE"); |
| 394 | sysread(MYFILE, $_, 1024*1024); |
| 395 | close(MYFILE); |
| 396 | add_module_idx(); |
| 397 | open(MYFILE,">$MODULE_INDEX_FILE"); |
| 398 | print MYFILE $_; |
| 399 | close(MYFILE); |
| 400 | } |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 401 | } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 402 | |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 403 | |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 404 | # In addition to the standard stuff, add label to allow named node files and |
| 405 | # support suppression of the page complete (for HTML Help use). |
Fred Drake | 095f817 | 2003-06-27 18:26:01 +0000 | [diff] [blame] | 406 | $MY_CONTENTS_PAGE = ''; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 407 | sub do_cmd_tableofcontents { |
| 408 | local($_) = @_; |
| 409 | $TITLE = $toc_title; |
| 410 | $tocfile = $CURRENT_FILE; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 411 | my($closures, $reopens) = preserve_open_tags(); |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 412 | anchor_label('contents', $CURRENT_FILE, $_); # this is added |
Fred Drake | 095f817 | 2003-06-27 18:26:01 +0000 | [diff] [blame] | 413 | $MY_CONTENTS_PAGE = "$CURRENT_FILE"; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 414 | join('', "<br />\n\\tableofchildlinks[off]", $closures |
| 415 | , make_section_heading($toc_title, 'h2'), $toc_mark |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 416 | , $reopens, $_); |
| 417 | } |
| 418 | # In addition to the standard stuff, add label to allow named node files. |
| 419 | sub do_cmd_listoffigures { |
| 420 | local($_) = @_; |
| 421 | $TITLE = $lof_title; |
| 422 | $loffile = $CURRENT_FILE; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 423 | my($closures, $reopens) = preserve_open_tags(); |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 424 | anchor_label('lof', $CURRENT_FILE, $_); # this is added |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 425 | join('', "<br />\n", $closures |
| 426 | , make_section_heading($lof_title, 'h2'), $lof_mark |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 427 | , $reopens, $_); |
| 428 | } |
| 429 | # In addition to the standard stuff, add label to allow named node files. |
| 430 | sub do_cmd_listoftables { |
| 431 | local($_) = @_; |
| 432 | $TITLE = $lot_title; |
| 433 | $lotfile = $CURRENT_FILE; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 434 | my($closures, $reopens) = preserve_open_tags(); |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 435 | anchor_label('lot', $CURRENT_FILE, $_); # this is added |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 436 | join('', "<br />\n", $closures |
| 437 | , make_section_heading($lot_title, 'h2'), $lot_mark |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 438 | , $reopens, $_); |
| 439 | } |
| 440 | # In addition to the standard stuff, add label to allow named node files. |
| 441 | sub do_cmd_textohtmlinfopage { |
| 442 | local($_) = @_; |
| 443 | if ($INFO) { # |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 444 | anchor_label("about",$CURRENT_FILE,$_); # this is added |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 445 | } # |
Fred Drake | 15796f7 | 1998-11-30 19:25:47 +0000 | [diff] [blame] | 446 | my $the_version = ''; # and the rest is |
| 447 | if ($t_date) { # mostly ours |
| 448 | $the_version = ",\n$t_date"; |
Fred Drake | 7497bd3 | 2000-10-25 16:18:10 +0000 | [diff] [blame] | 449 | if ($PACKAGE_VERSION) { |
Fred Drake | dce975c | 2001-06-20 21:31:36 +0000 | [diff] [blame] | 450 | $the_version .= ", Release $PACKAGE_VERSION$RELEASE_INFO"; |
Fred Drake | 15796f7 | 1998-11-30 19:25:47 +0000 | [diff] [blame] | 451 | } |
| 452 | } |
Fred Drake | 9443dc3 | 2001-08-10 20:12:09 +0000 | [diff] [blame] | 453 | my $about; |
| 454 | open(ABOUT, "<$ABOUT_FILE") || die "\n$!\n"; |
| 455 | sysread(ABOUT, $about, 1024*1024); |
| 456 | close(ABOUT); |
Fred Drake | 15796f7 | 1998-11-30 19:25:47 +0000 | [diff] [blame] | 457 | $_ = (($INFO == 1) |
Fred Drake | b35f2b7 | 1999-09-23 16:53:09 +0000 | [diff] [blame] | 458 | ? join('', |
| 459 | $close_all, |
| 460 | "<strong>$t_title</strong>$the_version\n", |
Fred Drake | 9443dc3 | 2001-08-10 20:12:09 +0000 | [diff] [blame] | 461 | $about, |
Fred Drake | b35f2b7 | 1999-09-23 16:53:09 +0000 | [diff] [blame] | 462 | $open_all, $_) |
| 463 | : join('', $close_all, $INFO,"\n", $open_all, $_)); |
Fred Drake | 15796f7 | 1998-11-30 19:25:47 +0000 | [diff] [blame] | 464 | $_; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | # $idx_mark will be replaced with the real index at the end |
| 468 | sub do_cmd_textohtmlindex { |
| 469 | local($_) = @_; |
| 470 | $TITLE = $idx_title; |
| 471 | $idxfile = $CURRENT_FILE; |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 472 | if (%index_labels) { make_index_labels(); } |
| 473 | if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 474 | else { $preindex = ''; } |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 475 | my $heading = make_section_heading($idx_title, 'h2') . $idx_mark; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 476 | my($pre, $post) = minimize_open_tags($heading); |
Fred Drake | 235e6b1 | 1998-03-27 05:19:43 +0000 | [diff] [blame] | 477 | anchor_label('genindex',$CURRENT_FILE,$_); # this is added |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 478 | return "<br />\n" . $pre . $_; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 479 | } |
| 480 | |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 481 | $MODULE_INDEX_FILE = ''; |
| 482 | |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 483 | # $idx_module_mark will be replaced with the real index at the end |
| 484 | sub do_cmd_textohtmlmoduleindex { |
| 485 | local($_) = @_; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 486 | $TITLE = $idx_module_title; |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 487 | anchor_label('modindex', $CURRENT_FILE, $_); |
| 488 | $MODULE_INDEX_FILE = "$CURRENT_FILE"; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 489 | $_ = ('<p></p>' . make_section_heading($idx_module_title, 'h2') |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 490 | . $idx_module_mark . $_); |
| 491 | return $_; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 492 | } |
| 493 | |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 494 | # The bibliography and the index should be treated as separate |
| 495 | # sections in their own HTML files. The \bibliography{} command acts |
| 496 | # as a sectioning command that has the desired effect. But when the |
| 497 | # bibliography is constructed manually using the thebibliography |
| 498 | # environment, or when using the theindex environment it is not |
| 499 | # possible to use the normal sectioning mechanism. This subroutine |
| 500 | # inserts a \bibliography{} or a dummy \textohtmlindex command just |
| 501 | # before the appropriate environments to force sectioning. |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 502 | |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 503 | # XXX This *assumes* that if there are two {theindex} environments, |
| 504 | # the first is the module index and the second is the standard |
| 505 | # index. This is sufficient for the current Python documentation, |
| 506 | # but that's about it. |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 507 | |
| 508 | sub add_bbl_and_idx_dummy_commands { |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 509 | my $id = $global{'max_id'}; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 510 | |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 511 | if (/[\\]tableofcontents/) { |
| 512 | $HAVE_TABLE_OF_CONTENTS = 1; |
| 513 | } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 514 | s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg; |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 515 | s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo; |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 516 | my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/); |
| 517 | if (scalar(@parts) == 3) { |
| 518 | # Be careful to re-write the string in place, since $_ is *not* |
| 519 | # returned explicity; *** nasty side-effect dependency! *** |
Fred Drake | bb7775a | 2001-12-04 17:03:54 +0000 | [diff] [blame] | 520 | print "\nadd_bbl_and_idx_dummy_commands ==> adding general index"; |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 521 | print "\nadd_bbl_and_idx_dummy_commands ==> adding module index"; |
| 522 | my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)" |
| 523 | . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)"; |
Fred Drake | 73c5b660 | 2002-10-24 16:36:05 +0000 | [diff] [blame] | 524 | s/$rx/\\textohtmlmoduleindex $1 \\textohtmlindex $2/o; |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 525 | # Add a button to the navigation areas: |
Fred Drake | aaa2385 | 2000-09-14 22:20:41 +0000 | [diff] [blame] | 526 | $CUSTOM_BUTTONS .= ('<a href="modindex.html" title="Module Index">' |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 527 | . get_my_icon('modules') |
Fred Drake | aaa2385 | 2000-09-14 22:20:41 +0000 | [diff] [blame] | 528 | . '</a>'); |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 529 | $HAVE_MODULE_INDEX = 1; |
| 530 | $HAVE_GENERAL_INDEX = 1; |
| 531 | } |
| 532 | elsif (scalar(@parts) == 2) { |
Fred Drake | bb7775a | 2001-12-04 17:03:54 +0000 | [diff] [blame] | 533 | print "\nadd_bbl_and_idx_dummy_commands ==> adding general index"; |
| 534 | my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex)"; |
Fred Drake | 73c5b660 | 2002-10-24 16:36:05 +0000 | [diff] [blame] | 535 | s/$rx/\\textohtmlindex $1/o; |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 536 | $HAVE_GENERAL_INDEX = 1; |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 537 | } |
Fred Drake | bb7775a | 2001-12-04 17:03:54 +0000 | [diff] [blame] | 538 | elsif (scalar(@parts) == 1) { |
| 539 | print "\nadd_bbl_and_idx_dummy_commands ==> no index found"; |
Fred Drake | d18722b | 2001-01-02 22:08:48 +0000 | [diff] [blame] | 540 | $CUSTOM_BUTTONS .= get_my_icon('blank'); |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 541 | $global{'max_id'} = $id; # not sure why.... |
| 542 | s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o; |
Fred Drake | 191439a | 1999-09-22 19:50:51 +0000 | [diff] [blame] | 543 | s/[\\]printindex/\\textohtmlindex /o; |
Fred Drake | bb7775a | 2001-12-04 17:03:54 +0000 | [diff] [blame] | 544 | } |
| 545 | else { |
| 546 | die "\n\nBad number of index environments!\n\n"; |
| 547 | } |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 548 | #---------------------------------------------------------------------- |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 549 | lib_add_bbl_and_idx_dummy_commands() |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 550 | if defined(&lib_add_bbl_and_idx_dummy_commands); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 551 | } |
| 552 | |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 553 | # The bibliographic references, the appendices, the lists of figures |
| 554 | # and tables etc. must appear in the contents table at the same level |
| 555 | # as the outermost sectioning command. This subroutine finds what is |
| 556 | # the outermost level and sets the above to the same level; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 557 | |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 558 | sub set_depth_levels { |
| 559 | # Sets $outermost_level |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 560 | my $level; |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 561 | #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH |
| 562 | foreach $level ("part", "chapter", "section", "subsection", |
| 563 | "subsubsection", "paragraph") { |
| 564 | last if (($outermost_level) = /\\($level)$delimiter_rx/); |
| 565 | } |
| 566 | $level = ($outermost_level ? $section_commands{$outermost_level} : |
| 567 | do {$outermost_level = 'section'; 3;}); |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 568 | |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 569 | #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given |
| 570 | if ($REL_DEPTH && $MAX_SPLIT_DEPTH) { |
| 571 | $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH; |
| 572 | } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 }; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 573 | |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 574 | %unnumbered_section_commands = ('tableofcontents' => $level, |
| 575 | 'listoffigures' => $level, |
| 576 | 'listoftables' => $level, |
| 577 | 'bibliography' => $level, |
| 578 | 'textohtmlindex' => $level, |
| 579 | 'textohtmlmoduleindex' => $level); |
| 580 | $section_headings{'textohtmlmoduleindex'} = 'h1'; |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 581 | |
Fred Drake | 64bdc24 | 1998-04-17 02:14:12 +0000 | [diff] [blame] | 582 | %section_commands = (%unnumbered_section_commands, |
| 583 | %section_commands); |
Fred Drake | 1191692 | 1998-04-02 22:30:57 +0000 | [diff] [blame] | 584 | |
| 585 | make_sections_rx(); |
Fred Drake | 13210ed | 1998-03-17 06:28:05 +0000 | [diff] [blame] | 586 | } |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 587 | |
| 588 | |
Fred Drake | 1072e46 | 1998-04-12 02:16:34 +0000 | [diff] [blame] | 589 | # This changes the markup used for {verbatim} environments, and is the |
Fred Drake | 95474f9 | 1999-02-09 18:45:50 +0000 | [diff] [blame] | 590 | # best way I've found that ensures the <dl> goes on the outside of the |
Fred Drake | 1072e46 | 1998-04-12 02:16:34 +0000 | [diff] [blame] | 591 | # <pre>...</pre>. |
| 592 | # |
| 593 | # Note that this *must* be done in the init file, not the python.perl |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 594 | # style support file. The %declarations must be set before |
| 595 | # initialize() is called in the main LaTeX2HTML script (which happens |
| 596 | # before style files are loaded). |
Fred Drake | 1072e46 | 1998-04-12 02:16:34 +0000 | [diff] [blame] | 597 | # |
Fred Drake | 8a5e679 | 2002-04-15 18:41:31 +0000 | [diff] [blame] | 598 | %declarations = ('preform' => '<div class="verbatim"><pre></pre></div>', |
Fred Drake | 1072e46 | 1998-04-12 02:16:34 +0000 | [diff] [blame] | 599 | %declarations); |
| 600 | |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 601 | |
Fred Drake | bf8ec3e | 2003-05-02 20:18:01 +0000 | [diff] [blame] | 602 | # This is used to map the link rel attributes LaTeX2HTML uses to those |
| 603 | # currently recommended by the W3C. |
| 604 | sub custom_REL_hook { |
| 605 | my($rel,$junk) = @_; |
| 606 | return 'parent' if $rel eq 'up'; |
| 607 | return 'prev' if $rel eq 'previous'; |
| 608 | return $rel; |
| 609 | } |
| 610 | |
Fred Drake | c568173 | 2000-09-12 20:13:04 +0000 | [diff] [blame] | 611 | # This is added to get rid of the long comment that follows the |
| 612 | # doctype declaration; MSIE5 on NT4 SP4 barfs on it and drops the |
| 613 | # content of the page. |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 614 | $MY_PARTIAL_HEADER = ''; |
Fred Drake | f547863 | 2002-05-23 17:59:16 +0000 | [diff] [blame] | 615 | sub make_head_and_body($$) { |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 616 | my($title, $body) = @_; |
Fred Drake | 1681627 | 2000-09-16 20:40:44 +0000 | [diff] [blame] | 617 | $body = " $body" unless ($body eq ''); |
Fred Drake | 85d14c9 | 2000-07-31 17:53:45 +0000 | [diff] [blame] | 618 | my $DTDcomment = ''; |
| 619 | my($version, $isolanguage) = ($HTML_VERSION, 'EN'); |
| 620 | my %isolanguages = ( 'english', 'EN' , 'USenglish', 'EN.US' |
| 621 | , 'original', 'EN' , 'german' , 'DE' |
| 622 | , 'austrian', 'DE.AT', 'french' , 'FR' |
| 623 | , 'spanish', 'ES'); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 624 | $isolanguage = $isolanguages{$default_language}; |
| 625 | $isolanguage = 'EN' unless $isolanguage; |
| 626 | $title = &purify($title,1); |
| 627 | eval("\$title = ". $default_title ) unless ($title); |
| 628 | |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 629 | # allow user-modification of the <title> tag; thanks Dan Young |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 630 | if (defined &custom_TITLE_hook) { |
| 631 | $title = &custom_TITLE_hook($title, $toc_sec_title); |
| 632 | } |
| 633 | |
| 634 | if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included |
| 635 | $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n"; |
| 636 | } else { |
| 637 | $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//" |
| 638 | . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n"; |
| 639 | } |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 640 | if ($MY_PARTIAL_HEADER eq '') { |
| 641 | $STYLESHEET = $FILE.".css" unless $STYLESHEET; |
| 642 | $MY_PARTIAL_HEADER = join('', |
Fred Drake | dd3d6a0 | 2002-10-30 17:00:58 +0000 | [diff] [blame] | 643 | ($DOCTYPE ? $DTDcomment : ''), |
Fred Drake | 98b2576 | 2003-05-02 18:21:22 +0000 | [diff] [blame] | 644 | "<html>\n<head>", |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 645 | ($BASE ? "\n<base href=\"$BASE\" />" : ''), |
| 646 | "\n<link rel=\"STYLESHEET\" href=\"$STYLESHEET\" type='text/css'", |
| 647 | " />", |
Fred Drake | dd3d6a0 | 2002-10-30 17:00:58 +0000 | [diff] [blame] | 648 | ($FAVORITES_ICON |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 649 | ? ("\n<link rel=\"SHORTCUT ICON\" href=\"$FAVORITES_ICON\" />") |
Fred Drake | dd3d6a0 | 2002-10-30 17:00:58 +0000 | [diff] [blame] | 650 | : ''), |
Fred Drake | 2394900 | 2002-10-30 21:51:18 +0000 | [diff] [blame] | 651 | ($EXTERNAL_UP_LINK |
Fred Drake | 98b2576 | 2003-05-02 18:21:22 +0000 | [diff] [blame] | 652 | ? ("\n<link rel='start' href='" . $EXTERNAL_UP_LINK |
| 653 | . ($EXTERNAL_UP_TITLE ? |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 654 | "' title='$EXTERNAL_UP_TITLE' />" : "' />")) |
Fred Drake | 2394900 | 2002-10-30 21:51:18 +0000 | [diff] [blame] | 655 | : ''), |
Fred Drake | 98b2576 | 2003-05-02 18:21:22 +0000 | [diff] [blame] | 656 | "\n<link rel=\"first\" href=\"$FILE.html\"", |
Fred Drake | 2394900 | 2002-10-30 21:51:18 +0000 | [diff] [blame] | 657 | ($t_title ? " title='$t_title'" : ''), |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 658 | ' />', |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 659 | ($HAVE_TABLE_OF_CONTENTS |
Fred Drake | 095f817 | 2003-06-27 18:26:01 +0000 | [diff] [blame] | 660 | ? ("\n<link rel='contents' href='$MY_CONTENTS_PAGE'" |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 661 | . ' title="Contents" />') |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 662 | : ''), |
| 663 | ($HAVE_GENERAL_INDEX |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 664 | ? "\n<link rel='index' href='genindex.html' title='Index' />" |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 665 | : ''), |
| 666 | # disable for now -- Mozilla doesn't do well with multiple indexes |
| 667 | # ($HAVE_MODULE_INDEX |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 668 | # ? '<link rel="index" href="modindex.html" title="Module Index"' |
| 669 | # . " />\n" |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 670 | # : ''), |
Fred Drake | 2394900 | 2002-10-30 21:51:18 +0000 | [diff] [blame] | 671 | ($INFO |
| 672 | # XXX We can do this with the Python tools since the About... |
| 673 | # page always gets copied to about.html, even when we use the |
| 674 | # generated node###.html page names. Won't work with the |
| 675 | # rest of the Python doc tools. |
Fred Drake | 98b2576 | 2003-05-02 18:21:22 +0000 | [diff] [blame] | 676 | ? ("\n<link rel='last' href='about.html'" |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 677 | . " title='About this document...' />" |
Fred Drake | 98b2576 | 2003-05-02 18:21:22 +0000 | [diff] [blame] | 678 | . "\n<link rel='help' href='about.html'" |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 679 | . " title='About this document...' />") |
Fred Drake | 2394900 | 2002-10-30 21:51:18 +0000 | [diff] [blame] | 680 | : ''), |
Fred Drake | dd3d6a0 | 2002-10-30 17:00:58 +0000 | [diff] [blame] | 681 | $more_links_mark, |
Fred Drake | 0e2e687 | 2002-10-30 19:55:23 +0000 | [diff] [blame] | 682 | "\n", |
Fred Drake | dd3d6a0 | 2002-10-30 17:00:58 +0000 | [diff] [blame] | 683 | ($CHARSET && $HTML_VERSION ge "2.1" |
| 684 | ? ('<meta http-equiv="Content-Type" content="text/html; ' |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 685 | . "charset=$CHARSET\" />\n") |
Fred Drake | dd3d6a0 | 2002-10-30 17:00:58 +0000 | [diff] [blame] | 686 | : ''), |
| 687 | ($AESOP_META_TYPE |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 688 | ? "<meta name='aesop' content='$AESOP_META_TYPE' />\n" : '')); |
Fred Drake | a219b41 | 2001-10-22 16:57:49 +0000 | [diff] [blame] | 689 | } |
Fred Drake | 0e2e687 | 2002-10-30 19:55:23 +0000 | [diff] [blame] | 690 | if (!$charset && $CHARSET) { |
| 691 | $charset = $CHARSET; |
| 692 | $charset =~ s/_/\-/go; |
| 693 | } |
Fred Drake | f06b905 | 2003-05-02 18:08:16 +0000 | [diff] [blame] | 694 | # Remove section number from the title for use in the |
| 695 | # <meta name='description' ...> element in the document head. |
| 696 | my $metatitle = "$title"; |
| 697 | $metatitle =~ s/^\d+(\.\d+)*\s*//; |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 698 | $metatitle = meta_information($metatitle); |
| 699 | $metatitle =~ s/ NAME=/ name=/g; |
| 700 | $metatitle =~ s/ CONTENT=/ content=/g; |
Fred Drake | f06b905 | 2003-05-02 18:08:16 +0000 | [diff] [blame] | 701 | |
Fred Drake | dd3d6a0 | 2002-10-30 17:00:58 +0000 | [diff] [blame] | 702 | join('', |
| 703 | $MY_PARTIAL_HEADER, |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 704 | $metatitle, |
Fred Drake | dd3d6a0 | 2002-10-30 17:00:58 +0000 | [diff] [blame] | 705 | "<title>", $title, "</title>\n</head>\n<body$body>"); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 706 | } |
| 707 | |
Fred Drake | 2fc88a6 | 2003-08-05 03:45:37 +0000 | [diff] [blame^] | 708 | sub replace_morelinks { |
| 709 | $more_links =~ s/ REL=/ rel=/g; |
| 710 | $more_links =~ s/ HREF=/ href=/g; |
| 711 | $_ =~ s/$more_links_mark/$more_links/e; |
| 712 | } |
| 713 | |
Fred Drake | bc7101d | 1998-03-06 21:18:55 +0000 | [diff] [blame] | 714 | 1; # This must be the last line |