Zim

Comment 14 for bug 380844

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote : Re: [Bug 380844] Re: Link to anchors within pages

2011/6/25 Jiří Janoušek <email address hidden>

> Implicit anchors
> + No need to define them, therefore quicker to use.
> - Dependent on text of the heading (more likely to became invalid)
> - Can't be easily implemented in HTML (JavaScript look-up function needed)
>

I favor implicit anchors over explicit ones - I even doubt if there should
be explicit anchors at all. My guess is that 99% of the time you want to
link to a section, which has an heading, or some other inline object like an
image / table / etc. I would add the pro "more natural to use".

Implementation in HTML is less difficult than it sounds - no javascript
needed I think. When exporting you can set an anchor tag on each heading.
For links you just need to replace the implicit anchor with the explicit
anchor for that heading.

This requires looking up e.g. the full text of that heading - so maybe we
should keep these in the index as well. But if we keep all explicit anchors
in an index table, why not implicit anchors as well ?

Similar it should be possible to update links when an heading changes text.
Another way to deal with this is to assign each heading an unique ID
(preferable unique throughout the notebook) and deal with this as a kind of
hidden explicit anchor. So make it look like the user that you link the
heading directly, but keep the unique ID in the index for this link, so it
keeps the reference even when the text changes. But maybe I'm now making it
more complex than it needs be....

> I agree invalid anchors (not unique) should be marked. But I'm not
> sure about marking links to missing anchors, because Zim doesn't even
> mark links to missing pages. It should be consistent.

Well I would welcome a patch that does similar marking for links to
non-existing pages etc.

-- Jaap