Tk Library Source Code

View Ticket
Login
Ticket UUID: 1220090
Title: subsection markup doesn't detect duplicate anchors
Type: Bug Version: None
Submitter: duquette Created on: 2005-06-14 03:24:08
Subsystem: doctools Assigned To: andreas_kupries
Priority: 3 Low Severity:
Status: Closed Last Modified: 2008-05-16 13:47:02
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2008-05-16 06:47:02
Description:
If a doctools file has two "subsection" tags with the same title, the 
two subsections will have identical HTML anchor string.  Doctools 
should issue a warning, and provide a way for the author to resolve 
the ambiguity without necessarily changing their titles.
User Comments: andreas_kupries added on 2008-05-16 13:47:02:
Logged In: YES 
user_id=75003
Originator: NO

Fixed in head. (sub)sections can be given logical names for use in (sub)section references. Anchors are generated internally, different from both (sub)section titles and logical names, always unique (counter). The system warns about ambiguous (sub)section names.

duquette added on 2007-03-21 08:25:50:
Logged In: YES 
user_id=372859
Originator: YES

I have a "section" command that looks like this:

  <<section intro.history.ancient "Ancient History">>

Also, I've switched to using "<<" and ">>" as my expand brackets, in place of "[" and "]".  When
documenting Tcl code, "<<" and ">>" is less like to cause confusion.

andreas_kupries added on 2007-03-21 08:18:23:
Logged In: YES 
user_id=75003
Originator: NO

Mistake - Quite likely. So you have code like

    [subsection FOO intro.history.ancient]

etc. in your documents ? Or do you use two commands ?

    [subsection FOO][label intro.history.ancient]

? (The second would be the LaTeX approach).

Updating Tcllib. With a smart [sectref] and the tags themselves optional updating the sub/section info and references can be done incrementally.

Hm.     [subsection FOO intro.history.ancient]
or      [subsection intro.history.ancient FOO]

Both can support optional tags. The second form is like [uri].

Deep nesting of subsections ... If we do that, it seems that we would not need section and subsection commands anymore, just a section command ? (Right now doctools does not have arbitrarily deep nesting).

In general I think that tagging makes sense. LaTeX uses tags as well, except that tags do not need to have structure. They are just labels for locations. Nesting is limited, and each level has its own command.

Will do some more thinking.

Thanks for the comment.

duquette added on 2007-03-21 06:42:31:
Logged In: YES 
user_id=372859
Originator: YES

Basing section cross-references on the section title strings was a mistake, I think.  It works for small documents, but
breaks down for larger ones.

What I've started doing in my personal code, when formatting larger documents, is give each section a tag which
is a list of period-delimited tokens.  Toplevel sections get a tag that's a single token, i.e., "intro".  Subsections
add a token, i.e., "intro.history" is a subsection of "intro" and "intro.history.ancient" is a subsection of "intro.history".
Cross references use these tags instead of the section titles.  As a bonus, the structure of the tag indicates both
the level of the section and its parentage; you can nest subsections arbitrarily deep, and generate section numbers
automatically if you choose.

Note that the command used to indicate a cross-reference can be smart about this: it can recognize both section titles
(as it does now) and tags.

This would mean updating all of the Tcllib documentation (ugh) but it's probably worth it.

andreas_kupries added on 2007-03-21 03:39:24:
Logged In: YES 
user_id=75003
Originator: NO

Will, what do you think would be a way for the author to resolve the ambiguity without changing the titles ?

andreas_kupries added on 2005-10-04 06:31:31:
Logged In: YES 
user_id=75003

Actually this can be resolved by simply counting
subsections, i.e. generating an anchor based on a unique id
instead of the title. Of course, [sectref] section
references still need disambiguation.

A palliative might be to look for the section the subsection
is in and use it in the construction of the anchor. ... Ah,
not quite, still needs disambiguation of references ...

Ok, it seems the best we can do without user intervention is
warning. For reolsution of ambiguities we need a syntax
change in the format. I.e. sectrefs, sections, and
subsections need optional arguments for guide resolution.

Added code generating warnings to the CVS head. Common
layer, not the engines. ... In tcllib this code is tripped
currently only by the snitfaq.

Keeping open until a complete solution has been committed,
albeit at lower priority for now.