mdview

module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT

README

mdview

A small CLI that renders a Markdown file to HTML and opens it in your browser. GitHub-flavored Markdown, syntax highlighting, Mermaid diagrams, and an optional live-reload watch mode.

Install

go install github.com/owenrumney/mdview/cmd/mdview@latest

Or build from source:

make build   # produces ./bin/mdview
make install # go install ./cmd/mdview

Usage

mdview path/to/file.md

One-shot mode renders the file to a temp HTML file and opens it in your default browser.

Flags
Flag Description
-w, --watch Serve the file over a local HTTP server and reload the browser on changes
--light Light theme (default is dark)
--unsafe Allow raw HTML in markdown and relaxed Mermaid security. Only use on trusted files
--version Print version info
Examples

Render once and open:

mdview README.md

Live preview while editing:

mdview --watch docs/guide.md

Light mode:

mdview --light notes.md

Features

  • GitHub-flavored Markdown (tables, task lists, strikethrough, autolinks)
  • Footnotes and definition lists
  • Syntax highlighting via Chroma (github-dark / github)
  • Mermaid diagrams (bundled, no network required)
  • Copy-to-clipboard buttons on code blocks
  • Click images or Mermaid diagrams to zoom (Esc or click backdrop to close)
  • Live reload over Server-Sent Events when --watch is set
  • Auto-generated heading IDs

Development

make build           # build to ./bin/mdview
make test            # go test ./...
make fmt             # gofmt -s -w .
make vet             # go vet ./...
make lint            # golangci-lint run
make tidy            # go mod tidy
make update-mermaid  # refresh bundled mermaid.min.js
make release-snapshot
make clean

The bundled Mermaid version is controlled by MERMAID_VERSION in the Makefile.

Project layout

cmd/mdview/         # CLI entrypoint
internal/render/    # Markdown -> HTML, embedded assets, Mermaid extension
internal/server/    # Watch-mode HTTP server with SSE live reload
internal/browser/   # Cross-platform "open URL" helper
examples/           # Sample markdown

License

MIT — see LICENSE.

Directories

Path Synopsis
cmd
mdview command
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL