Tags:
create new tag
, view all tags

Feature Proposal: Auto-generated anchor name for ToC varies

Motivation

When creating a FAQ topic, for example, one would like the individual entries to have fixed anchor names so that they can be referenced easily from other topics, via e-mail, and via code.

Description and Documentation

I'd like to be able to attach an anchor name to a heading that can be referenced from that topic's ToC and from other topics, sent in an e-mail, or generated via code (given relevant information) without fear of the anchor name changing. The current behavior is for the link to be generated from the heading text. Since there are documented problems with that approach and since any change to the heading text can break extant references to the anchor, providing the user with a means to specify the anchor name will prevent broken links.

I propose that ---+ style headings support the [[anchor-name][heading text]] syntax. I further propose that %TOC% recognize that format or, if it parses the rendered code after the fact, use the provided anchor name rather than generating its own.

This approach also means that fixed links can be supplied for pages that don't use a %TOC%.

Examples

Impact

WhatDoesItAffect: Rendering, UI, Usability, Vars

Implementation

-- Contributors: RobStewart - 15 Jun 2007

Discussion

MakeAnchorVariable is related to this. Either of the two proposals would satisfy the need.

-- PankajPant - 15 Jun 2007

Is there a reason you can't use standard TWiki anchors for this? For example #ThisIsAnAnchor at the start of a line?

-- CrawfordCurrie - 15 Jun 2007

I use manual anchors currently for url's I am going to pass around, but the fact that the %TOC% doesn't use it is a pain. The TOC link is what most people use when sending anchors to others that reference sections of a document. MakeAnchorVariable doesn't quite do it since it doesn't override what TOC produces. It simply returns an anchor from some text that is the same as what TOC would produce if the text was a section heading.

-- JohnRouillard - 15 Jun 2007

MakeAnchorVariable addresses what you specified in your original usage model, i.e. linking to FAQ entries. If you FAQ entries starts with a heading, you type %MAKEANCHOR{FAQ heading}% and it generates the same anchor that TOC uses. You don't need to explicitly create an anchor for each entry. If the TOC algorithm changes, all your links are transparently fixed too. This works really well for auto-generated links, e.g. a random "FAQ of the day".

It doesn't, however, work for your second use model where you want to email a link to a heading. You'd have to add a specific anchor in this case.

-- PankajPant - 16 Jun 2007

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2007-06-16 - PankajPant
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.