md2html, everything it does
md2html turns a Markdown file into one web page that needs nothing else: no server, no network, no fonts or scripts from anywhere. The page brings its own outline, search, light and dark themes, text size, glossary, footnotes, figures that enlarge, coloured code, typeset maths and diagrams. This page was written in Markdown and rendered by md2html, so everything it describes is at work on it as you read.
How to read this
1. Where it runs
| Where | |
|---|---|
| The md2html tool | macOS (Apple silicon and Intel), Linux and Windows, from one Rust program with no dependencies beyond the standard library; tested on all three on every change |
| The pages it makes | current Chrome, Edge, Firefox and Safari, on computers, tablets and phones, online or offline; screen readers and the keyboard throughout |
| Opened from | a web server, a shared folder, an email attachment, or straight from the disk: the page is one file |
| Printed or saved as PDF | from any browser, with a print layout of its own; --pdf makes the PDF itself, with the Chrome, Chromium or Edge already on the computer |
| E-readers | --epub makes an EPUB 3, the standard e-book format |
| Languages of the page | seventeen, right to left included (chapter 8) |
Install with Rust's own installer, from the source:
$ cargo install --git https://github.com/githubrobbi/md2html --tag v0.8.1 md2html --locked
$ md2html notes.md
md2html: notes.md -> notes.html (68504 bytes, 9 glossary terms, 0 of them shared)
2. At a glance
| md2html | |
|---|---|
| Markdown | all of CommonMark 0.31.2 (all 652 of its test examples pass), and GitHub's tables, task lists, strikethrough, autolinks, footnotes and alerts |
| Output | one HTML file, nothing fetched, nothing to install for the reader |
| Reading | outline, search, light and dark themes, text size, glossary, footnotes, figures that enlarge |
| Code, maths, diagrams | code coloured in some twenty languages, maths as MathML, Mermaid flowcharts and sequence diagrams drawn as SVG, all without a script library |
| Sharing | a link to any chapter, table row, figure, diagram, code block, or selected passage |
| Languages | the page's own words in 17 languages, translations linked by a switch, right to left for Hebrew, Yiddish and Arabic |
| Keeping | the page itself, a PDF with bookmarks, an EPUB for e-readers |
| Live | pages that reload when their Markdown changes and keep the reader's place |
| Safety | no script from the text, ever; no file read outside the document's folder |
| Accessibility | no findings against WCAG 2.2 AA, in both themes and at phone width |
| Speed | a 4,000-line document, diagrams and maths included, in under a tenth of a second |
| Dependencies | none: the Rust standard library and md2html |
3. The page
The page has three parts: a bar along the top, the outline at the left, and the text.
The dark theme follows the system, or the reader's choice, and is remembered:
On a phone the outline folds away behind the switch in the bar, and nothing scrolls sideways:
What a reader can do:
| To | Do this |
|---|---|
| Find something | Search in the bar, ⌘ K (Ctrl K), or / |
| Hide or show the outline | the switch at the left of the bar, or ⌘ \ |
| Change the text size | Aa in the bar, then − and +; or ⌘ + and ⌘ −, from 85 to 200 percent |
| Change the theme | Aa, then System, Light or Dark |
| Enlarge a figure | click it; two more clicks bring it closer; Esc puts it back |
| Read a footnote or a dotted word | rest on it; click to go to it, and back returns |
| Share a chapter, a table row, a figure, a diagram, a code block or a passage | the share symbol to the right of a heading, at the end of the table row under the pointer, or in the corner of the figure, diagram or code block under it, copies its link (a phone opens its share sheet); select words, and a link to exactly them is offered |
| Keep it | the download button at the end of the bar: the page itself (it reads offline), print or save as PDF, or the PDF and the EPUB where they were made |
The text size and the theme sit together behind Aa; keeping the page has its own button:
4. Writing
Ordinary Markdown, and each construct reads well as plain text too. What you write comes first, in a code block; what you get follows it.
Emphasis and links
**Bold**, *italic*, ***both***, ~~struck~~ and `code`.
A [link](https://commonmark.org "CommonMark"), a bare one,
https://spec.commonmark.org/0.31.2/, and marks like [V] that stay as written.
Bold, italic, both, struck and code. A link, a bare one, https://spec.commonmark.org/0.31.2/, and marks like [V] that stay as written.
Lists inside lists
1. First, with a nested list:
- a bullet
- another, with its own:
1. deeper
2. Second.
- [x] a task done
- [ ] a task open
- First, with a nested list:
- a bullet
- another, with its own:
- deeper
- Second.
- a task done
- a task open
Quotes and callouts
> A plain quotation stays a quotation.
> [!TIP]
> GitHub's alerts work: NOTE, TIP, IMPORTANT, WARNING, CAUTION.
> **Note:** so does the older form, a bold word and a colon.
A plain quotation stays a quotation.
GitHub's alerts work: NOTE, TIP, IMPORTANT, WARNING, CAUTION.
so does the older form, a bold word and a colon.
Tables
| Room | Floor | Area (sq ft) |
|:-------|:------:|-------------:|
| Living | ground | 312 |
| Loft | upper | 205 |
| Room | Floor | Area (sq ft) |
|---|---|---|
| Living | ground | 312 |
| Loft | upper | 205 |
A table wider than the column scrolls inside it, and the page never does.
Footnotes
A claim that needs a source.[^1]
[^1]: The source. Rest on the number to read it there.
A claim that needs a source.1
Figures and images
{width=60%}
An icon {width=18} inside a sentence.
An icon inside a sentence.
Small things
Press <kbd>Ctrl</kbd>+<kbd>K</kbd>. Water is H<sub>2</sub>O, the room 9 m<sup>2</sup>.
A line ending in a backslash\
breaks there.
Press Ctrl+K. Water is H2O, the room 9 m2. A line ending in a backslash
breaks there.
A section that opens on a click
Written as <details> with a <summary>, with ordinary Markdown inside: bold, a list,
- one
- two
A fourth-level heading
Headings below the third level stay out of the outline, as this one does.
5. Code, maths and diagrams
Code is coloured for Rust, Python, JavaScript and TypeScript, Go, C and C++, Java, Kotlin, Swift, C#, the shell, SQL, Ruby, Lua, PHP, CSS, HTML, JSON, YAML, TOML, Dockerfiles and diffs, and every block has a copy button.
/// The whole page from one Markdown text.
fn main() {
let page = md2html::render("# Hello\n\nWorld.", &Settings::default());
println!("{} bytes, nothing to fetch", page.len()); // one file
}
@cache
def area(w: float, h: float) -> float:
"""The area of a room."""
return w * h # square feet
- every quotation a note
+ a quotation is a quotation; a bold first word makes it a note
Maths is typeset by the browser itself, as MathML, with no script and no font to download. Inline, the theorem of Pythagoras is , and Euler's identity is ; a dollar amount such as $5 or $10 stays money. Displayed:
Diagrams
A Mermaid flowchart or sequence diagram is drawn by md2html itself, as SVG inside the page: no script, nothing to download, the page's own colours in both themes, and its words stay words that search finds. This is the Markdown:
```mermaid
flowchart LR
md[notes.md] --> parse[Read the Markdown]
parse --> render{Diagram?}
render -->|flowchart or sequence| svg[Draw it as SVG]
render -->|another kind| js[mermaid.js, if given]
svg --> page([one HTML page])
js --> page
```
And this is what it becomes:
A sequence diagram, numbered, with a note:
Other kinds (pie charts, Gantt charts, class diagrams) are drawn by mermaid.js when the author points md2html at a copy of it (--mermaid-js FILE); the script then goes into that page only. Without it, they stay as code, and --check says so.
6. Glossary, footnotes, search and figures
A chapter called Glossary holds the page's words as a table. It is not printed where it stands: instead, the first mention of each term in every chapter becomes a dotted word that explains itself on hover, and a click on it jumps to the entry at the foot, which leads back to the line you were reading.
Footnotes work the same way: the number explains itself on hover.
A glossary can be shared across pages: one file at ~/.config/md2html/glossary.md, whose words then link on every page rendered from a file on that computer.
Search covers every word on the page, the glossary included. The results show where each word stands; the chosen one is lit where the search lands.
A figure enlarges over the page without leaving it. Larger than the window, it follows the pointer, so you point at what you want to see.
7. Sharing and live pages
Every heading carries a share symbol to its right; every table row, figure, diagram and code block shows one under the pointer. A click copies a link to exactly that place, and says so; on a phone the system's share sheet opens instead. Select a few words, and the page offers a link to exactly them, which opens the page on that passage, highlighted.
A page can also keep itself current. md2html --serve shows the pages on this computer while they are written, and every open page reloads the moment its Markdown is saved. A published page made with --live has its own time to live: when it runs out, the page asks its server for the first kilobyte of itself, where its fingerprint is, and reloads only if that changed. Either way the reader stays where they were: the same paragraph at the same height, or, if it is gone, the chapter before it; switching to another language keeps the place the same way. The server is for this computer alone: it answers only requests addressed to it, serves only the document's folder, and answers a request it cannot read whole with the status that says why.
8. Languages
The page's own words (the search, the callouts, the glossary, the dates, every button) come in seventeen languages: English, German, Hebrew, Indonesian, Dutch, Javanese, Yiddish, Low German, French, Italian, Spanish, Japanese written three ways (in kanji and kana, in kana alone, and in rōmaji), Mandarin Chinese in simplified and in traditional characters, and Cantonese. lang: de in the front matter is all it takes. Hebrew and Yiddish are laid out right to left, the outline on the right, and so is Arabic, with English words.
A translation is simply another Markdown file beside the original, named for its language: capabilities.de.md is the German capabilities.md. md2html finds the versions there are, links them to each other with a switch in the bar (the globe), tells browsers and search engines with hreflang, and gives each the words of its own interface. This page exists in all seventeen; the globe switches between them, and the page opens at the paragraph you were reading.
Each translation names its original and records the original's fingerprint, so the page can say which version is the authoritative one, and --check notices when the original has changed since the translation was made:
translated_from: capabilities.md
source_sha256: 5b0c...e1
For a language nobody has translated a page into, the reader's own browser can translate it, where it has that ability (Chrome's built-in translator): on the device itself, so nothing leaves it, labelled as a machine translation, with a way back to the original.
9. Keeping a page
The download button in the bar offers what there is to keep. The page itself reads offline when its images are inside it (embed: true). Print gets its own layout: the controls drop away, every link prints its address, nothing is cut across a page, and the pages carry the title and their number.
--pdf prints the page with the Chrome already on the computer: its own print layout, the headings as the PDF's bookmarks, the title at the head of each page and its number at the foot. --epub makes a book for e-readers from the same page, with its contents, images, diagrams and maths, and footnotes that open where they are mentioned; md2html writes it itself. The reader finds both under the download button.
10. Settings
The top of this page's own Markdown file reads:
---
title: md2html, everything it does
description: md2html turns Markdown into one complete, self-contained web page ...
brand: md2html
kicker: Capabilities
version: 0.8.1
date: 2026-11-23
footer: Written in Markdown and rendered by **md2html 0.8.1** itself ...
csp: true # only this page's own code may run
embed: true # the screenshots are inside the page
---
| Setting | What it does |
|---|---|
title, description, author | the title, and the meta tags for link previews |
lang | the language: the page's own words and dates in any of the seventeen (ja-Hira is Japanese in kana, zh-Hant Chinese in traditional characters, yue Cantonese) |
translated_from, source_sha256 | for a translation: its original, and the original's fingerprint when it was translated |
brand, brand_link, kicker, eyebrow, footer | the bar, the line above the title, the fine print |
date, version | the date and version shown above the title |
embed | images inside the page, so it is one file |
csp | a Content-Security-Policy |
pdf, epub | a PDF and an EPUB of the page, beside it |
live | the page's time to live (true is two minutes, or a number of seconds): then it reloads if it changed, keeping the reader's place |
large, toc, math, index, html, css, head | larger type, the outline, maths, search engines, richer HTML, extra style and head |
With lang: de the search says "Diese Seite durchsuchen", the callouts say "Hinweis" and "Achtung", and the date reads "23. November 2026".
11. The command line
$ md2html notes.md
md2html: notes.md -> notes.html (68504 bytes, 9 glossary terms, 0 of them shared)
$ md2html docs/ -o site/ --nav
$ md2html notes.md --check
notes.md:30: `plan.svg` does not exist next to this page
notes.md: a link points at #setup, which is nowhere on the page
md2html: 2 to look at
$ cat notes.md | md2html - > notes.html
$ md2html notes.md --pdf --epub
$ md2html notes.md --serve
--check writes nothing and lists what an author should look at, line by line where there is a line, and exits 1 when there is anything: a link to an anchor that is not on the page, a file that is not there, a footnote without its note, raw HTML shown as text, a tag of the author's that closes nothing or is never closed, a translation older than its original. That makes it the last step of a build. --watch renders again on every save, --nav links the pages of a folder with previous and next, and a link to another Markdown file goes to its page.
12. Safety, quality and accessibility
A page can be rendered from Markdown someone else wrote. md2html never writes a script from the text: raw HTML is shown as written except a few harmless tags, which are balanced inside the article so they cannot break the page around it, and javascript: or data: links are dropped, however they are spelled. A document cannot make md2html read a file outside its folder, and no input, however hostile, can stall it or make it crash.
--html lets richer HTML through (images, links, video, SVG, layout), but never anything that runs: no script, no event handler, no frame, no form.
What is checked on every change, the tests on macOS, Linux and Windows and the checks in Chrome on Linux:
- the tests that render whole pages and read them back, and those that run the program itself, the security and the pathological cases among them;
- the 652 examples of the CommonMark specification, of which the count passing may rise but never fall;
- clippy's strictest lints, and the oldest Rust the tool promises to build on;
- an accessibility audit with axe-core against WCAG 2.2 AA, in both themes and at phone width;
- a click-through in Chrome that uses every control the way a reader would, by mouse and by keyboard, at the normal and a larger text size;
- live pages, end to end: a reload on a change, the reader's place kept, a language switch that lands on the same paragraph.
md2html has no third-party code, and its supply chain is pinned and vetted: the toolchain, the CI actions, the test tools. Every page ends with one quiet line: made with md2html, its version, and a link to where md2html lives.
The path every page takes:
The glossary below explains the words this page uses; each was a dotted word above.
Notes
The source. Rest on the number to read it there; click it to come here, and back to return. back
Words used here
Each dotted word in the chapters shows its meaning when you rest on it and jumps here when you click it. Every entry has a back that returns you to the line you were reading.
- calloutback
- A boxed aside: a note, a tip, something important, a warning or a caution.
- CommonMarkback
- The specification of Markdown that most tools now follow, with a test for every rule.
- Content-Security-Policyback
- A rule in the page that tells the browser which code may run; here, only the page's own.
- EPUBback
- The standard format for e-books, a packaged web page that e-readers lay out.
- figureback
- An image on a line of its own, with its caption under it, enlarged on a click.
- front matterback
- The block of settings between two
---lines at the very top of a Markdown file. - Markdownback
- Plain text with light marks for headings, emphasis, lists and links, readable as it is and convertible to a page.
- MathMLback
- The web's own language for maths, drawn by the browser without a script.
- Mermaidback
- A text language for diagrams, written in a code block; md2html draws its flowcharts and sequence diagrams.
- outlineback
- The list of chapters at the left of the page, made from its headings.
- translationback
- A version of a page in another language, a Markdown file beside the original.
- WCAGback
- The Web Content Accessibility Guidelines; level AA is the usual target.
Made with md2html 0.8.1