npm install --save md2react
global.React = require('react');
var md2react = require('md2react');
var md = '# Hello md2react';
var html = React.renderToString(md2react(md));
/*
<div data-reactid=".14qrwokr3sw" data-react-checksum="20987480"><h1 data-reactid=".14qrwokr3sw.$_start_root_0_heading"><span data-reactid=".14qrwokr3sw.$_start_root_0_heading.0">Hello md2react</span></h1></div>'
//'<div data-reactid=".58nba97pxc" data-react-checksum="-55236619"><h1 data-reactid=".58nba97pxc.0"><span data-reactid=".58nba97pxc.0.0">Hello</span></h1></div>'
*/
Compiled elements are given checked/unchecked class if bullet has checkbox.
var md = '- [x] a\n- [ ] b\n- c';
var html = React.renderToString(md2react(md, tasklist: true));
<div><ul><li class="checked"><p>a</p></li><li class="unchecked"><p>b</p></li><li class=""><p>c</p></li></ul></div>
Write your checklist style
md2react(markdown: string , mdastOptionsWithSanitize: Object): ReactElement
See mdast detail in wooorm/mdast
And sanitize: true
uses dompurify to raw html input(examle, <span onload='alert(1)'></span>
)
- Support table align
- Update mdast to 0.12.0
- Fix table align
MIT