mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-02-03 22:15:42 -06:00
make %%init: ...%% in mermaid codeblock effective
only remove comments outside of codeblocks
This commit is contained in:
parent
f346a01296
commit
681491418e
@ -161,7 +161,13 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
||||
textTransform(_ctx, src) {
|
||||
// do comments at text level
|
||||
if (opts.comments) {
|
||||
src = src.replace(commentRegex, "")
|
||||
// Remove %% comments %% outside of codeblocks
|
||||
const codeblockRegex = /```[\s\S]*?```|`[^`\n]+`/
|
||||
const codeblockOrCommentRegex = new RegExp(
|
||||
`(${codeblockRegex.source})|${commentRegex.source}`,
|
||||
"g"
|
||||
)
|
||||
src = src.replace(codeblockOrCommentRegex, (match, codeblock) => codeblock ?? "")
|
||||
}
|
||||
|
||||
// pre-transform blockquotes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user