An idea for within document anchor references

Fletcher T. Penney fletcher at alumni.duke.edu
Sun Aug 21 23:50:01 EDT 2005



On Aug 21, 2005, at 11:03 PM, John Gruber wrote:


> MDK <michaldominik at gmail.com> wrote on 8/21/05 at 6:26 PM:

>

>

>> I miss this feature very much as well. But why don't we use a

>> syntax like:

>>

>> [linked text][header]

>>

>> ...like we do with other links? If the link id ("header") matches any

>> of the header names in the document it's automatically resolved.

>>

>

> Hmm. Interesting idea.

>

> `[header]` is way too long though, and too wordy.


I don't follow you - I think you misunderstood his proposal (which I
understood to be a repetition of my own).

My implementation allows the following:

<EXAMPLE>

### Some Header Text ###

You can point back to [another section][Some Header Text]. Or you
can implicitly link back to [Some Header Text][].

Just like regular implicit links as used in [markdown][]. Or the
reference-style links [like used in markdown][markdown].

[markdown]: http://daringfireball.net/projects/markdown/

</EXAMPLE>


That seems to me to be the most obvious way to do this, and it's more
flexible than what you propose below:


> Off the top of my head:

>

> [matches the text of a header][#]

>

> might work.

>

> The idea would be:

>

> ## This is a header ##

>

> Blah blah blah.

>

> ...

>

> Blah blah, see "[This is a header][#]" for more info.

>

> And then in the markup, each header would get some sort of GUID id

> attribute, and the magic [#] hookup would go to the first header in

> the current article that matches the text of the link. So if you

> have two "This is a header" headers, a `[This is a header][#]` link

> would always point to the first one.


This approach does not allow you to link to a header unless your link
uses the text of the header as the text of the link (which might not
always be desirable or grammatically correct.)

This has all been implemented on my wiki, and the header links are
used in the outline at the top of my local copy of the Markdown Syntax:

http://fletcher.freeshell.org/wiki/MarkdownSyntax

So far, it has worked great, and is much easier than hand-coding
anchors (especially since I don't allow raw HTML on my wiki).

Fletcher


--
Fletcher T. Penney
fletcher at alumni.duke.edu

Just for today, I will not sit in my living room all
day watching TV. Instead I will move my TV into the
bedroom.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3949 bytes
Desc: not available
Url : http://six.pairlist.net/pipermail/markdown-discuss/attachments/20050821/5cc152b5/smime.bin


More information about the Markdown-Discuss mailing list