Markdown-it Parser

14.1.1 · active · verified Tue Apr 21

Markdown-it is a high-performance and highly extensible Markdown parser, currently at version 14.1.1. It strictly follows the CommonMark specification while also offering several useful syntax extensions like URL autolinking, smart typography (typographer), and HTML tag support. Known for its speed and configurability, users can easily add, modify, or replace parsing rules and extend functionality via a rich ecosystem of community-developed plugins available on npm. It prioritizes safety by design and is suitable for both Node.js and browser environments. The project maintains an active development pace with frequent updates, ensuring ongoing compatibility and feature enhancements.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic markdown-it initialization with common options, renders a block of Markdown text, and shows inline rendering for single-line content.

import markdownit from 'markdown-it';

// Initialize markdown-it with specific options
const md = markdownit({
  html: true,        // Enable HTML tags in source
  linkify: true,     // Autoconvert URL-like text to links
  typographer: true  // Enable smart quotes and other typographic replacements
});

// Example 1: Basic rendering
const markdownText1 = '# Hello, markdown-it!\n\nThis is a *simple* paragraph with an [example link](https://example.com).';
const htmlResult1 = md.render(markdownText1);
console.log('Basic Render:\n', htmlResult1);

// Example 2: Render inline content (without paragraph wrap)
const markdownText2 = '__markdown-it__ rulezz!';
const htmlResult2 = md.renderInline(markdownText2);
console.log('\nInline Render:\n', htmlResult2);

// Example 3: Demonstrating typographer and linkify
const markdownText3 = 'Check out google.com or write "hello" here.';
const htmlResult3 = md.render(markdownText3);
console.log('\nTypographer & Linkify:\n', htmlResult3);

view raw JSON →