Parsing inline markdown syntax for simple rich text support.
MIT License
Lightweight inline markdown syntax parser for simple rich text support.
npm i react-inline-markdown
import React from 'react';
import ReactDOM from 'react-dom';
import { InlineMarkdown } from 'react-inline-markdown';
const App = () => {
return (
<div>
<InlineMarkdown
markdown={`Hi! I _am_ *Malcolm* Kee.
Checkout [my website](https://malcolmkee.com)`}
/>
</div>
);
};
ReactDOM.render(<App />, document.getElementById('root'));
At the moment only 4 markdown syntaxes are supported:
[link-text](link-url)
_italic_
*bold*
Besides, you can combine them together, i.e. _*test*_
will work.
<InlineMarkdown />
Accepted Props:
Required: markdown
(string)
The markdown string to be parsed, e.g. I *am* _react-inline-markdown_
.
Optional: renderers
: an object of four properties (strong
, em
, a
, p
)
Functions that returns React Elements. Used to customize how markdown will be rendered.
parseMarkdown
: (markdown: string) => InlineMarkAST[]Internal function to generate the AST for the markdown.