Why mdview
Single zsh script
No npm, no Python, no virtualenv. Drop bin/mdview on PATH and you are done.
Pandoc when present, CDN fallback otherwise
Works on a fresh Mac out of the box. pandoc support kicks in automatically if installed.
Default browser, your choice
--app "Google Chrome" picks any installed browser. macOS and Linux both supported.
Terminal mode too
-t renders via glow → mdcat → bat → $PAGER — first one available wins.
Stdin and stdout friendly
cat notes.md | mdview - reads stdin. -p prints rendered HTML so you can pipe it onward.
Safe by construction
Markdown embeds in a <textarea> and is HTML-escaped — adversarial content cannot break out of the page.
Install
All install flows produce two commands on PATH:
mdview(full name) andmdv(short alias).
Quick taste
mdview README.md # render + open in default browser
mdview notes.md --app "Google Chrome"
mdview notes.md -t # terminal mode (glow → mdcat → bat → pager)
mdview notes.md -p > out.html # print HTML to stdout
mdview notes.md -o /tmp/x.html -n # write to a path, do not open
cat notes.md | mdview - # read markdown from stdin
mdv notes.md # short alias
Flags at a glance
| Flag | Effect |
|---|---|
-b, --browser | Render to HTML and open (default). |
-t, --terminal | Render in terminal: glow → mdcat → bat → $PAGER. |
-p, --print | Print rendered HTML to stdout (no file, no open). |
-o, --output P | Save HTML to path P instead of an auto temp file. |
-n, --no-open | Write the HTML file but skip launching the browser. |
--app NAME | Open in a specific browser ("Google Chrome", "Safari"). |
--title TITLE | Override <title>. Default: file basename. |
-h, --help | Show help. |
-V, --version | Show version. |
Full reference and examples live in the usage guide.
How rendering works
Two paths, picked at runtime in this order:
pandoc— when installed, mdview shells out topandoc -f gfm -t htmland wraps the result in a styled document usinggithub-markdown-css. Fully offline.marked.jsfallback — when pandoc isn’t on PATH, mdview emits a self-contained HTML document that embeds the raw markdown inside a<textarea id="md-source">(HTML-escaped on the way in) and renders client-side usingmarked.js+highlight.jsloaded from jsDelivr.
The <textarea> embedding is deliberate: the only sequence that closes a textarea is </textarea>, so escaping < (and &) on the way in neutralises any </script> or other tag-soup in the input. The test suite has an explicit case proving this.
Documentation
- Usage guide — every flag, edge case, and editor recipe.
- Development notes — repo layout, release checklist, zsh idioms.
- Contributing — ground rules and test-with-every-PR policy.
- Changelog — release history.
- Source on GitHub.