blob: 774f3a79444d2dcb3b783988365fee3681dd964c [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)/;
23 join('','<IMG ',$iconsizes{$1},' ALIGN=BOTTOM ALT="',$1,
24 '" SRC="',$ICONSERVER,"/$icon",'" BORDER=0>')
25 } :
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
101 "<DIV CLASS=navigation>\n" .
102 "$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 Draked5692421997-12-11 21:46:07 +0000107 ($NEXT_TITLE ? "<B> Next:</B> $NEXT_TITLE\n" : undef) .
108
Fred Drakef2d7e551997-12-03 19:44:27 +0000109 # Similarly with the ``up'' title ...
Fred Draked5692421997-12-11 21:46:07 +0000110 ($UP_TITLE ? "<B>Up:</B> $UP_TITLE\n" : undef) .
111
Fred Drakef2d7e551997-12-03 19:44:27 +0000112 # ... and the ``previous'' title
113 ($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
116 "<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
142# similar to make_index_entry(), but includes the string in the result
143# instead of the dummy filler.
144#
145sub 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 Draked5692421997-12-11 21:46:07 +0000151 local($nstr) = "$str###" . ++$global{'max_id'}; # Make unique
Fred Drakef2d7e551997-12-03 19:44:27 +0000152 $index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
153 "<a name=\"$br_id\">$str<\/a>";
154}
155
156sub add_idx {
157 print "\nDoing the index ...";
Fred Draked5692421997-12-11 21:46:07 +0000158 local($key, $str, @keys, $index, $level, $count,
Fred Drakef2d7e551997-12-03 19:44:27 +0000159 @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 Draked5692421997-12-11 21:46:07 +0000172 }
Fred Drakef2d7e551997-12-03 19:44:27 +0000173 while ($count < $level) {
174 $index .= "</dl>\n";
175 $level--;
Fred Draked5692421997-12-11 21:46:07 +0000176 }
Fred Drakef2d7e551997-12-03 19:44:27 +0000177 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 Draked5692421997-12-11 21:46:07 +0000187 ", $index{$key}" . $cross_ref_visible_mark . "</a>\n" :
Fred Drakef2d7e551997-12-03 19:44:27 +0000188 "<dt>$index{$key}<strong>" . $str . "</strong></a>\n");
189 @previous = @current;
190 }
191 while ($count < $level) {
192 $index .= "</dl>\n";
193 $level--;
Fred Draked5692421997-12-11 21:46:07 +0000194 }
Fred Drakef2d7e551997-12-03 19:44:27 +0000195 s/$idx_mark/<dl compact>$index<\/dl>/o;
196}
197
198
Fred Drakea5a3cdc1997-12-08 20:58:13 +0000199# need to remove leading <...>
200sub 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 Drake784c6d31996-11-11 20:46:44 +00002101; # This must be the last line