mdok
A document-grade reader for Markdown and Word (.docx) files in the terminal.
Most terminal renderers either stretch text across the entire display width or force it into a rigid, narrow column on the left edge. Tables often fuse rows together, eat technical tags like <Type>, or ignore <br> line breaks. Word documents (.docx) piped through pandoc turn into broken ASCII grids, raw [tags]{.underline}, and corrupted multi-column tables.
mdok formats Markdown and Word documents like clean, readable documents:
- Word (
.docx) Reader: Native OpenXML parser built with Python's standard library (zero heavy binary dependencies). Cleanly renders contracts, agreements, technical specifications, and resumes:- Tables: Column width allocation via
<w:tblGrid>, multi-column cell spans (<w:gridSpan>), cell background shading (<w:shd>), and header rows (<w:tblHeader>). - Borderless Layout Tables: Intelligently renders side-by-side signature and party metadata blocks without ugly grid lines.
- Checkboxes & Form Controls: Structured document checkboxes (
☑/☐) and Wingdings symbols. - Footnotes & Endnotes: Clean inline citations with reference sections rendered at the bottom.
- Try it:
mdok examples/showcase.docxormdok examples/showcase.md.
- Tables: Column width allocation via
- Proportional width & centering: Centers text on wide displays with gentle margins and scales comfortably (~75% of terminal width up to ~120 columns).
- Readable tables: LaTeX booktabs style—horizontal rules, no heavy ASCII borders, soft cell wrapping, alignment support, and row dividers so multiline rows don't run together.
- Tag & line break handling: Preserves technical tags (like
<Tag>or<Property>) and respects<br>breaks inside cells. - Muted colors: Inline code uses a warm amber (
#e0af68) on a subtle dark badge instead of bright yellow. Code blocks default to the Nord syntax theme. - Automatic pager with Vim navigation: Seamless cursor-based reading in Neovim/Vim with text cursor, or tuned
lesswith smart-case search and centered matches. - GitHub-style callouts: Renders
> [!NOTE],> [!TIP],> [!WARNING], etc.
Installation
pip install mdok
Or from source:
git clone https://github.com/anton/mdok.git
cd mdok
pip install .
For development:
pip install -e .
Usage
Read a Markdown or Word document:
mdok README.md
mdok contract.docx
Pipe from standard input:
cat doc.md | mdok
cat agreement.docx | mdok
Jump directly to a search match:
mdok doc.md -s "Installation"
mdok contract.docx -s "Termination"
Options
mdok doc.md -s "Installation" # Jump directly to search pattern and highlight
mdok doc.md -w 100 # Explicit document width in columns
mdok doc.md -m 4 # Explicit left margin
mdok doc.md --no-center # Align to left edge
mdok doc.md -b rounded # Table style (booktabs, rounded, simple, minimal, none)
mdok doc.md --code-theme gruvbox-dark # Syntax highlighting theme
mdok doc.md --nvim # Force Neovim viewer (true text cursor, libvterm)
mdok doc.md --vim # Force Vim viewer (+terminal mode with text cursor)
mdok doc.md --less # Force tuned less pager
mdok doc.md --no-pager # Print directly without pager
mdok doc.md --pager-cmd "bat -p" # Custom pager command (or use $MDOK_PAGER / $PAGER)
Viewer Engine & Graceful Degradation
mdok automatically selects the best available viewer engine for your system:
- Neovim (
nvim): If installed, launches in Neovim terminal mode with full 24-bit truecolor fidelity and a real text cursor that moves through the document. - Vim (
vim): Ifnvimis absent, detects if Vim is installed with+terminalsupport. - Tuned
less: If neither is installed, gracefully degrades tolesswith smart-case search, vertical centering (-j.5), left gutter hit marks (-J), and vivid highlights (-DSkY). - Standard Output: If no pager binary is found, prints directly to stdout with zero errors.
Navigation & Search
When viewing documents in mdok's cursor viewer:
| Key | Action |
|---|---|
h / j / k / l or Arrows |
Move cursor left / down / up / right |
w / b |
Hop forward / backward word-by-word |
0 / $ |
Jump to beginning / end of line |
d / u or Ctrl-D / Ctrl-U |
Half-page down / up |
g / G |
Jump to top / bottom of document |
/pattern / ?pattern |
Search forward / backward |
n / N |
Next / previous match (cursor lands directly on the match) |
v / V then y |
Visual select and yank text directly to system clipboard |
yy |
Yank current line directly to system clipboard |
yw / yip |
Yank word / paragraph to system clipboard |
Mouse drag + y |
Select with mouse and yank to system clipboard |
e |
Open source markdown file for editing |
q |
Exit |
Metadata
Release files for mdok 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mdok-0.1.3.tar.gz | 43.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mdok-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 74.3 kB
Release files / mdok-0.1.3.tar.gz
| Download URL | mdok-0.1.3.tar.gz |
|---|---|
| Size | 43.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
518d07cdbe00f279afdd71867e5431cfbe7d71f87c5a38c368c04b854b795641
|
|
BLAKE2b-256 checksum How to use checksums |
3d66f7fa80863483221b9e8e64a6dd59cf5339911ab5aa2222228e84e36d6918
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / mdok-0.1.3-py3-none-any.whl
| Download URL | mdok-0.1.3-py3-none-any.whl |
|---|---|
| Size | 30.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0c86b36786301596fe447ac8b4a58edee3cecc2c4288e5a4bef5b8834c75683
|
|
BLAKE2b-256 checksum How to use checksums |
cde177314572eca7201d5159be5b8f8fb721bd016c6603b07008919269e5c63f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|