Skip to content

Commit 8abbe29

Browse files
committed
fix: html entities encoded twice in toc plugin
closes #4908
1 parent e25f228 commit 8abbe29

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/node/markdown/markdown.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,11 @@ export async function createMarkdownRenderer(
320320
.use(titlePlugin)
321321
.use(tocPlugin, {
322322
slugify,
323-
...options.toc
323+
...options.toc,
324+
format: (s) => {
325+
const title = s.replaceAll('&', '&') // encoded twice because of restoreEntities
326+
return options.toc?.format?.(title) ?? title
327+
}
324328
} as TocPluginOptions)
325329

326330
if (options.math) {

0 commit comments

Comments
 (0)