From 1f9ee4735e1a446016d53d622610cfb598d64cd2 Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Thu, 31 Oct 2024 19:51:59 +0100 Subject: [PATCH] Comment regex (fixes https://github.com/jackyzha0/quartz/issues/1114) --- quartz/plugins/transformers/text/htmlComments.ts | 6 +++--- quartz/plugins/transformers/text/ofmComments.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/quartz/plugins/transformers/text/htmlComments.ts b/quartz/plugins/transformers/text/htmlComments.ts index 49e3c6ed2ecf2..dd3da780a3c65 100644 --- a/quartz/plugins/transformers/text/htmlComments.ts +++ b/quartz/plugins/transformers/text/htmlComments.ts @@ -11,16 +11,16 @@ export const HtmlComments: TextTransformerPlugin = () => { if (src instanceof Buffer) { src = src.toString() } // capture all codeblocks before parsing comments - const codeBlocks = Array.from(src.matchAll(codeBlockRegex), (x) => x[1].toString()) + const codeBlocks = Array.from(src.matchAll(codeBlockRegex), (x) => x[1]) src = src.replaceAll(codeBlockRegex, "###codeblockplaceholder###") src = src.replaceAll(commentRegex, "") // Restore codeblocks - codeBlocks.forEach((codeblock) => { + for (const codeblock of codeBlocks) { src = src.replace("###codeblockplaceholder###", codeblock) - }) + } return src }, diff --git a/quartz/plugins/transformers/text/ofmComments.ts b/quartz/plugins/transformers/text/ofmComments.ts index dbf0224961149..82a1e1c95b718 100644 --- a/quartz/plugins/transformers/text/ofmComments.ts +++ b/quartz/plugins/transformers/text/ofmComments.ts @@ -19,10 +19,10 @@ export const ObsidianFlavoredMarkdownComments: TextTransformerPlugin = () => { src = src.replaceAll(commentRegex, "") - // Restore codeblocks - codeBlocks.forEach((codeblock) => { + // Restore codeblock + for (const codeblock of codeBlocks) { src = src.replace("###codeblockplaceholder###", codeblock) - }) + } return src },