From 00b93ca5cee3403d45bb95b5c51affea1058519e Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 2 Jul 2024 08:19:19 +0900 Subject: [PATCH] revert markdown process changes --- src/ts/parser.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ts/parser.ts b/src/ts/parser.ts index 457af734..72d83fb8 100644 --- a/src/ts/parser.ts +++ b/src/ts/parser.ts @@ -23,7 +23,7 @@ const markdownItOptions = { breaks: true, linkify: false, typographer: true, - quotes: '“”‘’', + quotes: '\u{E9b0}\u{E9b1}\u{E9b2}\u{E9b3}', //placeholder characters to convert to real quotes } const md = markdownit(markdownItOptions) @@ -79,18 +79,18 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => { function renderMarkdown(data:string){ return md.render(data) - .replace(/“/gu, '“') - .replace(/”/gu, '”') - .replace(/‘/gu, '‘') - .replace(/’/gu, '’') + .replace(/\uE9b0/gu, '“') + .replace(/\uE9b1/gu, '”') + .replace(/\uE9b2/gu, '‘') + .replace(/\uE9b3/gu, '’') } async function renderHighlightableMarkdown(data:string) { let rendered = mdHighlight.render(data) - .replace(/“/gu, '“') - .replace(/”/gu, '”') - .replace(/‘/gu, '‘') - .replace(/’/gu, '’') + .replace(/\uE9b0/gu, '“') + .replace(/\uE9b1/gu, '”') + .replace(/\uE9b2/gu, '‘') + .replace(/\uE9b3/gu, '’') console.log(rendered) const highlightPlaceholders = rendered.match(/(.+?)<\/pre-hljs-placeholder>/gms) console.log(highlightPlaceholders)