https://github.com/streamich/md-jml
Markdown to JsonML parser in JavaScript
https://github.com/streamich/md-jml
Last synced: 11 months ago
JSON representation
Markdown to JsonML parser in JavaScript
- Host: GitHub
- URL: https://github.com/streamich/md-jml
- Owner: streamich
- Created: 2016-07-05T19:43:09.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-01-05T09:31:38.000Z (over 8 years ago)
- Last Synced: 2025-08-09T10:43:45.597Z (11 months ago)
- Language: TypeScript
- Size: 29.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `md-jml`
Markdown to JsonML parser. This is a port of [`marked`](https://github.com/chjj/marked) to TypeScript.
Differences:
- Outputs JsonML AST instead of an HTML string.
- Written in TypeScript.
- Does not support highlighting functionality of `marked`, as it is better
to do it by extending the `Ast` constructor function (a.k.a. `Renderer` in `marked`) or
by traversing the resulting JsonML tree.
- Asynchronous AST generation.
- Not tested.
Unlike other Markdown parsers this module returns a JsonML AST of the resulting
HTML instead of just an HTML string.
You can use that JsonML to easily concatenate it to an HTML string or
feed the JsonML to a virtual DOM rendering engine, like `React.js`, `Mithril.js`, `virtual-dom`, etc...
Using `marked` you get an HTML string:
```js
var marked = require('marked');
console.log(marked('I am using __markdown__.'));
//
I am using markdown.
```
However, `md-jml` returns a JsonML tree:
```js
var md = require('md-jml');
md.parse('I am using __markdown__.', {}, function(jml) {
console.log(jml);
});
// [ 'div',
// [ 'p', null,
// 'I am using ',
// [ 'strong', null, 'markdown' ],
// '.'
// ]
// ]
```
You can use the resulting JsonML to generate HTML using the [`jml-h`](http://www.npmjs.com/package/jml-h) package:
```js
var jmlh = require('jml-h');
var html = jmlh.dom(jml);
console.log(html);
//
I am using markdown.
```