Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-markdown

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-markdown

Renders Markdown as React components

  • 4.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3M
decreased by-17.11%
Maintainers
1
Weekly downloads
 
Created

What is react-markdown?

The react-markdown npm package is a markdown renderer for React applications. It allows you to take Markdown content and render it as React components. This is useful for content-driven applications, such as blogs or documentation sites, where you want to allow content creators to write in Markdown and then display that content within your React application.

What are react-markdown's main functionalities?

Rendering Markdown

This feature allows you to render standard Markdown text as React components. The example code shows how to import the ReactMarkdown component and use it to render a simple piece of Markdown text.

import React from 'react';
import ReactMarkdown from 'react-markdown';

const markdown = '# Hello, *world*!';

function App() {
  return <ReactMarkdown>{markdown}</ReactMarkdown>;
}

export default App;

Custom Renderers

This feature allows you to define custom renderers for different Markdown elements. In the example, a custom renderer is provided for 'h1' elements, which renders them with a blue color.

import React from 'react';
import ReactMarkdown from 'react-markdown';

const markdown = '# Hello, *world*!';

function HeadingRenderer(props) {
  return <h1 style={{ color: 'blue' }}>{props.children}</h1>;
}

function App() {
  return (
    <ReactMarkdown
      components={{
        h1: HeadingRenderer
      }}
    >
      {markdown}
    </ReactMarkdown>
  );
}

export default App;

Inline HTML and Skip HTML

This feature allows you to include or exclude inline HTML within your Markdown content. The example code demonstrates how to skip rendering inline HTML by using the 'skipHtml' prop.

import React from 'react';
import ReactMarkdown from 'react-markdown';

const markdown = 'This is a paragraph with <span style="color: red;">inline HTML</span>.';

function App() {
  return (
    <ReactMarkdown skipHtml>
      {markdown}
    </ReactMarkdown>
  );
}

export default App;

Plugins

This feature allows you to extend the functionality of react-markdown with plugins. The example code shows how to use the 'remark-gfm' plugin to add support for GitHub Flavored Markdown (GFM) task lists.

import React from 'react';
import ReactMarkdown from 'react-markdown';
import gfm from 'remark-gfm';

const markdown = 'This supports GitHub Flavored Markdown (GFM)\n\n- [ ] todo\n- [x] done';

function App() {
  return <ReactMarkdown remarkPlugins={[gfm]}>{markdown}</ReactMarkdown>;
}

export default App;

Other packages similar to react-markdown

Keywords

FAQs

Package last updated on 24 Jun 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc