Zim

Comment 13 for bug 380844

Revision history for this message
Jiří Janoušek (fenryxo) wrote : Re: [Bug 380844] Re: Link to anchors within pages

On Sat, Jun 25, 2011 at 06:51, Oliver Joos <email address hidden> wrote:
> @Jiri: Great to hear that you will work on this!!
>
> I fully agree with most points of the previous comment. I have an other
> idea to define anchors: so called "implicit anchors" could simply refer
> a slice of a heading. E.g. if there is a heading "1. My Nice
> Introductory Chapter" on MyPage, an valid anchor would be
> "MyPage#Intro". This works without a separate definition of the anchor,
> and would still be more robust than referring the full heading text. My
> idea is meant to supplement yours.

Good idea. Let's compare pros and cons:

Explicit anchors:
+ Take precedence over implicit ones.
+ Independent on text of the heading (less likely to became invalid)
+ Can be easily implemented in HTML.
- Have to be defined before used

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)

> A heading with implicit anchor would not need to be marked somehow, nor
> should it appear in an anchor list button in the status bar (which is a
> nice idea for explicit anchors). Relating to your last point "Issues" I
> would change the foreground color of anchors to red if they are invalid
> or ambiguous (not unique). Invalid anchors would lead to the top of the
> page, ambiguous anchors to their first match.

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.

> Furthermore the command line interface could make use of anchors: zim
> <notebook> <page#anchor> would place the cursor to the target of the
> given anchor.

I agree.

> Open Issues:
> * should an anchor match case-insensitive to make it even more robust? Case-sensitivity in titles may change, especially on English pages.

Anchors should be case-insensitive, multiple spaces replaced by one
space. Maybe not to distinguish space, underscore and dash?