How to add anchor links to Markdown headings? #887
-
I would like to have permalinks at the headlines like: <h2 id="nice-headline">Nice Headline <a href="#nice-headline>#</a></h2>
I have already looked for extensions and also searched here in the discussions, but couldn't find anything. Before I try to understand the toc extension and convert it into something suitable, I wanted to ask you if you might know something or can give me the decisive tip. Many thanks in advance! EDIT: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
I suppose you are looking for an automated solution? But just in case you missed the least invasive method, here's how to do this in markdown. Adding an anchor link just after the markdown heading:
In this case the heading ID has to be written separately as a special attribute, because the anchor link otherwise will become a part of the automatically generated ID. To avoid this, and also for accessibility reasons you could write down the anchor on the next line.
Markdown is fun! 😁 |
Beta Was this translation helpful? Give feedback.
-
It seems that PHP Markdown, the standard parser used by Yellow, does allow a function to achieve this:
When I have time, I will give a glance to |
Beta Was this translation helpful? Give feedback.
Hi Giovanni,
the ID is already given to the heading. If not, the ID is generated by the JavaScript. By the way, the instructions here work without any problems: https://attacomsian.com/blog/deep-anchor-links-javascript