Add Regex for handling comment endings

Since Obsidian honors unterminated comments, these must also be filtered out, which the current Regex does not do.
This commit is contained in:
Sam Hendry 2026-01-13 11:38:05 -08:00 committed by GitHub
parent f346a01296
commit 4ae56664a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<Partial<Options>>
// do comments at text level
if (opts.comments) {
src = src.replace(commentRegex, "")
src = src.replace(commentEndRegex, "")
}
// pre-transform blockquotes