A modified version of marked and marked-ast that can produce an abstract syntax tree for Markdown from a single js file.
IMPORTANT This fork of the project not set up to update from npm sources, I'll work on that later. I just needed a non-nodejs version of this for a project and thought someone else might find it useful.
Tests do not function and need reworked.
//var marked = require('marked-ast');
var ast = marked.parse('_This is **Markdown**_, he said.');
var html = marked.render(ast);
The package is just a wrapper for marked
, so the produced HTML should be identical (if it isn't it's a bug). The AST produced in the example would look like this:
[
{
"type": "paragraph",
"text": [
{
"type": "em",
"text": [
"This is ",
{
"type": "strong",
"text": [ "Markdown" ]
}
]
},
", he said."
]
}
]
Basic setup:
git clone https://github.com/elijahz/marked-ast.git
cd marked-ast
cp ./markedast.js ~/ProjectDir/markedast.js