diff options
Diffstat (limited to 'src/build/special_box.mjs')
-rw-r--r-- | src/build/special_box.mjs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/build/special_box.mjs b/src/build/special_box.mjs new file mode 100644 index 0000000..0b284ec --- /dev/null +++ b/src/build/special_box.mjs @@ -0,0 +1,24 @@ +import {visit} from 'unist-util-visit'; + +// This plugin is an example to let users write HTML with directives. +// Itβs informative but rather useless. +// See below for others examples. +/** @type {import('unified').Plugin<[], import('mdast').Root>} */ +export default function specialBox() { + return tree => { + visit(tree, node => { + if (node.type === 'containerDirective' && ( + node.name === 'attention' + || node.name === 'question' + || node.name === 'information')) { + const data = node.data || (node.data = {}); + + data.hName = 'div'; + data.hProperties = { + className: 'special-box ' + node.name, + }; + } + }); + }; +} + |