pimd
pimd copied to clipboard
Add IDs and anchors to headings
Write a plugin that adds IDs and anchors to headings.
Example
Input:
# Lorem ipsum
Output:
<h1><a href="#lorem-ipsum"><span id="lorem-ipsum"></span></a>Lorem ipsum</h1>
Background
- The extra
<span>
allows manipulating the scroll position (for example when there’s a fixed navigation, this avoids that the headline is hidden behind it) - The
<a>
should be visible on hover and display a#
, link icon or anchor icon (depending on the theme) - This might need to have an additional hook which gets called in
renderInline()