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

simple-customize-markdown-converter

v1.3.2

Published

Transform Markdown into fully customizable HTML or React components.

Readme

Simple Customize Markdown Converter

This simple library help you convert Markdown to HTML and customize it.

Feature

This library currently supports the most common Markdown syntaxes:

  • Headings (#, ##, …)
  • Paragraphs
  • Bold (\*\*text\*\*)
  • Italic (\*text\* or \_text\_)
  • Strikethrough (\~\~text\~\~)
  • Inline code (\code``)
  • Code blocks (\``lang ... ````)
  • Quotes (> text)
  • Lists (- Item 1,...)
  • Tasklists (- [ ], - \[x\])
  • Links (\[link\]\(url\))
  • Images (\[alt\]\(url\))
  • Horizontal lines (--- or *** or ___)
  • Tables

And customizable renderer for all elements

Install

npm install simple-customize-markdown-converter

Usage

1. Standard HTML

const input = `
# Hello World
This is **bold** and *italic*
`
console.log(convertMarkdownToHTML(input))

Output:

<h1>Hello World</h1>
<p>This is <strong>bold</strong> and <em>italic</em></p>

2. ReactJS Integration (v1.1.0+)

Render Markdown directly as ReactJS elements.

Using the provided component

import { MarkdownComponent } from 'simple-customize-markdown-converter/react';

function App() {
  return (
    <MarkdownComponent 
      content="# Hello React" 
      className="md-body"
      options={{ converterOptions: { allowDangerousHtml: false } }}
    />
  );
}

Using the render function

import { convertMarkdownToReactNode } from 'simple-customize-markdown-converter/react';

const node = convertMarkdownToReactNode("## Subtitle");
return <div>{node}</div>;

Customization

1. Customize your HTML converter

You can also customize which HTML should be rendered which every commmon Markdown syntax.

For example: change <h1> to <h5>, wrap paragraphs in <div>, or style bold text:

const options: MarkdownDefaultOptions = {
  renderOptions: {
    elements: {
      Header: (node, children) => {
          //Customize for only Heading 1
          if (node.level === 1) {
              return `<h5 class="custom-h1">${children.join("")}</h5>`
          }
          //Keep all remain Heading
          return `<h${node.level}>${children.join("")}</h${node.level}>`
      },
      Paragraph: (_node, children) => `<div class="paragraph">${children.join("")}</div>`,
      Bold: (_node, children) => `<b class="bold-text">${children.join("")}</b>`,
    }
  },
  converterOptions: { allowDangerousHtml: false }
}

const input = `
# Title
Hello **World**
`

console.log(convertMarkdownToHTML(input, MarkdownDefaultOptions))

Output:

<h5 class="custom-h1">Title</h5>
<div class="paragraph">Hello <b class="bold-text">World</b></div>

2. Customize React Elements

You can override default elements using MarkdownReactOptions.

import { MarkdownReactOptions } from 'simple-customize-markdown-converter';

const options: MarkdownReactOptions = {
  renderOptions: {
    elements: {
      // Custom Blue Bold text
      Bold: (_node, children) => <strong style={{ color: 'blue' }}>{children}</strong>,
      // Custom Link behavior (e.g., for Mentions)
      Link: (node) => {
        if (node.href.startsWith('@')) {
            return <button className="mention">{node.text}</button>;
        }
        return <a href={node.href}>{node.text}</a>;
      }
    }
  }
};

3. Customize className (v1.2.1+)

You can custom CSS class name for each elements

  • For HTML
const renderOptions: RenderOption<string> = {
  className: {
    Header: "common-h",
    Header1: "main-title",
    Paragraph: "text-muted"
  }
};

const md = "# Title\nParagraph content";
const result = convertMarkdownToHTML(md, { renderOptions });

Output:

<h1 class="main-title" style="border-bottom: 1px solid #d1d9e0b3">Title</h1>
<p class="text-muted">Paragraph content</p>
  • For ReactJS
import { MarkdownComponent } from 'simple-customize-markdown-converter/react';

const options: MarkdownOptions<React.ReactNode> = {
  renderOptions: {
    className: {
      Header: "h-common",
      Header2: "h2-special",
      Bold: "font-heavy"
    }
  }
};

function App() {
  return (
    <MarkdownComponent 
      content="# Hello React" 
      className="md-body"
      options
    />
  );
}

Plugin (v1.3.0+)

You can create a plugin to define custom sytax rule handler

  • With default converter
import { DefaultMarkdownConverter } from 'simple-customize-markdown-converter';

const emojiPlugin = createPlugin<string, React.ReactNode>(
  "Emoji",
  "inline",
  {
      match: (lexer) => lexer.peek() === ":",
      emit: (lexer) => {
        lexer.next();
        const value = lexer.readUntil(":");
        lexer.listToken.push({ type: "Emoji", value });
      }
  },
  {
    execute: (parser, token) => {
      parser.next(1);
      return { type: "Emoji", value: token.value };
    }
  },
  {
    render: (node) => React.createElement(
      "span",
      { className: `emoji emoji-${node.value}` },
      "😲"
    )
  }
);

const converter = new DefaultMarkdownConverter({}, plugin).convert(input)
  • With React converter
import { MarkdownComponent } from 'simple-customize-markdown-converter/react';

function App() {
  const emojiPlugin = createPlugin<string, React.ReactNode>(
    "Emoji",
    "inline",
    {
        match: (lexer) => lexer.peek() === ":",
          emit: (lexer) => {
            lexer.next();
            const value = lexer.readUntil(":");
            lexer.listToken.push({ type: "Emoji", value });
          }
    },
    {
      execute: (parser, token) => {
        parser.next(1);
        return { type: "Emoji", value: token.value };
      }
    },
    {
      render: (node) => React.createElement(
        "span",
        { className: `emoji emoji-${node.value}` },
        "😲"
      )
    }
  );

  return (
    <MarkdownComponent 
      content="Hello :omg: world"
      className="md-body"
      options=options
      plugin=[emojiPlugin]
    />
  );
}

Security

By default, HTML tags in Markdown are escaped. To allow raw HTML, explicitly set allowDangerousHtml: true in converterOptions. Be sure only enable this for trusted content.

Note: Upgrade to React v19.2.0 or later when using React 19 for security reason.