diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index 5c2f4b25c..9ec04802c 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -126,7 +126,7 @@ export const tableRegex = new RegExp(/^\|([^\n])+\|\n(\|)( ?:?-{3,}:? ?\|)+\n(\| // matches any wikilink, only used for escaping wikilinks inside tables export const tableWikilinkRegex = new RegExp(/(!?\[\[[^\]]*?\]\]|\[\^[^\]]*?\])/g) -const highlightRegex = new RegExp(/==([^=]+)==/g) +const highlightRegex = new RegExp(/==([^=]+?)==/g) const commentRegex = new RegExp(/%%[\s\S]*?%%/g) // from https://github.com/escwxyz/remark-obsidian-callout/blob/main/src/index.ts const calloutRegex = new RegExp(/^\[\!([\w-]+)\|?(.+?)?\]([+-]?)/) @@ -203,6 +203,12 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin> }) } + // pre-transform highlights + if (opts.highlight) { + src = src.replace(highlightRegex, + `$1`) + } + return src }, markdownPlugins(_ctx) { @@ -291,19 +297,6 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin> ]) } - if (opts.highlight) { - replacements.push([ - highlightRegex, - (_value: string, ...capture: string[]) => { - const [inner] = capture - return { - type: "html", - value: `${inner}`, - } - }, - ]) - } - if (opts.parseArrows) { replacements.push([ arrowRegex,