Markdown to HTML Conversion
Write in Markdown, share as a polished web page — zero dependencies for viewers
Staleness Watch: See EXTERNAL-API-REGISTRY.md for source URLs and recheck cadence
Convert Markdown documents into self-contained HTML files with embedded CSS, base64 images, and Mermaid diagram rendering. Ready for quick-share distribution, offline viewing, print, or email attachment.
When to Use
- Sharing formatted documents without requiring Word or PDF viewers
- Creating self-contained HTML pages for offline distribution
- Generating printable web pages from Markdown sources
- Quick previews of documentation with professional styling
- Email attachments that open in any browser
- Static site generation from Markdown sources
Supported Formatting
| Format |
Status |
Notes |
| Headings |
✅ |
H1-H6 with styled colors |
| Bold/Italic |
✅ |
Standard emphasis |
| Links |
✅ |
Styled with underline on hover |
| Images |
✅ |
Base64 embedded or linked |
| Code blocks |
✅ |
Syntax highlighting, monospace font |
| Inline code |
✅ |
Background highlight |
| Tables |
✅ |
Striped rows, header styling |
| Blockquotes |
✅ |
Left border, italic style |
| Lists |
✅ |
Ordered, unordered, nested |
| Task lists |
✅ |
Checkbox rendering |
| Mermaid diagrams |
✅ |
PNG or table fallback |
| SVG |
✅ |
Inline or base64 embedded |
| Horizontal rules |
✅ |
Styled dividers |
| Footnotes |
✅ |
Via pandoc |
| Math (KaTeX) |
⚠️ |
Requires --katex flag |
Key Features
| Feature |
Details |
| Style presets |
professional, academic, minimal, dark |
| Self-contained |
All CSS embedded in <style> block, no external deps |
| Image embedding |
Local images converted to base64 data URIs |
| Mermaid support |
PNG rendering or table fallback for diagrams |
| Print-ready |
CSS @media print rules included |
| TOC generation |
Optional table of contents via --toc |
| Frontmatter |
Extracted for title, stripped from output |
Usage
# Basic conversion (professional style)
node .github/muscles/md-to-html.cjs report.md
# Academic style with TOC
node .github/muscles/md-to-html.cjs thesis.md --style academic --toc
# Dark mode output
node .github/muscles/md-to-html.cjs docs.md --style dark
# Mermaid diagrams rendered as PNG (high quality)
node .github/muscles/md-to-html.cjs architecture.md --mermaid-png
# Custom output path
node .github/muscles/md-to-html.cjs README.md output/readme.html
# Dry run (validate without generating)
node .github/muscles/md-to-html.cjs report.md --dry-run
# Debug mode (save preprocessed markdown)
node .github/muscles/md-to-html.cjs report.md --debug
Options Reference
| Option |
Default |
Description |
--style PRESET |
professional |
Style preset: professional, academic, minimal, dark |
--toc |
off |
Generate table of contents from headings |
--embed-images |
true |
Convert local images to base64 data URIs |
--no-embed-images |
- |
Keep image paths as-is (external references) |
--strip-frontmatter |
true |
Remove YAML frontmatter from output |
--mermaid-png |
off |
Render Mermaid as PNG (requires mmdc) |
--mermaid-fallback |
default |
Convert Mermaid to table representation |
--debug |
off |
Save preprocessed markdown as _debug_combined.md |
--dry-run |
off |
Validate only, no HTML output |
Style Presets
| Preset |
Font |
Max Width |
Colors |
Best For |
| professional |
Segoe UI |
900px |
Blue headings, white bg |
Business docs, reports |
| academic |
Palatino Linotype |
750px |
Dark headings, cream bg |
Papers, theses |
| minimal |
Inter |
800px |
Black/gray, white bg |
Clean, modern pages |
| dark |
Segoe UI |
900px |
Light text, dark bg |
Dark mode preference |
Mermaid Diagram Support
| Diagram Type |
PNG Mode |
Fallback Mode |
| Flowchart |
✅ Full render |
✅ Table |
| Sequence |
✅ Full render |
✅ Table |
| Class |
✅ Full render |
✅ Table |
| State |
✅ Full render |
✅ Table |
| ER |
✅ Full render |
✅ Table |
| Gantt |
✅ Full render |
⚠️ Limited |
| Pie |
✅ Full render |
✅ Table |
| Journey |
✅ Full render |
⚠️ Limited |
PNG Mode (--mermaid-png): Requires mermaid-cli (mmdc). Renders at scale 8, 2400px width for crisp output. Diagrams are embedded as base64 PNGs.
Fallback Mode (default): No external dependencies. Converts diagram syntax to an ASCII table representation suitable for text-only viewing.
Print Styling
HTML output includes @media print CSS rules:
- Page breaks before H1 headings
- No background colors (ink-friendly)
- Link URLs shown after text
- Code blocks with borders instead of background
- Proper margins for binding
Batch Processing
# Convert all markdown files in a directory
for file in docs/*.md; do
node .github/muscles/md-to-html.cjs "$file" --style professional
done
# PowerShell equivalent
Get-ChildItem docs/*.md | ForEach-Object {
node .github/muscles/md-to-html.cjs $_.FullName --style professional
}
Troubleshooting
| Problem |
Cause |
Solution |
| "pandoc not found" |
pandoc not installed |
winget install pandoc |
| Mermaid not rendering |
mmdc not installed |
npm install -g @mermaid-js/mermaid-cli or use fallback |
| Images missing |
Relative paths broken |
Use --embed-images (default) |
| Output too wide on print |
Style preset issue |
Use academic style for print |
| Special characters garbled |
Encoding issue |
Ensure source is UTF-8 |
Requirements
- Node.js 18+
- pandoc (
winget install pandoc)
- mermaid-cli (optional, only for
--mermaid-png)
Muscle Script
.github/muscles/md-to-html.cjs (v1.0.0)
Conversion Acceptance Decision Table
| Condition |
Verdict |
Action |
| All headings, lists, tables, code blocks render correctly |
Accept |
Ship as-is |
| Mermaid diagrams rendered as PNG/SVG with correct layout |
Accept |
Verify diagram labels readable |
| Mermaid diagrams missing or show raw syntax |
Reject |
Check mermaid-cli installed; re-run with --mermaid-png |
| Math equations (KaTeX/MathJax) render correctly |
Accept |
Spot-check complex equations |
| Math equations show raw LaTeX source |
Reject |
Verify KaTeX CSS/JS included in template |
| Embedded images display at correct size |
Accept |
Confirm no broken <img> tags |
| Images missing or show broken placeholders |
Reject |
Check paths are relative and files exist |
| CSS custom properties resolve (colors, fonts) |
Accept |
Visual spot-check against brand |
| Inline styles lost or overridden by browser defaults |
Warning |
Add !important or inline fallbacks |
| Output file size >5MB for a simple document |
Warning |
Check for unoptimized base64 images |
| HTML validates (no unclosed tags, no script injection) |
Accept |
Required for security |
HTML contains <script> from untrusted source |
Reject |
Sanitize; only allow known libraries |
Related Skills
- md-to-word — Sister converter for Word document output
- md-to-eml — Sister converter for email distribution
- md-scaffold — Generate converter-ready Markdown templates
- markdown-mermaid — Diagram authoring for embedded Mermaid
- lint-clean-markdown — Pre-validate markdown before conversion
- nav-inject — Add navigation tables for multi-file suites
Skill version: 2.0.0 | Last updated: 2026-04-14 | Category: document-conversion
1---2type: skill3lifecycle: stable4name: md-to-html-25description: "Convert Markdown to standalone HTML pages with embedded CSS, images, and Mermaid diagrams"6tier: standard7inheritance: inheritable8applyTo: '**/*md-to-html*,**/*convert*html*'9muscle: .github/muscles/md-to-html.cjs10currency: 2026-04-2211metadata:12 source: https://skillmd.com/skills/fabioc-aloha/md-to-html-213---1415# Markdown to HTML Conversion1617> Write in Markdown, share as a polished web page — zero dependencies for viewers1819> **Staleness Watch**: See [EXTERNAL-API-REGISTRY.md](../../EXTERNAL-API-REGISTRY.md) for source URLs and recheck cadence2021Convert Markdown documents into self-contained HTML files with embedded CSS, base64 images, and Mermaid diagram rendering. Ready for quick-share distribution, offline viewing, print, or email attachment.2223---2425## When to Use2627- Sharing formatted documents without requiring Word or PDF viewers28- Creating self-contained HTML pages for offline distribution29- Generating printable web pages from Markdown sources30- Quick previews of documentation with professional styling31- Email attachments that open in any browser32- Static site generation from Markdown sources3334---3536## Supported Formatting3738| Format | Status | Notes |39|--------|--------|-------|40| **Headings** | ✅ | H1-H6 with styled colors |41| **Bold/Italic** | ✅ | Standard emphasis |42| **Links** | ✅ | Styled with underline on hover |43| **Images** | ✅ | Base64 embedded or linked |44| **Code blocks** | ✅ | Syntax highlighting, monospace font |45| **Inline code** | ✅ | Background highlight |46| **Tables** | ✅ | Striped rows, header styling |47| **Blockquotes** | ✅ | Left border, italic style |48| **Lists** | ✅ | Ordered, unordered, nested |49| **Task lists** | ✅ | Checkbox rendering |50| **Mermaid diagrams** | ✅ | PNG or table fallback |51| **SVG** | ✅ | Inline or base64 embedded |52| **Horizontal rules** | ✅ | Styled dividers |53| **Footnotes** | ✅ | Via pandoc |54| **Math (KaTeX)** | ⚠️ | Requires --katex flag |5556---5758## Key Features5960| Feature | Details |61|---------|---------|62| Style presets | professional, academic, minimal, dark |63| Self-contained | All CSS embedded in `<style>` block, no external deps |64| Image embedding | Local images converted to base64 data URIs |65| Mermaid support | PNG rendering or table fallback for diagrams |66| Print-ready | CSS `@media print` rules included |67| TOC generation | Optional table of contents via `--toc` |68| Frontmatter | Extracted for title, stripped from output |6970## Usage7172```bash73# Basic conversion (professional style)74node .github/muscles/md-to-html.cjs report.md7576# Academic style with TOC77node .github/muscles/md-to-html.cjs thesis.md --style academic --toc7879# Dark mode output80node .github/muscles/md-to-html.cjs docs.md --style dark8182# Mermaid diagrams rendered as PNG (high quality)83node .github/muscles/md-to-html.cjs architecture.md --mermaid-png8485# Custom output path86node .github/muscles/md-to-html.cjs README.md output/readme.html8788# Dry run (validate without generating)89node .github/muscles/md-to-html.cjs report.md --dry-run9091# Debug mode (save preprocessed markdown)92node .github/muscles/md-to-html.cjs report.md --debug93```9495---9697## Options Reference9899| Option | Default | Description |100|--------|---------|-------------|101| `--style PRESET` | professional | Style preset: professional, academic, minimal, dark |102| `--toc` | off | Generate table of contents from headings |103| `--embed-images` | true | Convert local images to base64 data URIs |104| `--no-embed-images` | - | Keep image paths as-is (external references) |105| `--strip-frontmatter` | true | Remove YAML frontmatter from output |106| `--mermaid-png` | off | Render Mermaid as PNG (requires mmdc) |107| `--mermaid-fallback` | default | Convert Mermaid to table representation |108| `--debug` | off | Save preprocessed markdown as _debug_combined.md |109| `--dry-run` | off | Validate only, no HTML output |110111---112113## Style Presets114115| Preset | Font | Max Width | Colors | Best For |116|--------|------|-----------|--------|----------|117| **professional** | Segoe UI | 900px | Blue headings, white bg | Business docs, reports |118| **academic** | Palatino Linotype | 750px | Dark headings, cream bg | Papers, theses |119| **minimal** | Inter | 800px | Black/gray, white bg | Clean, modern pages |120| **dark** | Segoe UI | 900px | Light text, dark bg | Dark mode preference |121122---123124## Mermaid Diagram Support125126| Diagram Type | PNG Mode | Fallback Mode |127|--------------|----------|---------------|128| Flowchart | ✅ Full render | ✅ Table |129| Sequence | ✅ Full render | ✅ Table |130| Class | ✅ Full render | ✅ Table |131| State | ✅ Full render | ✅ Table |132| ER | ✅ Full render | ✅ Table |133| Gantt | ✅ Full render | ⚠️ Limited |134| Pie | ✅ Full render | ✅ Table |135| Journey | ✅ Full render | ⚠️ Limited |136137**PNG Mode** (`--mermaid-png`): Requires mermaid-cli (mmdc). Renders at scale 8, 2400px width for crisp output. Diagrams are embedded as base64 PNGs.138139**Fallback Mode** (default): No external dependencies. Converts diagram syntax to an ASCII table representation suitable for text-only viewing.140141---142143## Print Styling144145HTML output includes `@media print` CSS rules:146147- Page breaks before H1 headings148- No background colors (ink-friendly)149- Link URLs shown after text150- Code blocks with borders instead of background151- Proper margins for binding152153---154155## Batch Processing156157```bash158# Convert all markdown files in a directory159for file in docs/*.md; do160 node .github/muscles/md-to-html.cjs "$file" --style professional161done162163# PowerShell equivalent164Get-ChildItem docs/*.md | ForEach-Object {165 node .github/muscles/md-to-html.cjs $_.FullName --style professional166}167```168169---170171## Troubleshooting172173| Problem | Cause | Solution |174|---------|-------|----------|175| "pandoc not found" | pandoc not installed | `winget install pandoc` |176| Mermaid not rendering | mmdc not installed | `npm install -g @mermaid-js/mermaid-cli` or use fallback |177| Images missing | Relative paths broken | Use `--embed-images` (default) |178| Output too wide on print | Style preset issue | Use academic style for print |179| Special characters garbled | Encoding issue | Ensure source is UTF-8 |180181---182183## Requirements184185- Node.js 18+186- pandoc (`winget install pandoc`)187- mermaid-cli (optional, only for `--mermaid-png`)188189---190191## Muscle Script192193`.github/muscles/md-to-html.cjs` (v1.0.0)194195---196197## Conversion Acceptance Decision Table198199| Condition | Verdict | Action |200|-----------|---------|--------|201| All headings, lists, tables, code blocks render correctly | Accept | Ship as-is |202| Mermaid diagrams rendered as PNG/SVG with correct layout | Accept | Verify diagram labels readable |203| Mermaid diagrams missing or show raw syntax | Reject | Check mermaid-cli installed; re-run with `--mermaid-png` |204| Math equations (KaTeX/MathJax) render correctly | Accept | Spot-check complex equations |205| Math equations show raw LaTeX source | Reject | Verify KaTeX CSS/JS included in template |206| Embedded images display at correct size | Accept | Confirm no broken `<img>` tags |207| Images missing or show broken placeholders | Reject | Check paths are relative and files exist |208| CSS custom properties resolve (colors, fonts) | Accept | Visual spot-check against brand |209| Inline styles lost or overridden by browser defaults | Warning | Add `!important` or inline fallbacks |210| Output file size >5MB for a simple document | Warning | Check for unoptimized base64 images |211| HTML validates (no unclosed tags, no script injection) | Accept | Required for security |212| HTML contains `<script>` from untrusted source | Reject | Sanitize; only allow known libraries |213214---215216## Related Skills217218- **md-to-word** — Sister converter for Word document output219- **md-to-eml** — Sister converter for email distribution220- **md-scaffold** — Generate converter-ready Markdown templates221- **markdown-mermaid** — Diagram authoring for embedded Mermaid222- **lint-clean-markdown** — Pre-validate markdown before conversion223- **nav-inject** — Add navigation tables for multi-file suites224225---226227*Skill version: 2.0.0 | Last updated: 2026-04-14 | Category: document-conversion*