From 68dff2af8547ae70f6622ac826affd76f2f6378e Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sat, 15 Feb 2025 20:34:35 +0530 Subject: [PATCH] fix(markdown): include content of all tokens in heading ids closes #4561 BREAKING CHANGES: The heading ids might change in some cases if you're using special (non-html) elements in headings. Please update the broken links to fragments if you find any. To revert back to the older behavior you can customize `markdown.anchor.getTokensText`. --- src/node/markdown/markdown.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/node/markdown/markdown.ts b/src/node/markdown/markdown.ts index a39832a4..5d6d909d 100644 --- a/src/node/markdown/markdown.ts +++ b/src/node/markdown/markdown.ts @@ -263,6 +263,12 @@ export async function createMarkdownRenderer( // mdit-vue plugins md.use(anchorPlugin, { slugify, + getTokensText: (tokens) => { + return tokens + .filter((token) => token.type !== 'html_inline') + .map((token) => token.content) + .join('') + }, permalink: anchorPlugin.permalink.linkInsideHeader({ symbol: '​', renderAttrs: (slug, state) => {