@remyst/directives
v0.0.2
Published
A starter set of MyST directive specs (admonitions, image, code) for the remyst directive registry.
Readme
@remyst/directives
A starter set of MyST directive specs for the remyst
directive/role registry. Each spec turns a raw mystDirective node into semantic myst-spec
mdast — admonition, image, code, container, math, and friends — by declaring its
options and a run(data) that builds the node.
These are ports of mystmd's myst-directives, kept as a separate registry package so
remyst ships without opinions about which directives you enable.
Execution/build directives (include, embed, toc, bibliography, csv-table, …) that
depend on a downstream execution layer are not part of this set.
Install
npm install @remyst/directives @remyst/parserUsage
Pass the specs into the parser via the directives option. defaultDirectives is the whole
built-in set; you can also import individual specs and assemble your own array.
import { process } from '@remyst/parser';
import { defaultDirectives } from '@remyst/directives';
const source = `\`\`\`{admonition} Heads up
:class: tip
Register directives to get semantic mdast.
\`\`\`
`;
const { tree } = process(source, { directives: defaultDirectives });
// tree now contains an `admonition` node instead of a raw `mystDirective`
// Or curate a subset:
import { imageDirective, figureDirective } from '@remyst/directives';
process(source, { directives: [imageDirective, figureDirective] });Exported specs include admonitionDirective, imageDirective, codeDirective,
codeCellDirective, figureDirective, asideDirective, divDirective, blockquoteDirective,
dropdownDirective, mathDirective, mermaidDirective, iframeDirective, tableDirective,
listTableDirective, and the rawDirective family, plus option helpers
(commonOptions, choice, cssLength, nonNegativeInt, …). The shared DirectiveSpec type comes
from remyst.
Made with love by Curvenote. Source at github.com/curvenote/remyst.
