eleventy-plugin-toc
eleventy-plugin-toc copied to clipboard
PluginTOC renders permalink symbol from markdown-it
trafficstars
Environment
Node version: v17.0.1
OS/version: Mac OS 11.6 Big Sur
Eleventy
Eleventy version: 0.12.1
Template engine: Nunjucks
Plugin
Plugin module version: 1.1.0
Description of the issue
PluginTOC renders everything inside the h(n) tag. Markdown-it generates permalinks by placing an a tag inside the h(n) tag.
Desired output
PluginTOC renders the text content of the h(n) tag and ignores any other markup inside it.
I solved it by writing an 11ty filter, the ☍ is the permalink symbol:
// .eleventy.js
eleventyConfig.addFilter("removeSymbol", function(value) {
value.val = value.val.replace(/ ☍/g, "");
return value;
});
This needs to be applied in the template:
{{ content | toc | safe | removeSymbol }}