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

markdown-to-jsx

Package Overview
Dependencies
Maintainers
2
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-to-jsx

Convert markdown to JSX with ease for React and React-like projects. Super lightweight and highly configurable.

  • 7.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.1M
decreased by-5.82%
Maintainers
2
Weekly downloads
 
Created

What is markdown-to-jsx?

The markdown-to-jsx package is an npm package that allows you to parse and render Markdown content as React components. It is lightweight and customizable, making it a good choice for projects that need to convert Markdown to JSX without heavy dependencies.

What are markdown-to-jsx's main functionalities?

Basic Markdown Parsing

This feature allows you to render basic Markdown text as React components. The example code shows how to import the Markdown component from the package and use it to render a simple Markdown string.

import Markdown from 'markdown-to-jsx';

const markdownInput = '# Hello World!';

function App() {
  return <Markdown>{markdownInput}</Markdown>;
}

Custom Components

This feature allows you to use custom components to render specific parts of the Markdown content. In the example, a custom anchor component is used to replace the default rendering of links.

import Markdown from 'markdown-to-jsx';
import MyCustomComponent from './MyCustomComponent';

const markdownInput = '[Click me](#custom)';

const options = {
  overrides: {
    a: {
      component: MyCustomComponent,
      props: {
        className: 'my-custom-class'
      }
    }
  }
};

function App() {
  return <Markdown options={options}>{markdownInput}</Markdown>;
}

Markdown Options

This feature allows you to customize the parsing and rendering behavior of the Markdown content. The example demonstrates how to use options to modify the default behavior, such as forcing block-level rendering or customizing the slugify function.

import Markdown from 'markdown-to-jsx';

const markdownInput = 'Hello, *world*!';

const options = {
  forceBlock: true,
  forceInline: false,
  slugify: (text) => text.toLowerCase().replace(/\s/g, '-')
};

function App() {
  return <Markdown options={options}>{markdownInput}</Markdown>;
}

Other packages similar to markdown-to-jsx

Keywords

FAQs

Package last updated on 20 Nov 2024

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