Skip to content

Commit

Permalink
📒 Support basic callouts that use *.qmd syntax (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Dec 12, 2022
1 parent 6c52577 commit 48ae328
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-gifts-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-cli': patch
---

Support basic callout admonitions that use the QMD format (e.g. `{.callout-tip}`). More to come in the future!
13 changes: 13 additions & 0 deletions packages/myst-cli/src/process/myst/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,14 @@ const Header: IDirective = {
hast: (h, node) => h(node, 'header'),
};

function aliasDirectiveHack(directive: IDirective['myst']): IDirective {
return {
myst: directive,
mdast: { type: '_' },
hast: (h, node) => h(node, '_'),
};
}

export const directives = {
image: Image,
'r:var': RVar,
Expand All @@ -808,4 +816,9 @@ export const directives = {
header: Header,
grid: Grid,
'grid-item-card': Card,
'.callout-note': aliasDirectiveHack(directivesDefault.note),
'.callout-warning': aliasDirectiveHack(directivesDefault.warning),
'.callout-important': aliasDirectiveHack(directivesDefault.important),
'.callout-tip': aliasDirectiveHack(directivesDefault.tip),
'.callout-caution': aliasDirectiveHack(directivesDefault.caution),
};

0 comments on commit 48ae328

Please sign in to comment.