At 02:45 PM 9/23/2003 +0200, Jens Lehmann wrote:

The next problem is that subsections (and below) have anchors which are not safe for updates, for instance <A NAME="SECTION000420000000000000000">. I would like to have the headings of the subsections and subsubsections as anchor names. I'm aware that this causes trouble if a heading appears more than once within one html file, but this is not a problem in our case. It's important that the mnemonic anchors are the ones which are actually used in the document (for example in the table of contents). How can this be achieved?

The make_section_heading() override below (which can go in ~/.latex2html-init or equivalent) makes symbolic section names using the $LONG_TITLES code (for the filenames). However, these names are not used in the autogenerated contents, and it was not obvious to me where else things need to be modified. Of course I could just keep reading the code, but in the interest of time efficiency, can someone (e.g., Ross?) give us an outline?


Thanks,
Julius

[Place the following in ~/.latex2html-init or replace make_section_heading() in latex2html (version latex2html-2002-2-1)]:

# The following is overridden in order to provide symbolic section names.
# $LONG_TITLES must be set to something greater than 0 (like 3 or 4).
# Created from the version in by jos

sub make_section_heading {
    local($text, $level, $anchors) = @_;
    local($elevel) = $level; $elevel =~ s/^(\w+)\s.*$/$1/;
    local($section_tag) = join('', @curr_sec_id);
    local($align,$pre_anchors);
    local($sectiontag) = "SECTION$section_tag";

# separate any invisible anchors or alignment, if this has not already been done
if (!($anchors)){ ($anchors,$text) = &extract_anchors($text) }
else {
$anchors =~ s/(ALIGN=\"\w*\")/$align = " $1";''/e;
$align = '' if ($HTML_VERSION < 2.2);
$anchors = &translate_commands($anchors) if ($anchors =~ /\\/);
}


    # strip off remains of bracketings
    $text =~ s/$OP\d+$CP//g;

if (!($text)) {
# anchor to a single `.' only
$text = "<A NAME=\"$sectiontag\">.</A>$anchors\n";
} else {
if ($LONG_TITLES) {
$sectiontag = &make_long_title($text);
}
if ($anchors) {
# # put anchors immediately after, except if title is too long
# if ((length($text)<60 )&&(!($align)||($align =~/left/))) {
# $text = "<A NAME=\"$sectiontag\">$text</A>\n" . $anchors;
# ...put anchors preceding the title, on a separate when left-aligned
# } else {
$text = "<A NAME=\"$sectiontag\">$anchor_invisible_mark</A>$anchors"
. (!($align)||($align =~ /left/i ) ? "<BR>" : "") . "\n". $text;
# }
} elsif (!($text =~ /<A[^\w]/io)) {
# no embedded anchors, so anchor it all
$text = "<A NAME=\"$sectiontag\">\n" . $text . "</A>";
} else {
# there are embedded anchors; these cannot be nested
local ($tmp) = $text;
$tmp =~ s/<//o ; # find 1st <
if ($`) { # anchor text before the first <
# $text = "<A NAME=\"$sectiontag\">\n" . $` . "</A>\n<" . $';
$text = "<A NAME=\"$sectiontag\">\n" . $` . "</A>";
$pre_anchors = "<" . $';
if ($pre_anchors =~ /^(<A NAME=\"[^\"]+>${anchor_invisible_mark}<\/A>\s*)+$/) {
$pre_anchors .= "\n"
} else { $text .= $pre_anchors; $pre_anchors = '' }
} else {
# $text starts with a tag
local($after,$tmp) = ($','');
if ( $after =~ /^A[^\w]/i ) {
# it is an anchor already, so need a separate line
$text = "<A NAME=\"$sectiontag\">$anchor_invisible_mark</A><BR>\n$text";
} else {
# Is it a tag enclosing the anchor ?
$after =~ s/^(\w)*[\s|>]/$tmp = $1;''/eo;
if ($after =~ /<A.*<\/$tmp>/) {
# it encloses an anchor, so use anchor_mark + break
$text = "<A NAME=\"$sectiontag\">$anchor_invisible_mark</A><BR>\n$text";
} else {
# take up to the anchor
$text =~ s/^(.*)<A([^\w])/"<A NAME=\"$sectiontag\">$1<A$2"/oe;
}
}
}
}
}
"$pre_anchors\n<$level$align>$text\n<\/$elevel>";
}


_______________________________________________
latex2html mailing list
[EMAIL PROTECTED]
http://tug.org/mailman/listinfo/latex2html

Reply via email to