Remarkable Markdown Parser

2.0.1 · active · verified Tue Apr 21

Remarkable is a fast, extensible Markdown parser for JavaScript, offering 100% CommonMark specification support, alongside syntax extensions and typographer features. Currently at version 2.0.1, the library provides a robust solution for converting Markdown strings to HTML. Its key differentiators include high performance, a highly configurable parsing engine that allows adding or replacing syntax rules, and a vibrant community plugin ecosystem available via npm. Version 2.0.0 introduced significant changes, including a migration to ES module source code, rollup-based bundling for UMD, CJS, and ESM formats, and a shift to named exports for its public API. The project maintains an active development status, with updates focusing on stability and modern JavaScript practices.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic usage of the Remarkable parser, including default rendering, applying the 'commonmark' preset, and configuring options via the constructor to enable features like HTML tags, line breaks, and typographer rules.

import { Remarkable } from 'remarkable';

// Initialize Remarkable with default settings (similar to GFM, but HTML disabled)
const md = new Remarkable();

// Render a basic Markdown string to HTML
const markdownString = '# Hello, Remarkable!\n\nThis is a *simple* paragraph.';
const htmlOutput = md.render(markdownString);

console.log('--- Default Rendering ---');
console.log(htmlOutput);
// Expected output: <h1>Hello, Remarkable!</h1><p>This is a <em>simple</em> paragraph.</p>

// Demonstrate a common preset: 'commonmark'
const mdCommonMark = new Remarkable('commonmark');
const commonMarkOutput = mdCommonMark.render('1. Ordered list item\n\n- Unordered list item');

console.log('\n--- CommonMark Preset Rendering ---');
console.log(commonMarkOutput);

// Demonstrate setting options via constructor
const mdWithOptions = new Remarkable({
  html: true,         // Enable HTML tags in source
  breaks: true,       // Convert '\n' in paragraphs into <br>
  typographer: true   // Enable smart quotes and other typographic improvements
});

const complexMarkdown = `
# Markdown with Options
<p>This is an HTML paragraph.</p>
Line one.
Line two.

"Smart quotes" should be enabled.
`;
const complexHtmlOutput = mdWithOptions.render(complexMarkdown);

console.log('\n--- Rendering with Custom Options ---');
console.log(complexHtmlOutput);

view raw JSON →