New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-rich-markdown

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-rich-markdown

A ready-to-go component to render rich Markdown snippets (md + LaTex + code sh)

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

react-rich-markdown

A ready-to-go component to render rich Markdown snippets.

The <Markdown /> component renders the contents of its source property with markdown-it and the following plugins:

Usage

import React from 'react';
import Markdown from 'react-rich-markdown';

export class MyComponent extends React.Component {
	render() {
		const opts = { smartarrows: false };
		return (
			<div>
				<h1>{this.props.sometitle}</h1>
				<Markdown source={this.props.sometext} options={opts}/>
			</div>
		);
	}
}

The options property allows to switch off unneeded plugins

{
	"sup": true|false,
	"sub": true|false,
	"smartarrows": true|false,
	/* syntax highlighting */
	"sh": true|false,
	"math": true|false
}

By default all the plugins are loaded.

Styling

The component includes a stylesheet for LaTex expressions and syntax highlighting. It's a very big file because it has all the fonts needed by Katex inlined, so you can setup it quickly with PostCSS or Webpack.

Nonetheless, I strongly recommend to not use this solution in production, and instead go and download Katex styles separately, without the fonts inlined, so the browser isn't forced to download them all at once.

You'll need also Highlight.js styles.

TODOs

  • Testing
  • Support mounting other markdown-it plugins

License

ISC

Keywords

component

FAQs

Package last updated on 03 Dec 2015

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