Markdown React
Markdown to React Component converter.
This project uses Markdown parser from Markdown It library, but loosely supports its plugins.
Examples
Basic example
; ... { return <MDReactComponent text='Some text **with emphasis**.' /> ;}
or, using function instead of component:
; ... { return 'Some text **with emphasis**.';}
Result:
Some text with emphasis.
Using custom tags
const TAGS = html: 'span' // root node, replaced by default strong: 'b' em: 'i' ... { return <MDReactComponent text='Some **bold** and *italic* text.' tags=TAGS /> ;}
Result:
Some bold and italic text.
Using custom component renderer
{ if level === 1 props = ...props className: 'first-level-class' ; if Tag === 'a' props = ...props className: 'link-class' href: propshref ; return <Tag ...props>children</Tag>;} ... { return <MDReactComponent text='[This link](SOME_URL) has it’s own style.' onIterate=handleIterate /> ;}
Result:
This link has it’s own style.
Copyright
Forked from
-
markdown-react-js Copyright 2015 Alexander Kuznetsov alexkuz@gmail.com
-
Markdown-it Copyright (c) 2014 Vitaly Puzrin vitaly@rcdesign.ru, Alex Kocharin alex@kocharin.ru
LICENSE
MIT