Render Markdown files in your terminal with ANSI color and formatting. Zero external dependencies — pure Go stdlib.
tools/mdview/
├── main.go # CLI entry point
├── render.go # Rendering engine
├── go.mod
└── README.md
cd tools/mdview
go build -o mdview .Or install to $GOPATH/bin:
go install github.com/adrianpriza-ai/mdview@latestmdview [--width N] <file.md>
cat README.md | mdview
mdview reads from a file path or from stdin when no path is given.
Terminal width is detected automatically via TIOCGWINSZ with a fallback of
80 columns. Use --width to override.
| Flag | Short | Description |
|---|---|---|
--width N |
-w N |
Wrap output to N columns instead of auto-detected terminal width |
--help |
-h |
Show help |
# View a local file
mdview README.md
# Specify a fixed render width
mdview --width 100 README.md
# Pipe from stdin
cat CHANGELOG.md | mdview
# Pipe to a pager (preserves colors)
mdview README.md | less -R
# Fetch and render a remote file
curl -s https://raw.githubusercontent.com/cli/cli/trunk/README.md | mdview| Feature | Syntax |
|---|---|
| Headings (ATX) | # through ###### |
| Headings (setext) | underline with === / --- |
| Bold | **text** or __text__ |
| Italic | *text* or _text_ |
| Bold + italic | ***text*** |
| Strikethrough | ~~text~~ |
| Inline code | `code` |
| Fenced code blocks | ``` with optional language label |
| Blockquotes | > text |
| Unordered lists | - item / * item |
| Ordered lists | 1. item |
| Nested lists | two-space indent |
| Tables (GFM) | pipe-delimited, column alignment |
| Links | [text](url) |
| Auto-links | <https://example.com> |
| Images |  → renders as [alt] label |
| Horizontal rules | --- / *** / ___ |
| Centered blocks | <div align="center"> / <p align="center"> |
Tables automatically shrink to fit the terminal (or --width). Cells
word-wrap across multiple rows when needed; words wider than their column are
hard-broken. Inline markup — bold, italic, inline code, links — is fully
rendered inside table cells.
HTML center blocks render all content flush-centered to the terminal width.
Inside a <div align="center"> or <p align="center"> block, the following
are supported and styled:
- ATX markdown headings (
# h1through###### h6) — bold + color by level - HTML headings (
<h1>through<h6>) - Inline images (
<img>) → rendered as[alt] - Inline links (
<a>) → rendered as link text - HTML line breaks (
<br>) - HTML entities (
&,<,>,",&#NNN;,­, …)
