From 4ae56664a44902e73fd68854261df74efe3dcd10 Mon Sep 17 00:00:00 2001 From: Sam Hendry <134175998+SamHendry@users.noreply.github.com> Date: Tue, 13 Jan 2026 11:38:05 -0800 Subject: [PATCH] Add Regex for handling comment endings Since Obsidian honors unterminated comments, these must also be filtered out, which the current Regex does not do. --- quartz/plugins/transformers/ofm.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index 7a523aa59..341dc2cea 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -130,6 +130,7 @@ export const tableWikilinkRegex = new RegExp(/(!?\[\[[^\]]*?\]\]|\[\^[^\]]*?\])/ const highlightRegex = new RegExp(/==([^=]+)==/g) const commentRegex = new RegExp(/%%[\s\S]*?%%/g) +const commentEndRegex = new RegExp(/%%[\s\S]*?$/) // from https://github.com/escwxyz/remark-obsidian-callout/blob/main/src/index.ts const calloutRegex = new RegExp(/^\[\!([\w-]+)\|?(.+?)?\]([+-]?)/) const calloutLineRegex = new RegExp(/^> *\[\!\w+\|?.*?\][+-]?.*$/gm) @@ -162,6 +163,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin> // do comments at text level if (opts.comments) { src = src.replace(commentRegex, "") + src = src.replace(commentEndRegex, "") } // pre-transform blockquotes