devkits-markdown-tools
v1.0.7
Published
Parse and render Markdown to HTML. Extract headings, generate TOC. Zero-dependency Markdown utilities for developers.
Maintainers
Readme
@devkits/markdown-tools
Parse and render Markdown to HTML. Extract headings, generate TOC. Zero-dependency Markdown utilities for developers.
💰 Support DevKits
Love these tools? Support development via Open Collective
- $5/mo - Supporter (priority support)
- $9/mo - Pro (early access to new tools)
- $29 - Lifetime (all current + future Pro features)
💎 Upgrade to DevKits Pro
Get access to 20+ premium tools including SQL to Code, Data Faker, JWT Generator, and more — all for $9 one-time.
💡 Pay with Crypto: BTC, ETH, USDT (TRC-20), SOL accepted. View crypto addresses
🧰 DevKits Pro Tools
This package is part of DevKits — 82+ free developer tools. The online Markdown Editor offers live preview, export to PDF/HTML, and theme customization.
Installation
npm install @devkits/markdown-toolsUsage
const {
render,
extractHeadings,
toc,
countWords,
parseInline
} = require('@devkits/markdown-tools');
const md = `
# Hello World
This is **bold** and *italic* text.
## Features
- Item 1
- Item 2
- Item 3
### Code Example
\`\`\`javascript
console.log('Hello');
\`\`\`
> This is a blockquote
| Col1 | Col2 |
|------|------|
| A | B |
`;
// Render Markdown to HTML
const html = render(md);
// '<h1>Hello World</h1><p>This is <strong>bold</strong>...'
// Extract headings
const headings = extractHeadings(md);
// [
// { level: 1, text: 'Hello World', id: 'hello-world' },
// { level: 2, text: 'Features', id: 'features' },
// { level: 3, text: 'Code Example', id: 'code-example' }
// ]
// Generate table of contents
const tableOfContents = toc(md);
// '<ul><li><a href="#hello-world">Hello World</a>...'
// Count words
const stats = countWords(md);
// { words: 25, chars: 234, lines: 20 }
// Parse inline elements only
parseInline('**bold** and *italic*');
// '<strong>bold</strong> and <em>italic</em>'API
render(markdown)
Renders full Markdown text to HTML string.
Supports:
- Headers (h1-h6)
- Bold, italic, strikethrough
- Inline code and code blocks
- Links and images
- Ordered and unordered lists
- Blockquotes
- Tables
- Horizontal rules
parseInline(text)
Parses only inline elements (no blocks).
extractHeadings(markdown)
Extracts all headings with level, text, and generated ID.
toc(markdown, options)
Generates HTML table of contents.
Options:
minLevel: Minimum heading level (default: 1)maxLevel: Maximum heading level (default: 6)
countWords(markdown)
Counts words, characters, and lines (excluding code blocks).
escapeHtml(s)
Escapes HTML special characters.
Supported Markdown
| Element | Syntax |
|---------|--------|
| Headers | # H1 through ###### H6 |
| Bold | **text** or __text__ |
| Italic | *text* or _text_ |
| Strikethrough | ~~text~~ |
| Code | `code` and ``` |
| Links | [text](url) |
| Images |  |
| Lists | - item or 1. item |
| Blockquotes | > quote |
| Tables | \| col \| |
| HR | --- or *** |
See Also
🔧 More DevKits Tools
Free Tools (82+): | Tool | Description | |------|-------------| | base64-tool | Base64 encode/decode | | chmod-calculator | Unix permissions converter | | cron-parser | Cron expression parser | | csv-json-converter | CSV ↔ JSON converter | | diff-checker | Text comparison (LCS) |
💎 DevKits Pro — $9 One-Time
Unlock 20+ premium tools with a single payment:
💡 Pay with Crypto: BTC, ETH, USDT (TRC-20), SOL accepted
🚀 Other Products from Us
| Product | Description | |---------|-------------| | Invoicely | Free invoice generator for freelancers | | SnapOG | Free OG image generator (20+ templates) |
License
MIT
