@remyst/roles
v0.0.2
Published
A starter set of MyST role specs (subscript, superscript, abbreviation, span, …) for the remyst directive/role registry.
Readme
@remyst/roles
A starter set of MyST role specs for the remyst
directive/role registry. Each spec turns a raw mystRole node ({name}`body`) into a
myst-spec mdast node — subscript, superscript, abbreviation, span, and the reference/citation
roles — with option validation surfaced as messages.
These are ports of mystmd's myst-roles, split out so remyst
stays unopinionated about which roles you register. Reference/citation roles produce their nodes
here; resolving them against labels and bibliography is a later transform. Execution/build roles
(eval, term, index) that depend on a downstream execution layer are not included.
Install
npm install @remyst/roles @remyst/parserUsage
Pass the specs into the parser via the roles option. defaultRoles is the whole built-in set;
individual specs are exported too, so you can register only what you need.
import { process } from '@remyst/parser';
import { defaultRoles } from '@remyst/roles';
const source = 'H{sub}`2`O and E = mc{sup}`2`.\n';
const { tree } = process(source, { roles: defaultRoles });
// `{sub}` / `{sup}` become `subscript` / `superscript` nodes
// Or curate a subset:
import { subscriptRole, superscriptRole, abbreviationRole } from '@remyst/roles';
process(source, { roles: [subscriptRole, superscriptRole, abbreviationRole] });Exported specs include spanRole, subscriptRole, superscriptRole, deleteRole,
underlineRole, smallcapsRole, abbreviationRole, keyboardRole, chemRole, mathRole,
refRole, citeRole, docRole, downloadRole, siRole, and the rawLatexRole / rawTypstRole
pair, plus shared option helpers. The RoleSpec type comes from
remyst.
Made with love by Curvenote. Source at github.com/curvenote/remyst.
