rsc / markdown

Basic Markdown parser and HTML generator
BSD 3-Clause "New" or "Revised" License
78 stars 4 forks source link

feature: synthesize lowercase anchors for heading #19

Open adonovan opened 1 month ago

adonovan commented 1 month ago

GitHub's markdown renderer creates lowercase anchors for headings. For example, this heading, ## Diagnostic, can be found using either of these two URLs, which differ in the case of their fragment ID:

https://github.com/golang/tools/blob/master/gopls/doc/settings.md#diagnostic https://github.com/golang/tools/blob/master/gopls/doc/settings.md#Diagnostic

Perhaps your markdown renderer (which has been really useful--thanks!) could do the same.

rsc commented 1 month ago

Is the GitHub algorithm for turning heading text into anchor IDs documented somewhere? I don't mind adding it as an option if I can find the spec. Not sure about two choices, but one automatic choice would be good. (GitHub actually supports any casing at all: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#DiAgNoStIc Clearly JS is doing that.)