3.3.1 • Published 6 years ago
react-markdown-github v3.3.1
react-markdown-github
A React component that wraps react-markdown that:
- links all headers with an anchor link.
- resolves all relative links to absolute Github URLs based on the sourceUri of the document.
- e.g. /foo/bar.md becomes https://github.mycorp.com/org/component/blob/master/foo/bar.md
- allows the parent component to override the resolved url.
Installation
npm install react-markdown-githubUsage
<MarkdownGithub
source={ markdown }
sourceUri='https://github.mycorp.com/org/component/blob/master/README.md'
transformLinkUri={ ({ uri, github, org, repo, filename, filepath }) => { } }
transformImageUri={ ({ uri, github, org, repo, filename }) => {} }
renderers={ code: myCodeFormatter }
className='myClass' />Component Properties
sourceUriAbsolute URL to orgional markdown. All relative links will be resolved relative to this URL.transformLinkUriURL resolver function. To override the URL resolver and point a url to an alternate location.transformImageUriimage URL resolver function. Default behavior is to not modify image urls.renderersAn object of render function values with keys corresponding to Node Type to be passed to react-markdown.classNamethe CSS class passed to react-markdown.
Test
npm test