Skip to content

Latest commit

Β 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“„ convert-md-to-pdf

A powerful CLI tool and Browser Extension (Manifest V3) to convert Markdown (.md) files, raw text, or web pages into beautifully styled, high-quality PDF & static HTML documents. Built with support for Cover Pages, Dotted Leader Line Table of Contents (TOC), Mermaid.js diagrams, LaTeX Math, GitHub Callout Alerts, Custom CSS Injection, 7 Preset Themes, and Open-Source Font Selection.

Chrome Web Store npm version Browser Extension License


✨ Features

  • 🧩 Browser Extension (Manifest V3):
    • Drag & drop single or multiple .md files directly into the popup.
    • Auto-saved draft text in popup & conversion history list with 1-click re-open.
    • Convert active web page or GitHub raw Markdown files with 1 click.
    • Context menu integration: Right-click selected Markdown text or any page -> "Convert to PDF".
    • Full-page Print Preview with live theme switching, Font Selector, Auto TOC, Custom CSS, and native PDF/HTML export.
  • πŸ“‘ Auto Cover Page Generator: Generate elegant document report cover pages via YAML Front Matter (cover: true) or --cover flag.
  • πŸ“Œ Dotted Leader Line Table of Contents (TOC): Auto-generates publication-grade TOC with dotted leader lines (...) and clickable anchor links (--toc).
  • 🎨 7 Preset Themes: modern (default), dark, academic, github, ebook, cyberpunk, and minimal.
  • πŸ”€ Open-Source Font Selector: 100% free under SIL OFL / Apache 2.0 (Inter, Roboto, Lora, Merriweather, JetBrains Mono, Fira Code).
  • ⚑ Live Watch Mode & HTML Export: Real-time auto-recompilation on file changes (-w, --watch) and direct static HTML export (-f, --format html).
  • πŸš€ CLI & Batch Conversion: Convert single files or batch process directories with wildcard patterns.
  • 🎨 Custom CSS Injection: Inject custom branding CSS stylesheets (-c, --css custom.css).
  • πŸ“Š Mermaid Diagrams: Sequence diagrams (with auto note wrapping), flowcharts, class diagrams, and gantt charts.
  • πŸ“ LaTeX Math Support: Mathematical equations rendered with KaTeX.
  • πŸ’‘ GitHub Callout Box Alerts: Support for > [!NOTE], > [!TIP], > [!WARNING], > [!IMPORTANT], and > [!CAUTION].
  • πŸ’» ASCII UI Mockups: Styled dark-theme boxes for terminal output & ASCII wireframe mockups.

🌐 Extension Installation & Usage

πŸ›’ Direct Install from Chrome Web Store (Recommended)

You can install the official published extension directly with 1-click: πŸ‘‰ Install Markdown to PDF Converter on Chrome Web Store

πŸ› οΈ Developer Unpacked Installation (Local Build):

  1. Clone or download this repository:
    git clone https://github.com/vannt-dev/convert-md-to-pdf.git
  2. Open your browser and navigate to chrome://extensions (or edge://extensions).
  3. Enable Developer mode (toggle in the top-right corner).
  4. Click Load unpacked (TαΊ£i tiện Γ­ch Δ‘Γ£ giαΊ£i nΓ©n).
  5. Select the extension directory inside this repository (or load dist/extension-latest.zip).
  6. The Markdown to PDF Converter icon will appear in your browser toolbar!

πŸ’» CLI Installation & Usage

Global Installation via npm / npx

npm install -g convert-md-to-pdf

or run directly with npx:

npx convert-md-to-pdf input.md

CLI Examples:

# Convert a Markdown file with Cover Page, Auto TOC & Cyberpunk Theme
npx convert-md-to-pdf input.md --cover --toc -t cyberpunk --font "Fira Code" -o output.pdf

# Watch file and auto-recompile on save
npx convert-md-to-pdf input.md -w -f html

# Batch convert multiple files to an output directory
npx convert-md-to-pdf file1.md file2.md -o output_dir/

# Convert entire directory of .md files
npx convert-md-to-pdf ./docs/ -o ./dist/

πŸ› οΈ CLI Options

Flag Alias Description Default
-o, --output <path> Output PDF/HTML file path or target directory Auto-derived
-f, --format <format> Output format: pdf, html pdf
-w, --watch Live watch input file and auto-recompile on change false
-t, --theme <theme> Theme: modern, dark, academic, github, ebook, cyberpunk, minimal modern
--font <font> Font family: Inter, Roboto, Lora, Merriweather, JetBrains Mono, Fira Code Inter
--cover Auto-generate document report Cover Page false
--toc Auto-generate Table of Contents with Dotted Leader Lines false
-p, --page-size <size> Paper size: A4, Letter, A3, Legal A4
-l, --landscape Use landscape page orientation false
-m, --margin <margin> Custom page margin (e.g. 14mm 12mm 16mm 12mm) 14mm 12mm 16mm 12mm
-c, --css <path> Custom CSS stylesheet file path to inject
-k, --keep-html Keep temporary HTML file after conversion false
--no-mermaid Disable Mermaid diagram rendering false
--no-katex Disable KaTeX math formula rendering false

