Open ollie27 opened 7 years ago
I might be wrong but is this not a bug with Pulldown-cmark?
No. pulldown-cmark creates the inner link but it's mdBook which naively surrounds the entire header in another <a>
tag: https://github.com/azerupi/mdBook/blob/74e75d2cfbba79bfde31fbb43cc86df0671e4606/src/renderer/html_handlebars/hbs_renderer.rs#L273
Ah right! Sorry, my bad. 😄
So the thing is that we would like the header to be a link to itself so that user can click on the anchor and share the link directly. This can't work if the header is already a link obviously but I have no idea how we should handle that. Maybe add a special case for headers containing a link? I'm not sure.
You can see what GitHub does for example: https://github.com/azerupi/mdBook/blob/master/README.md
If a header contains a link like the following it will result in nested
a
tags which is invalid.This results in:
A possible solution is to put the anchor at the start or end of the header rather than around the whole thing.