Skip to content

Commit

Permalink
Comment regex (fixes jackyzha0#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
saberzero1 committed Oct 31, 2024
1 parent f64e277 commit 1f9ee47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions quartz/plugins/transformers/text/htmlComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
6 changes: 3 additions & 3 deletions quartz/plugins/transformers/text/ofmComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down

0 comments on commit 1f9ee47

Please sign in to comment.