LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

mdv

Styled terminal Markdown viewer

TLDR

View a Markdown file with default theme
$ mdv [path/to/file.md]
copy
Pipe Markdown from stdin
$ echo "# Hello" | mdv -
copy
Monitor a file and redisplay on change
$ mdv -m [path/to/file.md]
copy
Render with a specific theme (e.g. 729.8953 for a darker style)
$ mdv -t [729.8953] [path/to/file.md]
copy
Preview all available themes
$ mdv -t all [path/to/file.md]
copy
Render without ANSI color (plain text)
$ mdv -A [path/to/file.md]
copy
Fix the column width to 80
$ mdv -c [80] [path/to/file.md]
copy
Render as HTML instead of ANSI
$ mdv -H [path/to/file.md]
copy

SYNOPSIS

mdv [options] MDFILE

DESCRIPTION

mdv is a Python tool that renders Markdown documents directly in a 256-color terminal. It parses headings, lists, tables, block quotes, and fenced code blocks and emits styled ANSI output with syntax highlighting driven by Pygments. A large collection of color themes is bundled and can be previewed with -t all.Beyond one-shot rendering, mdv can watch a file or directory with -m/-M and refresh the view whenever the source changes, which is useful when editing Markdown in a second window. When called as a Python library, the same rendering is available as mdv.main() so it can be embedded in other programs (for example, to pretty-print CLI help text).

PARAMETERS

-A

Strip all ANSI escape codes; useful for piping to files or paging tools that don't interpret color.
-C mode
Source code highlighting mode (all, code, doc, mod).
-H
Output the rendered document as HTML.
-L
Shortcut for -u i (inline link style).
-M dir
Monitor dir for Markdown file changes.
-T theme
Color theme for code blocks (accepts random or all).
-X lexer
Default Pygments lexer name (default: python).
-b n
Tab length (default: 4).
-c cols
Fix column width to cols characters.
-f from
Start rendering at substring from; supports HEADING:N to limit to N lines after a heading.
-h
Show help.
-i
Display the selected theme's metadata along with the rendering.
-l
Experimental light-background mode.
-m
Monitor the input file and redisplay when it changes.
-n NRS
Enable header numbering (e.g. -3, 1-, 1-5).
-t theme
Markdown color theme. Accepts a numeric ID (e.g. 729.8953), random, or all.
-u style
Link rendering style: it (inline table), h (hide), i (inline).
-x
Disable automatic lexer guessing for code blocks.

CONFIGURATION

Defaults are read from ~/.mdv (YAML) for CLI arguments, and ~/.mdv.py (Python) is evaluated if present for dynamic overrides.Environment variables:MDV_THEME

Default Markdown theme ID.
MDV_CODE_THEME
Default Pygments theme for code blocks.

CAVEATS

Requires a 256-color terminal, and most themes assume a dark background — use -l for light backgrounds. Rendering uses unicode box characters, so a font that supports them is recommended. The project is written in Python; on recent distributions install it via pip install mdv or brew install mdv.

HISTORY

Written by axiros and first released in 2015 as terminalmarkdownviewer. The project is published under the BSD license and continues to receive sporadic updates; version 1.7.5 was released in September 2023. A lighter-weight sibling, mdvl, was later created by the same author for minimal environments.

SEE ALSO

glow(1), bat(1), pygmentize(1), pandoc(1)

Copied to clipboard
Kai