Transforms MDAST tree to bemjson regarding to rules.
$ npm install mdast-util-to-bemjson
const unified = require('unified');
const markdown = require('remark-parse');
const toBemjson = require('mdast-util-to-bemjson');
const mdast = unified().use(markdown).parse('# Hello im _heading_');
const bjson = toBemjson(mdast);
console.log(JSON.stringify(bjson, null, 4));
Yields:
{
"block": "md-root",
"content": {
"block": "heading",
"mods": {
"level": 1
},
"level": 1,
"content": [
"Hello im ",
{
"block": "emphasis",
"content": "heading"
}
]
}
}
- Function augment — callback called on every node.
Code and documentation copyright 2017 YANDEX LLC. Code released under the Mozilla Public License 2.0.