← 返回命令列表

Linux command

mdv 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

View a Markdown file

mdv [path/to/file.md]

Pipe Markdown

echo "# Hello" | mdv -

Monitor a file

mdv -m [path/to/file.md]

Render with a specific theme

mdv -t [729.8953] [path/to/file.md]

Preview all available themes

mdv -t all [path/to/file.md]

Render without ANSI color

mdv -A [path/to/file.md]

Fix the column width

mdv -c [80] [path/to/file.md]

Render as HTML

mdv -H [path/to/file.md]

说明

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).

参数

-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.

FAQ

What is the mdv command used for?

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).

How do I run a basic mdv example?

Run `mdv [path/to/file.md]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -A do in mdv?

Strip all ANSI escape codes; useful for piping to files or paging tools that don't interpret color.