Skip to content

Commit 4f2b04c

Browse files
Feature: Add support for calloutMetaData
Manually adding changes to `ofm.ts` from Quartz commits: - #1172 - #1174
1 parent 3169d34 commit 4f2b04c

File tree

1 file changed

+4
-3
lines changed
  • quartz/plugins/transformers

1 file changed

+4
-3
lines changed

quartz/plugins/transformers/ofm.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ export const tableWikilinkRegex = new RegExp(/(!?\[\[[^\]]*?\]\])/, "g")
124124
const highlightRegex = new RegExp(/==([^=]+)==/, "g")
125125
const commentRegex = new RegExp(/%%[\s\S]*?%%/, "g")
126126
// from https://github.com/escwxyz/remark-obsidian-callout/blob/main/src/index.ts
127-
const calloutRegex = new RegExp(/^\[\!(\w+)\]([+-]?)/)
128-
const calloutLineRegex = new RegExp(/^> *\[\!\w+\][+-]?.*$/, "gm")
127+
const calloutRegex = new RegExp(/^\[\!(\w+)\|?(.+?)?\]([+-]?)/)
128+
const calloutLineRegex = new RegExp(/^> *\[\!\w+\|?.*?\][+-]?.*$/, "gm")
129129
// (?:^| ) -> non-capturing group, tag should start be separated by a space or be the start of the line
130130
// #(...) -> capturing group, tag itself must start with #
131131
// (?:[-_\p{L}\d\p{Z}])+ -> non-capturing group, non-empty string of (Unicode-aware) alpha-numeric characters and symbols, hyphens and/or underscores
@@ -428,7 +428,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
428428

429429
const match = firstLine.match(calloutRegex)
430430
if (match && match.input) {
431-
const [calloutDirective, typeString, collapseChar] = match
431+
const [calloutDirective, typeString, calloutMetaData, collapseChar] = match
432432
const calloutType = canonicalizeCallout(typeString.toLowerCase())
433433
const collapse = collapseChar === "+" || collapseChar === "-"
434434
const defaultState = collapseChar === "-" ? "collapsed" : "expanded"
@@ -490,6 +490,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
490490
className: classNames.join(" "),
491491
"data-callout": calloutType,
492492
"data-callout-fold": collapse,
493+
"data-callout-metadata": calloutMetaData,
493494
},
494495
}
495496
}

0 commit comments

Comments
 (0)