Fred Drake | a5a3cdc | 1997-12-08 20:58:13 +0000 | [diff] [blame] | 1 | #LaTeX2HTML Version 96.1 : dot.latex2html-init -*- perl -*- |
Fred Drake | 784c6d3 | 1996-11-11 20:46:44 +0000 | [diff] [blame] | 2 | # |
| 3 | |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 4 | $INFO = 1; # 0 = do not make a "About this document..." section |
Fred Drake | 784c6d3 | 1996-11-11 20:46:44 +0000 | [diff] [blame] | 5 | $MAX_LINK_DEPTH = 3; |
| 6 | |
| 7 | # Python documentation uses section numbers to support references to match |
| 8 | # in the printed and online versions. |
| 9 | # |
| 10 | $SHOW_SECTION_NUMBERS = 1; |
| 11 | |
| 12 | $HTML_VERSION = '3.0'; |
| 13 | $ICONSERVER = '../icons'; |
| 14 | |
| 15 | # This replacement adds the "BORDER=0" attribute to the generated icon |
| 16 | # markup. This is done for no better reason than that it looks better. |
| 17 | # |
| 18 | sub img_tag { |
| 19 | local($icon) = @_; |
| 20 | ( ($icon =~ /(gif)/) ? |
| 21 | do { |
| 22 | $icon =~ /(up|next|previous|next_page|previous_page|change_begin|change_end|change_delete|contents|index)/; |
| 23 | join('','<IMG ',$iconsizes{$1},' ALIGN=BOTTOM ALT="',$1, |
| 24 | '" SRC="',$ICONSERVER,"/$icon",'" BORDER=0>') |
| 25 | } : |
| 26 | $icon); |
| 27 | } |
| 28 | |
Fred Drake | dce22ad | 1996-12-06 14:50:58 +0000 | [diff] [blame] | 29 | # This replacement for process_command() is needed to add the case for |
Fred Drake | 784c6d3 | 1996-11-11 20:46:44 +0000 | [diff] [blame] | 30 | # "\,"; it is unfortunate we need to do it this way. |
| 31 | # |
| 32 | sub process_command { |
| 33 | local ($cmd_rx, *ref_contents) = @_; |
| 34 | local($ref_before, $cmd, $after); |
| 35 | local($cmd_sub, $cmd_msub, $cmd_trans, $mathentity); |
| 36 | local (@open_font_tags,@open_size_tags); |
| 37 | $ref_contents = &convert_iso_latin_chars($ref_contents); |
| 38 | for (;;) { # Do NOT use the o option |
| 39 | last unless ($ref_contents =~ /$cmd_rx/ ); |
| 40 | ($ref_before, $cmd, $after) = ($`, $1, "$2$'"); |
| 41 | print("."); |
| 42 | # $after =~ s/^[ ]+/ /o; Collapse all spaces that follow a command |
| 43 | if ($cmd =~ /[a-zA-Z]$/) { # Eat redundant spaces that follow a command |
| 44 | $after =~ s/^[ \t]+//o; } |
| 45 | else { |
| 46 | $after =~ s/^[ \t]+/ /o; } |
| 47 | if ( $cmd = &normalize($cmd) ) { |
| 48 | ($cmd_sub, $cmd_msub, $cmd_trans, $mathentity) = |
| 49 | ("do_cmd_$cmd", "do_math_cmd_$cmd", |
| 50 | $declarations{$cmd}, $mathentities{$cmd}); |
| 51 | if (defined &$cmd_sub) { |
| 52 | # $ref_before may also be modified ... |
| 53 | if ($cmd =~ /$sizechange_rx/o) { |
| 54 | $after = &$cmd_sub($after, @open_size_tags); |
| 55 | } else { |
| 56 | $after = &$cmd_sub($after, @open_font_tags); |
| 57 | }; |
| 58 | } |
| 59 | elsif (defined &$cmd_msub) { |
| 60 | # $ref_before may also be modified ... |
| 61 | $after = &$cmd_msub($after, @open_font_tags); |
| 62 | if ( !$math_mode ) { |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 63 | $after = "<math>" . $after . "</math>"; |
Fred Drake | 784c6d3 | 1996-11-11 20:46:44 +0000 | [diff] [blame] | 64 | ++$commands_outside_math{$cmd}; |
| 65 | }; |
| 66 | } |
| 67 | elsif ($cmd_trans) { # One to one transform |
| 68 | $cmd_trans =~ m|</.*$|; |
| 69 | $after = $` . $after . $&; |
| 70 | push(@open_font_tags, $cmd) if ($cmd =~ /$fontchange_rx/o); |
| 71 | push(@open_size_tags, $cmd) if ($cmd =~ /$sizechange_rx/o);} |
| 72 | elsif ($mathentity) { |
| 73 | if ( $math_mode ) { |
| 74 | $after = "&$mathentity;" . $after; |
| 75 | } else { |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 76 | $after = "<math>&$mathentity;</math>" . $after; |
Fred Drake | 784c6d3 | 1996-11-11 20:46:44 +0000 | [diff] [blame] | 77 | ++$commands_outside_math{$cmd}; |
| 78 | }; } |
| 79 | # Here's the hack: |
| 80 | elsif ($cmd == ',' && ! $AUX_FILE) { |
| 81 | $ref_before = $ref_before . ","; |
| 82 | } |
| 83 | elsif ($ignore{$cmd}) { # Ignored command |
| 84 | print "."} |
| 85 | elsif ($cmd =~ /^the(.+)$/) { # Counter |
| 86 | $counter = $1; |
| 87 | $after = &do_cmd_thecounter($after);} |
| 88 | else { |
| 89 | # Do not add if reading an auxiliary file |
| 90 | ++$unknown_commands{$cmd} unless $AUX_FILE; |
| 91 | } |
| 92 | } |
| 93 | $ref_contents = join('', $ref_before, $after); |
| 94 | } |
| 95 | $ref_contents; |
| 96 | } |
| 97 | |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 98 | sub top_navigation_panel { |
| 99 | |
| 100 | # Now add a few buttons with a space between them |
| 101 | "<DIV CLASS=navigation>\n" . |
| 102 | "$NEXT $UP $PREVIOUS $CONTENTS $INDEX $CUSTOM_BUTTONS" . |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 103 | |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 104 | "<BR>\n" . # Line break |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 105 | |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 106 | # If ``next'' section exists, add its title to the navigation panel |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 107 | ($NEXT_TITLE ? "<B> Next:</B> $NEXT_TITLE\n" : undef) . |
| 108 | |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 109 | # Similarly with the ``up'' title ... |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 110 | ($UP_TITLE ? "<B>Up:</B> $UP_TITLE\n" : undef) . |
| 111 | |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 112 | # ... and the ``previous'' title |
| 113 | ($PREVIOUS_TITLE ? "<B> Previous:</B> $PREVIOUS_TITLE\n" : undef) . |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 114 | |
| 115 | # Line Break, horizontal rule (3-d dividing line) and new paragraph |
| 116 | "<BR><HR><P></DIV>\n" |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | sub bot_navigation_panel { |
| 120 | |
| 121 | # Start with a horizontal rule (3-d dividing line) |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 122 | "\n<div class=navigation><hr>". |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 123 | |
| 124 | # Now add a few buttons with a space between them |
| 125 | "$NEXT $UP $PREVIOUS $CONTENTS $INDEX $CUSTOM_BUTTONS" . |
| 126 | |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 127 | "<br>\n" . # Line break |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 128 | |
| 129 | # If ``next'' section exists, add its title to the navigation panel |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 130 | ($NEXT_TITLE ? "<b> Next:</b> $NEXT_TITLE\n" : undef) . |
| 131 | |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 132 | # Similarly with the ``up'' title ... |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 133 | ($UP_TITLE ? "<b>Up:</b> $UP_TITLE\n" : undef) . |
| 134 | |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 135 | # ... and the ``previous'' title |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 136 | ($PREVIOUS_TITLE ? "<b> Previous:</b> $PREVIOUS_TITLE\n" : undef) . |
| 137 | |
| 138 | "</div>\n" |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | |
| 142 | # similar to make_index_entry(), but includes the string in the result |
| 143 | # instead of the dummy filler. |
| 144 | # |
| 145 | sub make_str_index_entry { |
| 146 | local($br_id,$str) = @_; |
| 147 | # If TITLE is not yet available (i.e the \index command is in the title |
| 148 | # of the current section), use $ref_before. |
| 149 | $TITLE = $ref_before unless $TITLE; |
| 150 | # Save the reference |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 151 | local($nstr) = "$str###" . ++$global{'max_id'}; # Make unique |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 152 | $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id"); |
| 153 | "<a name=\"$br_id\">$str<\/a>"; |
| 154 | } |
| 155 | |
| 156 | sub add_idx { |
| 157 | print "\nDoing the index ..."; |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 158 | local($key, $str, @keys, $index, $level, $count, |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 159 | @previous, @current); |
| 160 | @keys = keys %index; |
| 161 | @keys = sort keysort @keys; |
| 162 | $level = 0; |
| 163 | foreach $key (@keys) { |
| 164 | @current = split(/!/, $key); |
| 165 | $count = 0; |
| 166 | while ($current[$count] eq $previous[$count]) { |
| 167 | $count++; |
| 168 | } |
| 169 | while ($count > $level) { |
| 170 | $index .= "<dl compact>\n"; |
| 171 | $level++; |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 172 | } |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 173 | while ($count < $level) { |
| 174 | $index .= "</dl>\n"; |
| 175 | $level--; |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 176 | } |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 177 | foreach $term (@current[$count .. $#current-1]) { |
| 178 | # need to "step in" a little |
| 179 | $index .= "<dt>" . $term . "\n<dl compact>\n"; |
| 180 | $level++; |
| 181 | } |
| 182 | $str = $current[$#current]; |
| 183 | $str =~ s/\#\#\#\d+$//o; # Remove the unique id's |
| 184 | $index .= #$index{$key} . |
| 185 | # If it's the same string don't start a new line |
| 186 | (&index_key_eq(join('',@current), join('',@previous)) ? |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 187 | ", $index{$key}" . $cross_ref_visible_mark . "</a>\n" : |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 188 | "<dt>$index{$key}<strong>" . $str . "</strong></a>\n"); |
| 189 | @previous = @current; |
| 190 | } |
| 191 | while ($count < $level) { |
| 192 | $index .= "</dl>\n"; |
| 193 | $level--; |
Fred Drake | d569242 | 1997-12-11 21:46:07 +0000 | [diff] [blame] | 194 | } |
Fred Drake | f2d7e55 | 1997-12-03 19:44:27 +0000 | [diff] [blame] | 195 | s/$idx_mark/<dl compact>$index<\/dl>/o; |
| 196 | } |
| 197 | |
| 198 | |
Fred Drake | a5a3cdc | 1997-12-08 20:58:13 +0000 | [diff] [blame] | 199 | # need to remove leading <...> |
| 200 | sub clean_key { |
| 201 | local ($_) = @_; |
| 202 | tr/A-Z/a-z/; |
| 203 | s/\s//; |
| 204 | s/\#\#\#\d+$//o; # Remove the unique id |
| 205 | s/^<[a-z][-._a-z0-9]*>//; # Remove leading <gi> |
| 206 | $_ |
| 207 | } |
| 208 | |
| 209 | |
Fred Drake | 784c6d3 | 1996-11-11 20:46:44 +0000 | [diff] [blame] | 210 | 1; # This must be the last line |