Open EdmundKorley opened 8 years ago
For the #header-&-noise
case, I think the result should be a double dash: #header--noise
The #
thisidentifier
example currently works correctly on GitHub.
The # Header & noise
example is indeed a bug though.
The fix is almost identical to thlorenz/anchor-markdown-header#29.
For the #header-&-noise case, the result should be a single dash: #header-noise.
Tested on github and gitlab - the link generated ignored the ampersand entirely, and uses a single hyphen.
I would guess that it converts all special chars to -
and merges multiple sequenced -
into a single one.
But maybe it is possible to look at the code behind this to be sure?
When parsing: a header named
this
identifier(Note the
code
formating) doctoc yields:#this-identifier
... when it should yield:
#-this-identifier
This is because,
-this-identifier
, rather thanthis-identifier
, is the actual id that GitHub renders when it converts the markdown to HTML for display. As a result the generated doctoc link will not work as a relative link.There are a few other examples of this like:
For
Header & noise
doctoc produces
#header-&-noise
which will lead to a dead link in GitHub markdown rather than the appropriate
#header-noise