mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-09 21:42:15 +00:00
Mismatch in case when using anchors #333
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Skotasma on GitHub (Oct 9, 2019).
First of all thanks for the good work!
Maybe I'm doing it wrong, but my anchors don't work:
I'm simply using the advanced extensions to generate HTML from md.
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
What happens is, that in the link the name is preserved, but in the id the name is lower case.
As a result anchors don't work.
Example:
Generates
Thanks!
@MihaZupan commented on GitHub (Oct 9, 2019):
There seems to be a consensus among different Markdown parsers as to how the heading id is generated. In other words, making the identifier lower-case is by design.
The solution is to use the lower-case identifier when linking to the heading.
@xoofx commented on GitHub (Oct 9, 2019):
Yeah. there are several rules, including replacing space by
-or collapsing non alpha-numeric characters...etc.So basically by design. Not sure it is worth adding a different rule, while these links would not work at all on GitHub for example (or even Gitlab), so better to use the common accepted rule
Closing this issue. If you really want this feature, you can try a PR to bring it to the AutoIdentifier extension.
@Skotasma commented on GitHub (Oct 10, 2019):
Thanks for the quick reply!
As this is not really usable, I'll hope I get people to use this format for anchors:
This works and you don't need to guess the correct text to use for the link, esp. thinking of more complicated headings spaces, numbers, special characters etc.
@xoofx commented on GitHub (Oct 10, 2019):
You can also avoid explicit anchors in that case:
Or in this documentation for example the entire table of content was generated using the mdtoc tool inside markdig repo. It was really fine for this case.
Otherwise, if you want an absolute control on the anchors, yes, there is no other way than using direct inline HTML