🏠 > Configuration

☀️ 🌙

Configuration Options

This document provides a complete reference of all configuration options for mk2html and mk2pdf.

mk2html Options

Input/Output

Option Type Default Description
INPUT positional required Input Markdown file. Use - for stdin
-o, --output string <input>.html Output HTML file path

Content Options

Option Type Default Description
-t, --title string filename Document title shown in header and browser tab
--theme choice light Default theme: light or dark
--no-mermaid flag false Disable Mermaid diagram support
--no-toc flag false Disable table of contents generation
--no-line-numbers flag false Disable line numbers in code blocks
--no-breaks flag false Disable converting newlines to <br> tags

Mode Options

Option Type Default Description
--offline flag false Embed JS libraries for offline use
--clear-cache flag false Clear cached library files and exit

Output Control

Option Type Default Description
-q, --quiet flag false Suppress output messages
-v, --version flag false Show version and exit
-h, --help flag false Show help and exit

mk2pdf Options

Input/Output

Option Type Default Description
INPUT positional required Input Markdown file
-o, --output string <input>.pdf Output PDF file path

Content Options

Option Type Default Description
-t, --title string filename Document title (shown in PDF metadata)
--theme choice light Theme for rendering: light or dark
--no-mermaid flag false Disable Mermaid diagram support
--no-line-numbers flag false Disable line numbers in code blocks
--no-breaks flag false Disable converting newlines to <br> tags

Page Layout

Option Type Default Description
--page-size choice a4 Page size: a4, a3, a5, letter, legal, tabloid
--margin string 1in Page margin (supports: in, cm, mm, px)
--landscape flag false Use landscape orientation

Rendering

Option Type Default Description
--wait integer 2000 Wait time for JS rendering in milliseconds

Output Control

Option Type Default Description
-q, --quiet flag false Suppress output messages
-v, --version flag false Show version and exit
-h, --help flag false Show help and exit

Environment Variables

Currently, mk2html and mk2pdf do not use environment variables. All configuration is done via command-line options.


Default Behaviors

Line Breaks (--no-breaks)

Default behavior (enabled):

Line 1
Line 2

Renders as:

<p>Line 1<br />
Line 2</p>

With --no-breaks (standard Markdown):

Line 1
Line 2

Renders as:

<p>Line 1
Line 2</p>

(Displays as a single line in browser)

Line Numbers (--no-line-numbers)

Default behavior (enabled):

1 | def hello():
2 |     print("Hello")

With --no-line-numbers:

def hello():
    print("Hello")

Theme Persistence

The theme toggle in the HTML output saves the user's preference to localStorage. The --theme option only sets the initial/default theme.

Offline Mode Cache

Libraries are cached in ~/.cache/mk2html/:
- <hash>_mermaid.min.js (~3.4 MB)
- <hash>_highlight.min.js (~120 KB)

Cache is shared across all conversions and persists until --clear-cache is used.


Page Size Reference

Size Portrait (W × H) Landscape (W × H)
A3 11.69" × 16.54" 16.54" × 11.69"
A4 8.27" × 11.69" 11.69" × 8.27"
A5 5.83" × 8.27" 8.27" × 5.83"
Letter 8.5" × 11" 11" × 8.5"
Legal 8.5" × 14" 14" × 8.5"
Tabloid 11" × 17" 17" × 11"

Margin Examples

Value Description
1in 1 inch (default)
0.5in Half inch
2cm 2 centimeters
20mm 20 millimeters
72px 72 pixels (≈ 1 inch)
0 No margin

Documentation Site

mk2html docs.md -o index.html --title "Documentation" --offline
mk2pdf report.md --page-size letter --margin 1in

Code-Heavy Document

mk2html code.md --theme dark --no-breaks

Quick Preview

mk2html README.md -q

Presentation Slides (Wide)

mk2pdf slides.md --page-size tabloid --landscape --margin 0.5in