Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
markdown-to-react-components
Advanced tools
Readme
Convert markdown into react components
There are several projects that claims to convert markdown using React, but that is not exactly right. They produce one single React component with some plain markdown converted HTML in it. They do not produce React components of the markdown syntax. But this project does!
npm install markdown-to-react-components
import React from 'react';
import MTRC from 'markdown-to-react-components';
MTRC.configure({
h1: React.createClass({
render() {
return <h1 id={this.props.id} style={{color: 'red'}}>{this.props.children}</h1>
}
})
});
const Editor = React.createClass({
getInitialState() {
return {
content: null
};
},
onTextareaChange(event) {
this.setState({
content: MTRC(event.target.value).tree
});
},
render() {
return (
<div>
<div>{this.state.content}</div>
<textarea onChange={this.onTextareaChange}/>
</div>
);
}
});
export default Editor;
You will have to include the Prism.js library and its css manually in your project. Look in the example app to see how this is done.
```javascript
var foo = 'bar';
```
```html
<h1>Hello world!</h1>
```
Supported languages can be found over at prism.js.
Allows you to configure custom elements for your markdown.
MTRC.configure({
h1: React.createClass({
render() {
return <h1 style={{color: 'red'}}>{this.props.children}</h1>
}
})
});
MTRC('# Hello there').tree // React virtual dom tree
MTRC('# Hello there').toc // [{children: [], level: 1, title: 'Hello there', id: 'hello-there'}]
npm install
npm start
http://localhost:8080/webpack-dev-server/bundle
FAQs
Convert markdown into react components
The npm package markdown-to-react-components receives a total of 130 weekly downloads. As such, markdown-to-react-components popularity was classified as not popular.
We found that markdown-to-react-components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.