react-showdown-safe
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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

or

yarn add react-showdown

Use as React component

Example with ES6/JSX:

export default function App() {
  const markdown = `
# Welcome to React Showdown :+1:
 
To get started, edit the markdown in \`example/src/App.tsx\`.
 
| Column 1 | Column 2 |
|----------|----------|
| A1       | B1       |
| A2       | B2       |
`;
 
  return (
    <MarkdownView
      markdown={markdown}
      options={{ tables: true, emoji: true }}
    />
  );
};

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

import MarkdownView from 'react-showdown';
 
function CustomComponent({ name }: { name: string }) {
  return <span>Hello {name}!</span>;
}
 
const markdown = `
# A custom component:
 
<CustomComponent name="world" />`;
 
<MarkdownView markdown={markdown} components={{ CustomComponent }} />

Available props

  • markdown, string, required
  • flavor, Flavor, optional
  • options, ConverterOptions, optional
  • extensions, showdown extensions, optional
  • components, components, optional

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

Credits

Project is based on the markdown parser Showdown and the html parser htmlparser2.

Alternatives

Dependencies (4)

Dev Dependencies (12)

Package Sidebar

Install

npm i react-showdown-safe

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

84.2 kB

Total Files

18

Last publish

Collaborators

  • anuraghazra