Skip to content

Commit

Permalink
feat: Surface callout metadata onto callout in post processor
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Mar 22, 2022
1 parent 228b021 commit f814019
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/callout/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement>(".callout-title");
const content =
callout.querySelector<HTMLDivElement>(".callout-content");
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f814019

Please sign in to comment.