From f8140192dad90788609d4586c1bfb6e256703145 Mon Sep 17 00:00:00 2001 From: valentine195 <38669521+valentine195@users.noreply.github.com> Date: Tue, 22 Mar 2022 12:48:52 -0400 Subject: [PATCH] feat: Surface callout metadata onto callout in post processor --- src/callout/manager.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/callout/manager.ts b/src/callout/manager.ts index 774482b..34cdb06 100644 --- a/src/callout/manager.ts +++ b/src/callout/manager.ts @@ -54,6 +54,18 @@ export default class CalloutManager extends Component { const admonition = this.plugin.data.userAdmonitions[type]; if (!admonition) return; + //apply metadata + const section = ctx.getSectionInfo(el); + if (section) { + const { text, lineStart } = section; + const definition = text.split("\n")[lineStart]; + + const [, metadata] = definition.match(/> \[!.+\|(.*)]/) ?? []; + if (metadata) { + callout.dataset.calloutMetadata = metadata; + } + } + const titleEl = callout.querySelector(".callout-title"); const content = callout.querySelector(".callout-content"); @@ -128,7 +140,7 @@ export default class CalloutManager extends Component { } } if (this.plugin.data.dropShadow) { - callout.addClass('drop-shadow') + callout.addClass("drop-shadow"); } } getComputedHeights(el: HTMLDivElement): Heights {