🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

react-showdown

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-showdown

Render React components within markdown and markdown as React components!

1.6.0
npm
Version published
Weekly downloads
11K
-23.78%
Maintainers
1
Weekly downloads
 
Created
Source

react-showdown Build status Test coverage Dependency Status

Render React components within markdown and markdown as React components!

Features

Installation

npm install --save react-showdown

Use as React component

Really simple markdown example with ES6/JSX:

import { Markdown } from 'react-showdown';

render: () => {
    var markdown = '# Hello\n\nMore content...';
    return <Markdown markup={ markdown } />
}

Use a React component and use it within the markdown with ES6/JSX:

import { Markdown } from 'react-showdown';

const MyComponent extends Component {
	render() {
		return React.createElement(this.props.tag, null, this.props.children);
	}
};

render: () => {
    var markdown = '# Hello\n\n<MyComponent tag="strong">More Content...</MyComponent>';
    return <Markdown markup={ markdown } components={{ MyComponent }} />
}

Use the converter

Really simple markdown example:

var Converter = require('react-showdown').Converter;
var converter = new Converter();

var markdown = '# Hello\n\nMore content...';
var reactElement = converter.convert(markdown);

Use a React component and use it within the markdown:

var createClass = require('create-react-class');
var MyComponent = createClass({
	render: function() {
		return React.createElement(this.props.tag, null, this.props.children);
	}
});

var Converter = require('react-showdown').Converter;
var converter = new ReactShowdown.Converter({ components: { 'MyComponent': MyComponent }});

var markdown = '# Hello\n\n<MyComponent tag="strong">More Content...</MyComponent>';
var reactElement = converter.convert(markdown);

Available props / converter options

Converter options will be pushed forward to the showdown converter, please checkout the valid options section.

Just the components option is managed by this converter. It define the component name (tag name) to component React class definition (instance of createClass) mapping. See example above.

Credits

Project is based on the markdown parser Showdown and the "forgiving" htmlparser2.

Alternatives

Keywords

react

FAQs

Package last updated on 18 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts