npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

markdown-renderer-react

v1.0.4

Published

一个功能强大、可定制的 React Markdown 渲染组件,支持语法高亮、数学公式、HTML 渲染和多种主题样式。

Downloads

15

Readme

React Markdown Renderer

npm version License: MIT TypeScript GitHub Pages

A powerful, customizable React Markdown rendering component with syntax highlighting, math formulas, HTML rendering, and multiple theme styles.

English | 中文

✨ Features

  • 🎨 Multiple Theme Styles - Built-in dark, academic, minimal, colorful themes
  • 📝 Complete Markdown Support - Full GFM (GitHub Flavored Markdown) support
  • 🎯 Code Syntax Highlighting - Prism.js-based syntax highlighting
  • 🧮 Math Formula Rendering - LaTeX math formulas with KaTeX
  • 🔧 Flexible Configuration - Customizable styles and component configuration
  • 🛡️ Safe HTML Filtering - Built-in HTML sanitization with DOMPurify
  • 📱 Responsive Design - Adapts to various screen sizes
  • 🎪 Storybook Documentation - Complete component examples and documentation
  • Lightweight - Optimized bundle size (~1.6MB ES module, ~980KB gzipped)

📦 Installation

npm install markdown-renderer-react
# or
yarn add markdown-renderer-react

🚀 Quick Start

import { MarkdownRenderer } from 'markdown-renderer-react';

function App() {
  const content = `
# Hello World

This is a **Markdown** rendering example.

\`\`\`javascript
console.log('Hello, World!');
\`\`\`

Math formula: $E = mc^2$
  `;

  return (
    <MarkdownRenderer
      content={content}
      enableSyntaxHighlight={true}
      enableMath={true}
    />
  );
}

📚 API Documentation

Props

| Property | Type | Default | Description | |----------|------|---------|-------------| | content | string | - | Markdown content | | enableHtml | boolean | true | Enable HTML rendering | | enableMath | boolean | true | Enable math formulas | | enableSyntaxHighlight | boolean | true | Enable syntax highlighting | | enableGfm | boolean | true | Enable GFM | | className | string | - | Custom CSS class name | | sanitizeHtml | boolean | true | Sanitize HTML content | | enableThinkSection | boolean | true | Enable think section processing | | styleConfig | MarkdownStyleConfig | - | Style configuration |

🎨 Theme Examples

Dark Theme

<MarkdownRenderer
  content={content}
  styleConfig={{
    backgroundColor: "#1a1a1a",
    color: "#e5e5e5",
    // ... more configuration
  }}
/>

Academic Style

<MarkdownRenderer
  content={content}
  styleConfig={{
    fontFamily: "'Times New Roman', serif",
    fontSize: "16px",
    lineHeight: "1.8",
    // ... more configuration
  }}
/>

Modern Minimal

<MarkdownRenderer
  content={content}
  styleConfig={{
    fontFamily: "'SF Pro Display', system-ui, sans-serif",
    backgroundColor: "#fefefe",
    maxWidth: "700px",
    // ... more configuration
  }}
/>

🎨 Built-in Themes

Import and use predefined themes:

import { MarkdownRenderer } from 'markdown-renderer-react';
import { darkTheme, academicTheme, modernMinimalTheme } from 'markdown-renderer-react/examples';

<MarkdownRenderer content={content} styleConfig={darkTheme} />

🛠️ Development

# Install dependencies
npm install

# Start development server
npm run dev

# Start Storybook
npm run storybook

# Build
npm run build

# Type checking
npm run type-check

📖 Documentation

🌐 Live Demo: https://zhengliu92.github.io/react-markdown

Run Storybook to view complete component documentation and examples:

npm run storybook

🎯 Advanced Usage

Custom Components

const customComponents = {
  h1: ({ children }) => <h1 className="custom-h1">{children}</h1>,
  code: ({ className, children }) => (
    <code className={`custom-code ${className}`}>{children}</code>
  ),
};

<MarkdownRenderer
  content={content}
  components={customComponents}
/>

Math Formulas

Supports both inline and block math:

Inline math: $E = mc^2$

Block math:
$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$

Code Highlighting

Supports multiple programming languages:

```javascript
function fibonacci(n) {
  if (n <= 1) return n;
  return fibonacci(n - 1) + fibonacci(n - 2);
}
```

```python
def hello_world():
    print("Hello, World!")
```

🔧 Configuration

Style Configuration Interface

interface MarkdownStyleConfig {
  fontSize?: string;
  fontFamily?: string;
  lineHeight?: string | number;
  color?: string;
  backgroundColor?: string;
  padding?: string;
  margin?: string;
  maxWidth?: string;
  headings?: {
    h1?: Partial<MarkdownStyleConfig>;
    h2?: Partial<MarkdownStyleConfig>;
    // ... h3-h6
  };
  codeBlock?: {
    backgroundColor?: string;
    borderRadius?: string;
    padding?: string;
    fontSize?: string;
    fontFamily?: string;
  };
  inlineCode?: {
    backgroundColor?: string;
    color?: string;
    padding?: string;
    borderRadius?: string;
    fontSize?: string;
    fontFamily?: string;
  };
  blockquote?: {
    borderLeft?: string;
    paddingLeft?: string;
    fontStyle?: string;
    backgroundColor?: string;
    margin?: string;
  };
}

🤝 Contributing

We welcome Pull Requests and Issues!

Development Setup

  1. Clone the repository
  2. Install dependencies: npm install
  3. Start development: npm run dev
  4. Run Storybook: npm run storybook

Guidelines

  • Follow TypeScript best practices
  • Add tests for new features
  • Update documentation
  • Follow the existing code style

📄 License

MIT License - see LICENSE for details.

🙏 Acknowledgments