blob: 932fbf3e29508ac96ede7fa69017cdc0647ebf42 [file] [log] [blame]
Fred Drakea5a3cdc1997-12-08 20:58:13 +00001#LaTeX2HTML Version 96.1 : dot.latex2html-init -*- perl -*-
Fred Drake784c6d31996-11-11 20:46:44 +00002#
3
Fred Draked5692421997-12-11 21:46:07 +00004$INFO = 1; # 0 = do not make a "About this document..." section
Fred Drake784c6d31996-11-11 20:46:44 +00005$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#
18sub 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)/;
Fred Drake616b23b1997-12-18 14:16:46 +000023 join('','<img ',$iconsizes{$1},' align=bottom alt="',$1,
24 '" src="',$ICONSERVER,"/$icon",'" border=0>')
Fred Drake784c6d31996-11-11 20:46:44 +000025 } :
26 $icon);
27}
28
Fred Drakedce22ad1996-12-06 14:50:58 +000029# This replacement for process_command() is needed to add the case for
Fred Drake784c6d31996-11-11 20:46:44 +000030# "\,"; it is unfortunate we need to do it this way.
31#
32sub 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 Draked5692421997-12-11 21:46:07 +000063 $after = "<math>" . $after . "</math>";
Fred Drake784c6d31996-11-11 20:46:44 +000064 ++$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 Draked5692421997-12-11 21:46:07 +000076 $after = "<math>&$mathentity;</math>" . $after;
Fred Drake784c6d31996-11-11 20:46:44 +000077 ++$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 Drakef2d7e551997-12-03 19:44:27 +000098sub top_navigation_panel {
99
100 # Now add a few buttons with a space between them
Fred Drake616b23b1997-12-18 14:16:46 +0000101 "<div class=navigation>\n" .
Fred Drakef2d7e551997-12-03 19:44:27 +0000102 "$NEXT $UP $PREVIOUS $CONTENTS $INDEX $CUSTOM_BUTTONS" .
Fred Draked5692421997-12-11 21:46:07 +0000103
Fred Drakef2d7e551997-12-03 19:44:27 +0000104 "<BR>\n" . # Line break
Fred Draked5692421997-12-11 21:46:07 +0000105
Fred Drakef2d7e551997-12-03 19:44:27 +0000106 # If ``next'' section exists, add its title to the navigation panel
Fred Drake616b23b1997-12-18 14:16:46 +0000107 ($NEXT_TITLE ? "<b> Next:</b> $NEXT_TITLE\n" : undef) .
Fred Draked5692421997-12-11 21:46:07 +0000108
Fred Drakef2d7e551997-12-03 19:44:27 +0000109 # Similarly with the ``up'' title ...
Fred Drake616b23b1997-12-18 14:16:46 +0000110 ($UP_TITLE ? "<b>Up:</b> $UP_TITLE\n" : undef) .
Fred Draked5692421997-12-11 21:46:07 +0000111
Fred Drakef2d7e551997-12-03 19:44:27 +0000112 # ... and the ``previous'' title
Fred Drake616b23b1997-12-18 14:16:46 +0000113 ($PREVIOUS_TITLE ? "<b> Previous:</b> $PREVIOUS_TITLE\n" : undef) .
Fred Draked5692421997-12-11 21:46:07 +0000114
115 # Line Break, horizontal rule (3-d dividing line) and new paragraph
Fred Drake616b23b1997-12-18 14:16:46 +0000116 "<br><hr><p></div>\n"
Fred Drakef2d7e551997-12-03 19:44:27 +0000117}
118
119sub bot_navigation_panel {
120
121 # Start with a horizontal rule (3-d dividing line)
Fred Draked5692421997-12-11 21:46:07 +0000122 "\n<div class=navigation><hr>".
Fred Drakef2d7e551997-12-03 19:44:27 +0000123
124 # Now add a few buttons with a space between them
125 "$NEXT $UP $PREVIOUS $CONTENTS $INDEX $CUSTOM_BUTTONS" .
126
Fred Draked5692421997-12-11 21:46:07 +0000127 "<br>\n" . # Line break
Fred Drakef2d7e551997-12-03 19:44:27 +0000128
129 # If ``next'' section exists, add its title to the navigation panel
Fred Draked5692421997-12-11 21:46:07 +0000130 ($NEXT_TITLE ? "<b> Next:</b> $NEXT_TITLE\n" : undef) .
131
Fred Drakef2d7e551997-12-03 19:44:27 +0000132 # Similarly with the ``up'' title ...
Fred Draked5692421997-12-11 21:46:07 +0000133 ($UP_TITLE ? "<b>Up:</b> $UP_TITLE\n" : undef) .
134
Fred Drakef2d7e551997-12-03 19:44:27 +0000135 # ... and the ``previous'' title
Fred Draked5692421997-12-11 21:46:07 +0000136 ($PREVIOUS_TITLE ? "<b> Previous:</b> $PREVIOUS_TITLE\n" : undef) .
137
138 "</div>\n"
Fred Drakef2d7e551997-12-03 19:44:27 +0000139}
140
141
Fred Drake819b7891997-12-17 03:08:27 +0000142sub gen_index_id {
143 # this is used to ensure common index key generation and a stable sort
144 local($str,$extra) = @_;
145 sprintf("%s###%s%010d", $str, $extra, ++$global{'max_id'});
146}
147
148sub make_index_entry {
Fred Drakef2d7e551997-12-03 19:44:27 +0000149 local($br_id,$str) = @_;
Fred Drake819b7891997-12-17 03:08:27 +0000150 # If TITLE is not yet available (i.e the \index command is in the title of the
151 # current section), use $ref_before.
Fred Drakef2d7e551997-12-03 19:44:27 +0000152 $TITLE = $ref_before unless $TITLE;
153 # Save the reference
Fred Drake819b7891997-12-17 03:08:27 +0000154 $str = gen_index_id($str, '');
155 $index{$str} .= &make_half_href("$CURRENT_FILE#$br_id");
156 "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
Fred Drakef2d7e551997-12-03 19:44:27 +0000157}
158
159sub add_idx {
160 print "\nDoing the index ...";
Fred Drake819b7891997-12-17 03:08:27 +0000161 local($key, $str, @keys, $index, $level, $count, @previous, @current);
Fred Drakef2d7e551997-12-03 19:44:27 +0000162 @keys = keys %index;
163 @keys = sort keysort @keys;
164 $level = 0;
165 foreach $key (@keys) {
166 @current = split(/!/, $key);
167 $count = 0;
168 while ($current[$count] eq $previous[$count]) {
169 $count++;
170 }
171 while ($count > $level) {
172 $index .= "<dl compact>\n";
173 $level++;
Fred Draked5692421997-12-11 21:46:07 +0000174 }
Fred Drakef2d7e551997-12-03 19:44:27 +0000175 while ($count < $level) {
176 $index .= "</dl>\n";
177 $level--;
Fred Draked5692421997-12-11 21:46:07 +0000178 }
Fred Drakef2d7e551997-12-03 19:44:27 +0000179 foreach $term (@current[$count .. $#current-1]) {
180 # need to "step in" a little
181 $index .= "<dt>" . $term . "\n<dl compact>\n";
182 $level++;
183 }
184 $str = $current[$#current];
Fred Drake819b7891997-12-17 03:08:27 +0000185 $str =~ s/\#\#\#\d+$//o; # Remove the unique id's
186 $str =~ s/\#\#\#[DR]EF\d+$//o; # Remove the unique id's
187 if (&index_key_eq(join('',@current), join('',@previous))) {
188 $index .= ",\n$index{$key}" . $cross_ref_visible_mark . "</a>"; }
189 else {
190 $index .= "\n<dt>$index{$key}" . $str . "</a>"; }
Fred Drakef2d7e551997-12-03 19:44:27 +0000191 @previous = @current;
192 }
193 while ($count < $level) {
194 $index .= "</dl>\n";
195 $level--;
Fred Draked5692421997-12-11 21:46:07 +0000196 }
Fred Drakef2d7e551997-12-03 19:44:27 +0000197 s/$idx_mark/<dl compact>$index<\/dl>/o;
198}
199
200
Fred Drake819b7891997-12-17 03:08:27 +0000201sub index_key_eq {
202 local($a,$b) = @_;
203 $a = &clean_key($a);
204 $a =~ s/\#\#\#\d+$//o; # Remove the unique id's
205 $a =~ s/\#\#\#[dr]ef\d+$//o; # Remove the unique id's
206 $b = &clean_key($b);
207 $b =~ s/\#\#\#\d+$//o; # Remove the unique id's
208 $b =~ s/\#\#\#[dr]ef\d+$//o; # Remove the unique id's
209 $a eq $b;
210}
211
Fred Drakea5a3cdc1997-12-08 20:58:13 +0000212# need to remove leading <...>
213sub clean_key {
214 local ($_) = @_;
215 tr/A-Z/a-z/;
216 s/\s//;
Fred Drakea5a3cdc1997-12-08 20:58:13 +0000217 s/^<[a-z][-._a-z0-9]*>//; # Remove leading <gi>
218 $_
219}
220
221
Fred Drake784c6d31996-11-11 20:46:44 +00002221; # This must be the last line