Parse markdown string to Abstract Syntax Tree which we defined.
Parse markdown string to Abstract Syntax Tree which we defined.
This package is available on npmjs.org
. You can install via npm
command:
$ npm install markdown-tree-parser
Import this package and apply markdown string.
const mtp = require('markdown-tree-parser');
const text = `
# Heading 1
This is **markdown** text!`;
const tree = mtp(text);
console.log(tree.dump());
>>>
[
{
"name": "heading",
"type": "block",
"level": 1,
"values": [
{
"name": "text",
"type": "inline",
"value": "Heading 1"
}
]
},
{
"name": "paragraph",
"type": "block",
"values": [
{
"name": "text",
"type": "inline",
"value": "This is "
},
{
"name": "em",
"type": "inline",
"value": "markdown"
},
{
"name": "text",
"type": "inline",
"value": " text!"
}
]
}
]
Yoshiaki Sugimoto
MIT