Skip to content

Commit 68dff2a

Browse files
committed
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`.
1 parent 6031dbc commit 68dff2a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/node/markdown/markdown.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ export async function createMarkdownRenderer(
263263
// mdit-vue plugins
264264
md.use(anchorPlugin, {
265265
slugify,
266+
getTokensText: (tokens) => {
267+
return tokens
268+
.filter((token) => token.type !== 'html_inline')
269+
.map((token) => token.content)
270+
.join('')
271+
},
266272
permalink: anchorPlugin.permalink.linkInsideHeader({
267273
symbol: '​',
268274
renderAttrs: (slug, state) => {

0 commit comments

Comments
 (0)