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