Overview

Markie is a demonstration of react-markdown, a versatile markdown component designed for React applications. Below are some key features of react-markdown:

Important Note

Contents

The content below showcases the usage of various plugins:

Syntax Highlighting

Here's an example of syntax highlighting using rehype-highlight:

import React from 'react'; import ReactDOM from 'react-dom'; import Markdown from 'react-markdown'; import rehypeHighlight from 'rehype-highlight'; const markdown = ` # Your markdown here `; ReactDOM.render( <Markdown rehypePlugins={[rehypeHighlight]}>{markdown}</Markdown>, document.querySelector('#content') );

GitHub Flavored Markdown (GFM)

For GFM support, you can use the remark-gfm plugin. It adds support for GitHub-specific extensions such as tables, strikethrough, task lists, and literal URLs.

HTML in Markdown

HTML in markdown can be risky, but if you need to support it, you can use rehype-raw combined with rehype-sanitize for security.

Components

Custom components can be utilized to modify the rendering behavior:

import React from 'react'; import ReactDOM from 'react-dom'; import Markdown from 'react-markdown'; import MyFancyRule from './components/my-fancy-rule.js'; const markdown = ` # Your markdown here `; ReactDOM.render( <Markdown components={{ h1: 'h2', // Render h1 as h2 hr(props) { const { node, ...rest } = props; return <MyFancyRule {...rest} />; } }} > {markdown} </Markdown>, document.querySelector('#content') );

Want to Learn More?

For more detailed information, check out the GitHub repository.