zsh · one file · zero deps

Preview Markdown. One Command. No Setup.

mdview is a single-file zsh script that turns a markdown file (or stdin) into a styled HTML preview and opens it in your default browser. Optional terminal-mode and "print HTML to stdout" flags make it equally happy in editors, scripts, and pipelines.

1 FILE BINARY
0 RUNTIME DEPS
2 macOS / LINUX

Why mdview

One File

Single zsh script

No npm, no Python, no virtualenv. Drop bin/mdview on PATH and you are done.

Render

Pandoc when present, CDN fallback otherwise

Works on a fresh Mac out of the box. pandoc support kicks in automatically if installed.

Browser

Default browser, your choice

--app "Google Chrome" picks any installed browser. macOS and Linux both supported.

Terminal

Terminal mode too

-t renders via glowmdcatbat$PAGER — first one available wins.

Pipe

Stdin and stdout friendly

cat notes.md | mdview - reads stdin. -p prints rendered HTML so you can pipe it onward.

Safe

Safe by construction

Markdown embeds in a <textarea> and is HTML-escaped — adversarial content cannot break out of the page.

Install

### Homebrew tap (recommended on macOS) ```bash brew tap amit-t/mdview https://github.com/amit-t/mdview brew install mdview ``` ### Curl one-liner (any Unix) ```bash mkdir -p "$HOME/.local/bin" curl -fsSL https://raw.githubusercontent.com/amit-t/mdview/main/bin/mdview \ -o "$HOME/.local/bin/mdview" chmod +x "$HOME/.local/bin/mdview" ln -sfn "$HOME/.local/bin/mdview" "$HOME/.local/bin/mdv" ``` ### Clone + `make install` ```bash git clone https://github.com/amit-t/mdview.git cd mdview make install ```

All install flows produce two commands on PATH: mdview (full name) and mdv (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

FlagEffect
-b, --browserRender to HTML and open (default).
-t, --terminalRender in terminal: glowmdcatbat$PAGER.
-p, --printPrint rendered HTML to stdout (no file, no open).
-o, --output PSave HTML to path P instead of an auto temp file.
-n, --no-openWrite the HTML file but skip launching the browser.
--app NAMEOpen in a specific browser ("Google Chrome", "Safari").
--title TITLEOverride <title>. Default: file basename.
-h, --helpShow help.
-V, --versionShow version.

Full reference and examples live in the usage guide.

How rendering works

Two paths, picked at runtime in this order:

  1. pandoc — when installed, mdview shells out to pandoc -f gfm -t html and wraps the result in a styled document using github-markdown-css. Fully offline.
  2. marked.js fallback — 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 using marked.js + highlight.js loaded 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