πŸ“„ Front Matter Options

You can specify conversion settings directly inside your .md files using YAML Front Matter:

---
title: "Quarterly Financial Report"
subtitle: "Q3 Fiscal Summary"
author: "Engineering Team"
date: "2026-08-11"
cover: true
toc: true
theme: github
font: Inter
pageSize: A4
landscape: false
---
# Document Executive Summary
...

🌿 Git Flow & Automated Release Workflow

This project follows standard Git Flow branching and automated release publishing:

πŸ”€ Branching Strategy

  • main: Production-ready branch. Stores stable releases. Merging code into main automatically triggers a GitHub Release.
  • develop: Active development branch. Daily commits, feature additions, and refactoring take place here.

πŸš€ Automated Release Pipeline

Whenever code is merged from develop into main (or a version tag v* is pushed), GitHub Actions (.github/workflows/release.yml) automatically:

  1. Runs full unit test suite (npm test).
  2. Bundles cross-platform extension zip artifacts (dist/extension-vX.Y.Z.zip).
  3. Auto-generates release notes from commit history.
  4. Publishes a new official GitHub Release with downloadable ZIP binaries attached!

πŸ’‘ 1-Click CLI Release Command

You can also bump version and trigger a release with a single CLI command:

npm run release <version|patch|minor|major>
# Example: npm run release 1.2.0

Please review our Git Commit & Push Workflow Guide (GIT_WORKFLOW.md) for conventional commit guidelines and pre-commit checks.


πŸ“ Project Architecture

convert-md-to-pdf/
β”œβ”€β”€ bin/
β”‚   └── cli.js               # CLI executable with watch & format options
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/                # Shared modular conversion engine
β”‚   β”‚   β”œβ”€β”€ themes/          # Modular Theme CSS collection
β”‚   β”‚   β”‚   β”œβ”€β”€ index.js     # Theme registry & font override builder
β”‚   β”‚   β”‚   β”œβ”€β”€ cover.js     # Cover page CSS
β”‚   β”‚   β”‚   β”œβ”€β”€ modern.js    # Modern blue theme
β”‚   β”‚   β”‚   β”œβ”€β”€ dark.js      # Dark slate theme
β”‚   β”‚   β”‚   β”œβ”€β”€ academic.js  # Academic serif theme
β”‚   β”‚   β”‚   β”œβ”€β”€ github.js    # GitHub light theme
β”‚   β”‚   β”‚   β”œβ”€β”€ ebook.js     # E-Book paper theme
β”‚   β”‚   β”‚   β”œβ”€β”€ cyberpunk.js # Cyberpunk neon dark theme
β”‚   β”‚   β”‚   └── minimal.js   # Minimal monochrome theme
β”‚   β”‚   β”œβ”€β”€ frontmatter.js   # YAML front matter parser
β”‚   β”‚   β”œβ”€β”€ cover.js         # Cover page generator
β”‚   β”‚   β”œβ”€β”€ toc.js           # Dotted leader line TOC generator
β”‚   β”‚   β”œβ”€β”€ sanitizer.js     # HTML sanitizer & escaping
β”‚   β”‚   β”œβ”€β”€ utils.js         # Preprocessors & helper re-exports
β”‚   β”‚   β”œβ”€β”€ parser.js        # Pipeline parser (Markdown -> HTML)
β”‚   β”‚   β”œβ”€β”€ templates.js     # HTML document template builder
β”‚   β”‚   └── index.js         # Main library API entrypoint
β”‚   └── browser/             # Headless browser rendering engine
β”‚       └── renderer.js      # Puppeteer Chrome/Edge launcher & PDF worker pool
β”œβ”€β”€ extension/               # Browser Extension (Manifest V3)
β”‚   β”œβ”€β”€ manifest.json
β”‚   β”œβ”€β”€ background/          # Service worker & context menus
β”‚   β”œβ”€β”€ content/             # Content script for raw MD pages
β”‚   β”œβ”€β”€ popup/               # Extension Popup UI (Batch file, Paste, Page, History)
β”‚   β”œβ”€β”€ preview/             # Print Preview & PDF/HTML export page
β”‚   β”œβ”€β”€ lib/                 # Vendor libraries (marked, mermaid, katex)
β”‚   └── icons/               # Extension icons (16, 48, 128)
β”œβ”€β”€ tests/                   # Standalone test suite (7/7 PASS)
β”‚   └── index.test.js
β”œβ”€β”€ dist/                    # Built Chrome Extension zip artifacts
β”œβ”€β”€ examples/                # Usage examples & custom CSS templates
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
β”œβ”€β”€ PRIVACY_POLICY.md
└── GIT_WORKFLOW.md

πŸ“ License

Distributed under the MIT License. See LICENSE for details.

About

A powerful CLI tool and Chrome Extension (Manifest V3) to convert Markdown files into beautifully styled PDFs with Mermaid diagrams, LaTeX math, Cover Pages, Dotted TOC, and 7 preset themes.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages