Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PluginTOC renders permalink symbol from markdown-it #33

Open
davidjost opened this issue Jan 24, 2022 · 1 comment
Open

PluginTOC renders permalink symbol from markdown-it #33

davidjost opened this issue Jan 24, 2022 · 1 comment

Comments

@davidjost
Copy link

davidjost commented Jan 24, 2022

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.

@davidjost
Copy link
Author

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 }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant