Zim

Comment 18 for bug 380844

Revision history for this message
Jiří Janoušek (fenryxo) wrote :

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

Unique id is a nice solution for implicit anchors. I should be generated from the text of the heading, e.g. "Chapter One: To be or not to be? → #chapter-one-to-be-or-not-to-be-3
1) replace non-word characters with dash
2) strip multiple dashes and trailing/leading dashes
3) lowercase
4) append number to resolve conflicts (if there is any)

The full id will be prefixed by page path to be unique throughout the notebook, therefore we don't get large conflict number for common headings (#introduction-378). The source code will contain page-unique id. However, these identifiers will be used internally, users will get a list of original headings after pressing # in the insert link dialog.

> But I leave it to the implementer to determine the performance and check for
> bottlenecks. Just trying to think ahead what may become limiting.

Anchors and original text of headings definitely have to be indexed to provide good performance. Also backlinks with anchor have to be indexed to be updated when heading changes.

> To summarize my view of implicit and explicit anchors:
> Like Jiří writes there could be anchor symbols insertable after a heading or anywhere on a page, represented as '#AnchorName' in wiki-syntax. They would be inserted by a menu "Insert anchor" and edited by a context menu "Edit anchor name". Links then may have a postfix '#AnchorName' to lead directly to the named anchor *or* (if non-existing) to the first heading that contains the anchors name. Exporting a html would generate html-anchors, for both cases.

The first implementation will allow anchors only for headings, maybe implicit anchors only.