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: Patrice Dumas
Subject: Re: [Texi2html-bug] Setting $element->{id} if manual is not split (i.e. element_file_name is not called)?
Date: Mon, 1 Sep 2008 16:35:55 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

On Sat, Aug 30, 2008 at 12:02:11AM +0200, Reinhold Kainhofer wrote:
> 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...

Thanks. In fact the code was wrong, should have been (target, id) 
(and the doc was wrong for placed_target_file_name). It wil be corrected
by the next commit, so your code needs certainly to be changed.

> > 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.

Indeed, but if you don't modify the id, and only want to do a reference
to the object you should use target. 

If you modify the id, you should in general modify the target to have 
it equal to the id.

> 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>

Indeed, but it is the intended result. It may be useful to distinguish
target and id if, for example you want to have a reference to
something that doesn't point to that something, but to the associated
element header.

In your case, you should just set the id equal to the target, I think.

> > 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.

Looks reasonable. However the result of remove_texi may not be valid as
a name="" in html (though all the browser should accept it), it is why
there is some specific mapping of node names to strings valid in name=""
as explained in 

 (texinfo)HTML Xref

> > 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).

Indeed. Using section headings for references is not texinfo-ish, but 
it may be very practical.

The issue I see is not about having unicity among section id, but about 
avoiding having section id use node id.

Anyway I already have turned index entry id which were IDXxx into
something more easy to read when I got fed up not to have any clue about
the real index entry when reading the html. And I have put in the TODO 
section id better handling using the section name as you want, it is
indeed better to have more reproducible section ids. This is not very
high on my TODO list, though.

--
Pat




reply via email to

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