From 8abbe298d545de17d34a9bc1eb72af4c5a4b41b8 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Thu, 14 Aug 2025 09:15:38 +0530 Subject: [PATCH] fix: html entities encoded twice in toc plugin closes #4908 --- src/node/markdown/markdown.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node/markdown/markdown.ts b/src/node/markdown/markdown.ts index f3e168e6..e1d08cac 100644 --- a/src/node/markdown/markdown.ts +++ b/src/node/markdown/markdown.ts @@ -320,7 +320,11 @@ export async function createMarkdownRenderer( .use(titlePlugin) .use(tocPlugin, { slugify, - ...options.toc + ...options.toc, + format: (s) => { + const title = s.replaceAll('&', '&') // encoded twice because of restoreEntities + return options.toc?.format?.(title) ?? title + } } as TocPluginOptions) if (options.math) {