@unified-myst/role-extension
Version:
Extension to support the MyST role syntax (``{name}`content` ``) in unified
37 lines (30 loc) • 642 B
JavaScript
import { tokenTypes } from './constants.js';
/**
* @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension
* @typedef {import('micromark-util-types').Handle} Handle
*/
/**
* The micromark HTML extension, to convert mystRole tokens directly to HTML.
* @type {HtmlExtension}
*/
const mystRoleHtmlExt = {
enter: {
[tokenTypes.mystRole]: enterMystRole
},
exit: {
[tokenTypes.mystRole]: exitMystRole
}
};
/**
* @type {Handle}
*/
function enterMystRole() {
this.tag('<span class="myst-role">');
}
/**
* @type {Handle}
*/
function exitMystRole() {
this.tag('</span>');
}
export { mystRoleHtmlExt };