vmg / sundown

Standards compliant, fast, secure markdown processing library in C
1.99k stars 385 forks source link

Feature Request: Permalink HTML_TOC-enabled headers #86

Closed shazow closed 12 years ago

shazow commented 12 years ago

Would be great if the Markdown headers rendered as links pointing to the TOC permalink. Such as...

# Foo

Would render as...

<h1 id="toc_0"><a href="#toc_0">Foo</a></h1>

If render flags HTML_TOC | HTML_TOC_PERMALINKS are passed.

vmg commented 12 years ago

Sorry, I'm not following. Why would you need the headers to link back to the toc?

Either way, this is trivially easy to implement on your own: just override the header callback on the Markdown struct with a custom function: the library has been designed so custom rendering output (like this case) is very easy to get without having to modify the library itself.

Shout if you're having trouble implementing the new header function; should be pretty straightforward. Cheers!

shazow commented 12 years ago

Sorry, I'm not following. Why would you need the headers to link back to the toc?

So people can easily permalink to specific header sections. :)

... should be pretty straightforward. Cheers!

I'll take a crack at it, thanks for the pointer!

Great work by the way, really enjoying using the library. :)