pipr.tools

md-to-html

Simple Markdown to HTML conversion

</> Web

Try it

stdin0 chars
stdout0 chars

Example

Convert Markdown to HTML

Usage
$ echo "# Hello

This is **bold** and *italic*.

- Item one
- Item t..." | md-to-html
View source
(input) => {
      return input
        .replace(/^### (.+)$/gm, "<h3>$1</h3>")
        .replace(/^## (.+)$/gm, "<h2>$1</h2>")
        .replace(/^# (.+)$/gm, "<h1>$1</h1>")
        .replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
        .replace(/\*(.+?)\*/g, "<em>$1</em>")
        .replace(/`(.+?)`/g, "<code>$1</code>")
        .replace(/^\- (.+)$/gm, "<li>$1</li>")
        .replace(/^(?!<[hlo])(.*\S.*)$/gm, "<p>$1</p>")
        .replace(/\n{2,}/g, "\n");
    }

Suggested Pipelines

Related Tools