From 1d65fd5438ba25051955ac4349e988f15b7371a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B1=9F=E8=BE=B0?= Date: Thu, 30 Mar 2023 12:00:53 +0800 Subject: [PATCH] fix: html tag escaping issue in plugin --- src/node/markdown/plugins/colorPreview.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/node/markdown/plugins/colorPreview.ts b/src/node/markdown/plugins/colorPreview.ts index c6c4fba2..21b4eb85 100644 --- a/src/node/markdown/plugins/colorPreview.ts +++ b/src/node/markdown/plugins/colorPreview.ts @@ -22,8 +22,7 @@ export const colorPreviewPlugin = (md: MarkdownIt) => { md.renderer.rules.text = (tokens, idx) => { let text = tokens[idx].content - text = text.replace(COLOR_REGEX, replaceColor) - - return text + text = md.utils.escapeHtml(text) + return text.replace(COLOR_REGEX, replaceColor) } }