texi2html-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texi2html-bug] Setting $element->{id} if manual is not split (i.e.


From: Reinhold Kainhofer
Subject: Re: [Texi2html-bug] Setting $element->{id} if manual is not split (i.e. element_file_name is not called)?
Date: Sat, 30 Aug 2008 00:02:11 +0200
User-agent: KMail/1.9.9

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Mittwoch, 27. August 2008 schrieb Patrice Dumas:
> On Fri, Aug 22, 2008 at 08:43:19PM +0200, Reinhold Kainhofer wrote:
> > The internal links in the text to other sections in the manual work just
> > fine (they use the node anchors), but the TOC does not use the node
> > anchors, but the sections and thus the SECxx anchors (which change quite
> > frequently, when new sections are added to the manual, so they should not
> > be used for bookmarks or sending links to mailing lists!).
> >
> > So, is there any way to modify the id of the elements if a manual is not
> > split?
>
> There was nothing practical. Now there is element_target_name you can
> use (and also 2 other functions you certainly don't need).

Thanks! Works really well! (as usual!)

What is a little confusing with that function is that in the parameters to the 
function call, the order is (element, target, id). The return value on the 
other hand has the order (id, target), which is just the other way round...

> Also, you should use 'target' and not 'id', in your TOC 

Yes, of course, thanks for the hint! I was already wondering why changing only 
the 'target' for the sections did not have an effect to the TOC... 

However, there is still a problem: All sections print out their 'id' as anchor 
and not the 'target', so if you modify only the 'target', then the navigator 
bars don't work, because they use the 'target' as the anchor, which does not 
exist!
That's also the reason why I needed to modify both the id and the target in my 
init script.

Attached is a simple example, run it with:
    texi2html --split=section \
      --init=texi2html_unnumberedsubsubsec_without_node.init \
      texi2html_unnumberedsubsubsec_without_node.texi                           
                  

The init script simply re-implements element_target_name and changes $id and 
$target to "ID_$id" and "Target_$target" to make it easy to see which one is 
printed into the html file.
As you see in the file texi2html_unnumberedsubsubsec_without_node_1.html, 
every section prints out the node target (if the section has a node attached) 
and the section's ID, rather than the section's target. E.g. Chapter 1 has 
the targets:
   <a name="accidental_002dplacement_002dinterface"></a>
   <a name="ID_SEC1"></a>
On the other hand, the navigation bars, all use the target of the sections, 
which does NOT exist in the html file:
   <tr><td valign="middle" align="left">[<a
        href="#Target_accidental_002dplacement_002dinterface" title="Previous
        section in reading order"> &lt; </a>]</td>


> and it should 
> be the node anchor, even for section, but for sections not associated
> with node, you'll still need to process it to have something that doesn't
> change too often.

I use 
    my $node_name = main::remove_texi($element->{'node_ref'}->{'texi'});
    if ($node_name eq '') {
        $node_name = main::remove_texi($element->{'texi'});
    }
So, in general I use the node name to generate the anchor (or rather look it 
up in my map generated by an external script), but if there is no node 
attached, then I use the section name.

> I am reluctant to do some something more intelligent in the default case,
> because of possible non uniqueness. SECxx isn't much better, though, since
> it could be the anchor produced by a node named SECxx. 

For us the issue is not so much to absolutely guarantee uniqueness, but rather 
to provide anchor names, which don't change over time. In particular, we 
often answer user requests by simply posting a link to the documentation. Of 
course, those links should always work. SECxx is bad in that regard, because 
whenever a subsection is added somewhere, everything after that will change 
anchors and the posted links will point to the wrong section (the docs on the 
homepage are updated quite frequently to the latest version...). 
That's why I base the anchor names on the node names (which need to be unique 
in the document, anyway). And for those sections without a node attached: 
Well, that's our problem then to guarantee that the section names are unique 
(at least unique within each section due to our file splitting).

Cheers,
Reinhold

- -- 
- ------------------------------------------------------------------
Reinhold Kainhofer, Vienna University of Technology, Austria
email: address@hidden, http://reinhold.kainhofer.com/
 * Financial and Actuarial Mathematics, TU Wien, http://www.fam.tuwien.ac.at/
 * K Desktop Environment, http://www.kde.org, KOrganizer maintainer
 * Chorvereinigung "Jung-Wien", http://www.jung-wien.at/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIuHHpTqjEwhXvPN0RAm+QAJsHdpelO1i2VNgDKjzMYocbjLAvDgCfSXjq
RLwffnb72WdaeKl0J13iHuc=
=XbUm
-----END PGP SIGNATURE-----

Attachment: texi2html_unnumberedsubsubsec_without_node.init
Description: Text document

Attachment: texi2html_unnumberedsubsubsec_without_node.texi
Description: Text document

Attachment: texi2html_unnumberedsubsubsec_without_node_1.html
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]