blob: 1737d56c9d35b76439148ba6d659c46039151ef7 [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
Fred Drake34d6f5b1998-03-04 05:36:59 +00007$NUMBERED_FOOTNOTES = 1;
8
Fred Drake784c6d31996-11-11 20:46:44 +00009# Python documentation uses section numbers to support references to match
10# in the printed and online versions.
11#
12$SHOW_SECTION_NUMBERS = 1;
13
Fred Drake784c6d31996-11-11 20:46:44 +000014$ICONSERVER = '../icons';
15
Fred Drake34d6f5b1998-03-04 05:36:59 +000016$CHILDLINE = "\n<p><hr>\n";
17$VERBOSITY = 0;
Fred Drake784c6d31996-11-11 20:46:44 +000018
Fred Drake784c6d31996-11-11 20:46:44 +000019
Fred Drakef2d7e551997-12-03 19:44:27 +000020sub top_navigation_panel {
21
22 # Now add a few buttons with a space between them
Fred Drake616b23b1997-12-18 14:16:46 +000023 "<div class=navigation>\n" .
Fred Drake70d289d1998-02-16 15:23:11 +000024 "$NEXT\n$UP\n$PREVIOUS\n$CONTENTS\n$INDEX $CUSTOM_BUTTONS" .
Fred Draked5692421997-12-11 21:46:07 +000025
Fred Drake60a3d271998-01-09 14:39:41 +000026 "<br>\n" . # Line break
Fred Draked5692421997-12-11 21:46:07 +000027
Fred Drakef2d7e551997-12-03 19:44:27 +000028 # If ``next'' section exists, add its title to the navigation panel
Fred Drake616b23b1997-12-18 14:16:46 +000029 ($NEXT_TITLE ? "<b> Next:</b> $NEXT_TITLE\n" : undef) .
Fred Draked5692421997-12-11 21:46:07 +000030
Fred Drakef2d7e551997-12-03 19:44:27 +000031 # Similarly with the ``up'' title ...
Fred Drake616b23b1997-12-18 14:16:46 +000032 ($UP_TITLE ? "<b>Up:</b> $UP_TITLE\n" : undef) .
Fred Draked5692421997-12-11 21:46:07 +000033
Fred Drakef2d7e551997-12-03 19:44:27 +000034 # ... and the ``previous'' title
Fred Drake616b23b1997-12-18 14:16:46 +000035 ($PREVIOUS_TITLE ? "<b> Previous:</b> $PREVIOUS_TITLE\n" : undef) .
Fred Draked5692421997-12-11 21:46:07 +000036
37 # Line Break, horizontal rule (3-d dividing line) and new paragraph
Fred Drake34d6f5b1998-03-04 05:36:59 +000038 "<br><hr><p></div>"
Fred Drakef2d7e551997-12-03 19:44:27 +000039}
40
41sub bot_navigation_panel {
42
43 # Start with a horizontal rule (3-d dividing line)
Fred Drake34d6f5b1998-03-04 05:36:59 +000044 "<div class=navigation><hr>".
Fred Drakef2d7e551997-12-03 19:44:27 +000045
46 # Now add a few buttons with a space between them
Fred Drake70d289d1998-02-16 15:23:11 +000047 "$NEXT\n$UP\n$PREVIOUS\n$CONTENTS\n$INDEX $CUSTOM_BUTTONS" .
Fred Drakef2d7e551997-12-03 19:44:27 +000048
Fred Draked5692421997-12-11 21:46:07 +000049 "<br>\n" . # Line break
Fred Drakef2d7e551997-12-03 19:44:27 +000050
51 # If ``next'' section exists, add its title to the navigation panel
Fred Draked5692421997-12-11 21:46:07 +000052 ($NEXT_TITLE ? "<b> Next:</b> $NEXT_TITLE\n" : undef) .
53
Fred Drakef2d7e551997-12-03 19:44:27 +000054 # Similarly with the ``up'' title ...
Fred Draked5692421997-12-11 21:46:07 +000055 ($UP_TITLE ? "<b>Up:</b> $UP_TITLE\n" : undef) .
56
Fred Drakef2d7e551997-12-03 19:44:27 +000057 # ... and the ``previous'' title
Fred Draked5692421997-12-11 21:46:07 +000058 ($PREVIOUS_TITLE ? "<b> Previous:</b> $PREVIOUS_TITLE\n" : undef) .
59
Fred Drake34d6f5b1998-03-04 05:36:59 +000060 "</div>"
Fred Drakef2d7e551997-12-03 19:44:27 +000061}
62
63
Fred Drake34d6f5b1998-03-04 05:36:59 +000064# sub make_section_heading {
65# local($text, $level, $anchors) = @_;
66# local($section_tag) = join('', @curr_sec_id);
67# local($align,$pre_anchors);
68# # separate any invisible anchors or alignment, if this has not already been done
69# if (!($anchors)){ ($anchors,$text) = &extract_anchors($text) }
70# else {
71# $anchors =~ s/(ALIGN=\"\w*\")/$align = " $1";''/e;
72# $anchors = &translate_commands($anchors) if ($anchors =~ /\\/);
73# }
74# if (!($text)) {
75# # anchor to a single `.' only
76# $text = "<a name=SECTION$section_tag>.</a>$anchors\n";
77# } elsif ($anchors) {
78# # keep it short and simple!
79# $text = "<a name=SECTION$section_tag>$text</a>";
80# } elsif (!($text =~ /<A[^\w]/io)) {
81# # no embedded anchors, so anchor it all
82# $text = "<a name=SECTION$section_tag>\n" . $text . "</a>";
83# } else {
84# # there are embedded anchors; these cannot be nested
85# local ($tmp) = $text;
86# $tmp =~ s/<//o ; # find 1st <
87# if ($`) { # anchor text before the first <
88# # $text = "<A NAME=\"SECTION$section_tag\">\n" . $` . "</A>\n<" . $';
89# $text = "<a name=SECTION$section_tag>\n" . $` . "</a>";
90# $pre_anchors = "<" . $';
91# if ($pre_anchors =~ /^(<A NAME=\"[^\"]+>${anchor_invisible_mark}<\/A>\s*)+$/) {
92# $pre_anchors .= "\n"
93# } else { $text .= $pre_anchors; $pre_anchors = '' }
94# } else {
95# # $text starts with a tag
96# local($after,$tmp) = ($','');
97# if ( $after =~ /^A[^\w]/i ) {
98# # it is an anchor already, so need a separate line
99# $text = "<a name=SECTION$section_tag>$anchor_invisible_mark</a><br>\n$text";
100# } else {
101# # Is it a tag enclosing the anchor ?
102# $after =~ s/^(\w)*[\s|>]/$tmp = $1;''/eo;
103# if ($after =~ /<A.*<\/$tmp>/) {
104# # it encloses an anchor, so use anchor_mark + break
105# $text = "<a name=SECTION$section_tag>$anchor_invisible_mark</a><br>\n$text";
106# } else {
107# # take up to the anchor
108# $text =~ s/^(.*)<A([^\w])/"<a name=SECTION$section_tag>$1<A$2"/oe;
109# }
110# }
111# }
112# }
113# "$pre_anchors\n<$level$align>$text\n<\/$level>";
114# }
115
116
Fred Drake819b7891997-12-17 03:08:27 +0000117sub gen_index_id {
118 # this is used to ensure common index key generation and a stable sort
119 local($str,$extra) = @_;
120 sprintf("%s###%s%010d", $str, $extra, ++$global{'max_id'});
121}
122
Fred Drake34d6f5b1998-03-04 05:36:59 +0000123# sub make_index_entry {
124# local($br_id,$str) = @_;
125# # If TITLE is not yet available (i.e the \index command is in the title of the
126# # current section), use $ref_before.
127# $TITLE = $ref_before unless $TITLE;
128# # Save the reference
129# $str = gen_index_id($str, '');
130# $index{$str} .= &make_half_href("$CURRENT_FILE#$br_id");
131# "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
132# }
Fred Drakef2d7e551997-12-03 19:44:27 +0000133
Fred Drake34d6f5b1998-03-04 05:36:59 +0000134# sub add_idx {
135# print "\nDoing the index ...";
136# local($key, $str, @keys, $index, $level, $count, @previous, @current);
137# @keys = keys %index;
138# @keys = sort keysort @keys;
139# $level = 0;
140# foreach $key (@keys) {
141# @current = split(/!/, $key);
142# $count = 0;
143# while ($current[$count] eq $previous[$count]) {
144# $count++;
145# }
146# while ($count > $level) {
147# $index .= "<dl compact>\n";
148# $level++;
149# }
150# while ($count < $level) {
151# $index .= "</dl>\n";
152# $level--;
153# }
154# foreach $term (@current[$count .. $#current-1]) {
155# # need to "step in" a little
156# $index .= "<dt>" . $term . "\n<dl compact>\n";
157# $level++;
158# }
159# $str = $current[$#current];
160# $str =~ s/\#\#\#\d+$//o; # Remove the unique id's
161# $str =~ s/\#\#\#[DR]EF\d+$//o; # Remove the unique id's
162# if (&index_key_eq(join('',@current), join('',@previous))) {
163# $index .= ",\n$index{$key}" . $cross_ref_visible_mark . "</a>"; }
164# else {
165# $index .= "\n<dt>$index{$key}" . $str . "</a>"; }
166# @previous = @current;
167# }
168# while ($count < $level) {
169# $index .= "</dl>\n";
170# $level--;
171# }
172# s/$idx_mark/<dl compact>$index<\/dl>/o;
173# }
Fred Drakef2d7e551997-12-03 19:44:27 +0000174
175
Fred Drake34d6f5b1998-03-04 05:36:59 +0000176# sub index_key_eq {
177# local($a,$b) = @_;
178# $a = &clean_key($a);
179# $a =~ s/\#\#\#\d+$//o; # Remove the unique id's
180# $a =~ s/\#\#\#[dr]ef\d+$//o; # Remove the unique id's
181# $b = &clean_key($b);
182# $b =~ s/\#\#\#\d+$//o; # Remove the unique id's
183# $b =~ s/\#\#\#[dr]ef\d+$//o; # Remove the unique id's
184# $a eq $b;
185# }
Fred Drake819b7891997-12-17 03:08:27 +0000186
Fred Drakea5a3cdc1997-12-08 20:58:13 +0000187# need to remove leading <...>
Fred Drake34d6f5b1998-03-04 05:36:59 +0000188# sub clean_key {
189# local ($_) = @_;
190# tr/A-Z/a-z/;
191# s/\s//;
192# s/^<[a-z][-._a-z0-9]*>//; # Remove leading <gi>
193# $_;
194# }
Fred Drakea5a3cdc1997-12-08 20:58:13 +0000195
196
Fred Drake9b6f1d21998-01-13 04:03:02 +0000197$idx_module_mark = '<tex2html_idx_module_mark>';
198$idx_module_title = 'Module Index';
Fred Drake9b6f1d21998-01-13 04:03:02 +0000199
200sub add_module_idx {
201 print "\nDoing the module index ...";
202 local($key, @keys, $index);
203 $index = "<p>";
204 @keys = keys %Modules;
205 @keys = sort keysort @keys;
206 foreach $key (@keys) {
Fred Drakebaa04a11998-02-19 18:51:39 +0000207 $index .= "$Modules{$key}$key</a><br>\n";
Fred Drake9b6f1d21998-01-13 04:03:02 +0000208 }
209 s/$idx_module_mark/$index<p>/o;
210}
211
212
Fred Drake34d6f5b1998-03-04 05:36:59 +0000213# sub remove_general_markers {
214# s/$lof_mark/<UL>$figure_captions<\/UL>/o;
215# s/$lot_mark/<UL>$table_captions<\/UL>/o;
216# &replace_citations if /$bbl_mark/;
217# &add_toc if (/$toc_mark/);
218# &add_idx if (/$idx_mark/);
219# &add_module_idx if (/$idx_module_mark/);
220# &replace_cross_references if /$cross_ref_mark/;
221# &replace_external_references if /$external_ref_mark/;
222# &replace_cite_references if /$cite_mark/;
223# if (defined &replace_user_references) {
224# &replace_user_references if /$user_ref_mark/;
225# }
226# }
Fred Drake9b6f1d21998-01-13 04:03:02 +0000227
Fred Drake6eb1f6b1998-02-19 21:00:41 +0000228# In addition to the standard stuff, add label to allow named node files.
229sub do_cmd_tableofcontents {
230 local($_) = @_;
Fred Drake6eb1f6b1998-02-19 21:00:41 +0000231 $TITLE = $toc_title;
Fred Drake34d6f5b1998-03-04 05:36:59 +0000232 $tocfile = $CURRENT_FILE;
233 local($closures,$reopens) = &preserve_open_tags();
Fred Drake6eb1f6b1998-02-19 21:00:41 +0000234 &anchor_label("contents",$CURRENT_FILE,$_); # this is added
Fred Drake34d6f5b1998-03-04 05:36:59 +0000235 join('', "<BR>\n", $closures
236 , &make_section_heading($toc_title, "H2"), $toc_mark
237 , $reopens, $_);
Fred Drake6eb1f6b1998-02-19 21:00:41 +0000238}
Fred Drake6eb1f6b1998-02-19 21:00:41 +0000239# In addition to the standard stuff, add label to allow named node files.
240sub do_cmd_listoffigures {
241 local($_) = @_;
242 $TITLE = $lof_title;
243 $loffile = $CURRENT_FILE;
Fred Drake34d6f5b1998-03-04 05:36:59 +0000244 local($closures,$reopens) = &preserve_open_tags();
245 &anchor_label("lof",$CURRENT_FILE,$_); # this is added
246 join('', "<BR>\n", $closures
247 , &make_section_heading($lof_title, "H2"), $lof_mark
248 , $reopens, $_);
249}
Fred Drake6eb1f6b1998-02-19 21:00:41 +0000250# In addition to the standard stuff, add label to allow named node files.
251sub do_cmd_listoftables {
252 local($_) = @_;
253 $TITLE = $lot_title;
254 $lotfile = $CURRENT_FILE;
Fred Drake34d6f5b1998-03-04 05:36:59 +0000255 local($closures,$reopens) = &preserve_open_tags();
256 &anchor_label("lot",$CURRENT_FILE,$_); # this is added
257 join('', "<BR>\n", $closures
258 , &make_section_heading($lot_title, "H2"), $lot_mark
259 , $reopens, $_);
Fred Drake6eb1f6b1998-02-19 21:00:41 +0000260}
Fred Drakebaa04a11998-02-19 18:51:39 +0000261# In addition to the standard stuff, add label to allow named node files.
262sub do_cmd_textohtmlinfopage {
263 local($_) = @_;
Fred Drake34d6f5b1998-03-04 05:36:59 +0000264 if ($INFO) { #
Fred Drakebaa04a11998-02-19 18:51:39 +0000265 &anchor_label("about",$CURRENT_FILE,$_); # this is added
Fred Drake34d6f5b1998-03-04 05:36:59 +0000266 } #
Fred Drakebaa04a11998-02-19 18:51:39 +0000267 ( ($INFO == 1)
Fred Drake34d6f5b1998-03-04 05:36:59 +0000268 ? join('', $close_all
269 , "<STRONG>$t_title</STRONG><P>\nThis document was generated using the\n"
270 , "<A HREF=\"$TEX2HTMLADDRESS\"><STRONG>LaTeX</STRONG>2<tt>HTML</tt></A>"
271 , " translator Version $TEX2HTMLVERSION\n"
272 , "<P>Copyright &#169; 1993, 1994, 1995, 1996, 1997,\n"
273 , "<A HREF=\"$AUTHORADDRESS\">Nikos Drakos</A>, \n"
274 , "Computer Based Learning Unit, University of Leeds.\n"
275 , "<P>The command line arguments were: <BR>\n "
276 , "<STRONG>latex2html</STRONG> <tt>$argv</tt>.\n"
277 , "<P>The translation was initiated by $address_data[0] on $address_data[1]"
278 , $open_all, $_)
279 : join('', $close_all, $INFO,"\n", $open_all, $_))
Fred Drakebaa04a11998-02-19 18:51:39 +0000280}
281
Fred Drake34d6f5b1998-03-04 05:36:59 +0000282# $idx_mark will be replaced with the real index at the end
Fred Drakebaa04a11998-02-19 18:51:39 +0000283sub do_cmd_textohtmlindex {
284 local($_) = @_;
285 $TITLE = $idx_title;
286 $idxfile = $CURRENT_FILE;
Fred Drake34d6f5b1998-03-04 05:36:59 +0000287 if (%index_labels) { &make_index_labels(); }
288 if (($SHORT_INDEX) && (%index_segment)) { &make_preindex(); }
289 else { $preindex = ''; }
290 local($heading) = join('',&make_section_heading($idx_title, "H2"),
291 $idx_mark);
292 local($pre,$post) = &minimize_open_tags($heading);
Fred Drakebaa04a11998-02-19 18:51:39 +0000293 &anchor_label("genindex",$CURRENT_FILE,$_); # this is added
Fred Drake34d6f5b1998-03-04 05:36:59 +0000294 join('',"<BR>\n" , $pre, $_);
Fred Drakebaa04a11998-02-19 18:51:39 +0000295}
296
297# $idx_module_mark will be replaced with the real index at the end
Fred Drake9b6f1d21998-01-13 04:03:02 +0000298sub do_cmd_textohtmlmoduleindex {
299 local($_) = @_;
Fred Drake45a40931998-02-17 23:11:40 +0000300 local($key) = q/modindex/;
Fred Drake9b6f1d21998-01-13 04:03:02 +0000301 $TITLE = $idx_module_title;
Fred Drake45a40931998-02-17 23:11:40 +0000302 &anchor_label("modindex",$CURRENT_FILE,$_);
Fred Drake9b6f1d21998-01-13 04:03:02 +0000303 join('', '<p>' , &make_section_heading($idx_module_title, "h2"),
304 $idx_module_mark, $_);
305}
306
307# The bibliography and the index should be treated as separate sections
308# in their own HTML files. The \bibliography{} command acts as a sectioning command
309# that has the desired effect. But when the bibliography is constructed
310# manually using the thebibliography environment, or when using the
311# theindex environment it is not possible to use the normal sectioning
312# mechanism. This subroutine inserts a \bibliography{} or a dummy
313# \textohtmlindex command just before the appropriate environments
314# to force sectioning.
315
316# XXX This *assumes* that if there are two {theindex} environments, the
317# first is the module index and the second is the standard index. This
318# is sufficient for the current Python documentation, but that's about
319# it.
320
321sub add_bbl_and_idx_dummy_commands {
Fred Drake34d6f5b1998-03-04 05:36:59 +0000322 local($id) = $global{'max_id'};
323
324 $section_commands{'textohtmlmoduleindex'} = 2;
325
Fred Drake9b6f1d21998-01-13 04:03:02 +0000326 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
Fred Drake34d6f5b1998-03-04 05:36:59 +0000327 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo
328 #if ($bbl_cnt == 1)
329 ;
Fred Drake9b6f1d21998-01-13 04:03:02 +0000330 #}
Fred Drake34d6f5b1998-03-04 05:36:59 +0000331 #----------------------------------------------------------------------#
332 # (FLD) This was added #
333 local(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/); #
334 if (scalar(@parts) == 3) { #
335 print "\n&add_bbl_and_idx_dummy_commands ==> adding module index"; #
336 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlmoduleindex $1/o; #
337 } #
338 #----------------------------------------------------------------------#
339 $global{'max_id'} = $id;
Fred Drake9b6f1d21998-01-13 04:03:02 +0000340 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
341 s/[\\]printindex/\\textohtmlindex /o;
342 &lib_add_bbl_and_idx_dummy_commands() if defined(&lib_add_bbl_and_idx_dummy_commands);
343}
344
345# The bibliographic references, the appendices, the lists of figures and tables
346# etc. must appear in the contents table at the same level as the outermost
347# sectioning command. This subroutine finds what is the outermost level and
348# sets the above to the same level;
Fred Drake34d6f5b1998-03-04 05:36:59 +0000349
350%section_commands = ('textohtmlmoduleindex', 2, %section_commands);
351
352# sub set_depth_levels {
353# # Sets $outermost_level
354# local($level);
355# #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
356# foreach $level ("part", "chapter", "section", "subsection",
357# "subsubsection", "paragraph") {
358# last if (($outermost_level) = /\\($level)$delimiter_rx/);
359# }
360# $level = ($outermost_level ? $section_commands{$outermost_level} :
361# do {$outermost_level = 'section'; 3;});
362
363# #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
364# if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
365# $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
366# } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
367
368# %unnumbered_section_commands = (
369# 'tableofcontents', $level
370# , 'listoffigures', $level
371# , 'listoftables', $level
372# , 'bibliography', $level
373# , 'textohtmlindex', $level
374# , 'textohtmlmoduleindex', $level
375# );
376
377# %section_commands = (
378# %unnumbered_section_commands
379# , %section_commands
380# );
381# }
382
383
384# Fix from Ross Moore for ']' in \item[...]; this can be removed once the next
385# patch to LaTeX2HTML is released and tested.
386#
387sub protect_useritems {
388 local(*_) = @_;
389 local($preitems, $thisitem);
390 while (/\\item\s*\[/) {
391 $preitems .= $`; $_ = $';
392 $thisitem = $&.'<<'.++$global{'max_id'}.'>>';
393 s/^(((($O|$OP)\d+($C|$CP)).*\3|<[^<>]*>|[^\]<]+)*)\]/$thisitem.=$1;''/e;
394 $preitems .= $thisitem.'<<'.$global{'max_id'}.'>>]'; s/^]//;
395 }
396 $_ = $preitems . $_;
Fred Drake9b6f1d21998-01-13 04:03:02 +0000397}
Fred Drake34d6f5b1998-03-04 05:36:59 +0000398
Fred Drake784c6d31996-11-11 20:46:44 +00003991; # This must be the last line