Package Exports
- commonmark-react-renderer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (commonmark-react-renderer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
commonmark-react-renderer
Renderer for CommonMark which returns an array of React elements, ready to be used in a React component. See react-markdown for such a component.
Installing
npm install --save commonmark-react-rendererBasic usage
var CommonMark = require('commonmark');
var ReactRenderer = require('commonmark-react-renderer');
var parser = new CommonMark.Parser();
var renderer = new ReactRenderer();
var input = '# This is a header\n\nAnd this is a paragraph';
var ast = parser.parse(input);
var result = renderer.render(ast);
// `result`:
[
<h1>This is a header</h1>,
<p>And this is a paragraph</p>
]Options
Pass an object of options to the renderer constructor to configure it. Available options:
sourcePos- boolean Setting totruewill adddata-sourceposattributes to all elements, indicating where in the markdown source they were rendered from (default:false).escapeHtml- boolean Setting totruewill escape HTML blocks, rendering plain text instead of inserting the blocks as raw HTML (default:false).skipHtml- boolean Setting totruewill skip inlined and blocks of HTML (default:false).softBreak- string Setting tobrwill create<br>tags instead of newlines (default:\n).
Testing
git clone git@github.com:rexxars/commonmark-react-renderer.git
cd commonmark-react-renderer
npm install
npm testLicense
MIT-licensed. See LICENSE.