mdview
A minimal terminal markdown reader written in Rust. Published on crates.io as mdview-tui; the installed binary is mdview.
mdview notes.md
What it does
Renders a single markdown file in a centered, fixed-width column inside the alternate screen. Toggle between the rendered view and the raw source with Tab. Scroll with the trackpad/mouse wheel, or with j/k and arrow keys.
Body paragraphs are justified to the column width. Standalone images render inline as half-block (▀) pixel previews at 80% of the column width — press o or click one (the bottom bar shows click: <file> while hovering) to open the original in your system viewer. LaTeX math renders as Unicode: $\gamma^d$ → γᵈ, $h_{\min}$ → hₘᵢₙ, \mathbb{E}[S] → 𝔼[S], with $$…$$ display equations centered on their own line. Complex TeX degrades to readable linear form (\frac{a}{b} → (a)/(b)) rather than raw source.
Install
The crate is published as mdview-tui (the mdview name on crates.io was already taken), but the binary it installs is mdview — so you still run mdview notes.md after installing.
Or build from source:
Keys
| Key | Action |
|---|---|
Tab |
Toggle rendered ↔ raw view |
j / ↓ |
Scroll down one line |
k / ↑ |
Scroll up one line |
Space / PgDn |
Scroll down a page |
PgUp |
Scroll up a page |
g / Home |
Jump to top |
G / End |
Jump to bottom |
| Mouse wheel | Scroll |
- / + |
Narrow / widen the content column |
o |
Open first visible image in system viewer |
| Left-click on image | Open that image in system viewer |
y |
Copy the file path to the clipboard |
q / Esc |
Quit |
Tweaks
A few constants near the top of src/main.rs control the look:
const MAX_CONTENT_WIDTH: u16 = 130; // cap on column width
const MIN_CONTENT_WIDTH: u16 = 80; // floor for -/+ adjustments
const DEFAULT_CONTENT_WIDTH: u16 = 90; // startup width target
const SIDE_MARGIN: u16 = 4; // breathing room left+right
const WIDTH_STEP: u16 = 4; // cells per -/+ press
const FRAME_COLOR: Color = DarkGray;
const TITLE_COLOR: Color = Green;
Startup column = min(DEFAULT_CONTENT_WIDTH, terminal_width - SIDE_MARGIN). Adjust live with - and + (clamped to [MIN_CONTENT_WIDTH, min(MAX_CONTENT_WIDTH, terminal_width - SIDE_MARGIN)]); each press re-renders the cached markdown.
Stack
ratatui+crossterm— TUI rendering and inputpulldown-cmark— CommonMark parsersyntect— code-block syntax highlightingimage— decoding for half-block image previewsunicode-width— cell widths for table layoutarboard— clipboardanyhow— error handling
The markdown renderer is a hand-rolled walk over the pulldown-cmark event stream — see src/render.rs. It handles headings (with ═/─ underbars on h1/h2), bold/italic/strikethrough/links, inline code, fenced code blocks (syntect-highlighted with a dark background and a language tag), ordered and unordered lists with nesting, blockquotes with a left bar, horizontal rules, tables with box-drawing borders that shrink columns to fit the content width, justified paragraphs, half-block image previews, and TeX math via a small hand-rolled converter (src/math.rs).
License
MIT — see LICENSE.