Skip to main content

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.docx or mdok examples/showcase.md.
  • 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 less with 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:

  1. 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.
  2. Vim (vim): If nvim is absent, detects if Vim is installed with +terminal support.
  3. Tuned less: If neither is installed, gracefully degrades to less with smart-case search, vertical centering (-j.5), left gutter hit marks (-J), and vivid highlights (-DSkY).
  4. Standard Output: If no pager binary is found, prints directly to stdout with zero errors.

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

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdok 0.1.2
File Size Uploaded
mdok-0.1.2.tar.gz 42.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mdok 0.1.2
File Interpreter ABI Platform
mdok-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 72.7 kB

Release files / mdok-0.1.2.tar.gz

Download URL mdok-0.1.2.tar.gz
Size 42.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4dce836380e5b0e0358ad294e29274732bad72cb07a59955145b706a910f4e5f
BLAKE2b-256 checksum
How to use checksums
96d0937269d7fa2227becf3748208e434e6d4c823df0c207b2705484b0045ba1
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.2-py3-none-any.whl

Download URL mdok-0.1.2-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4da6ffdc3ae5d05abde534f933d096de132857fa0ccb7854d31198c517c6ae3
BLAKE2b-256 checksum
How to use checksums
4e1e89dc82052c3c8cb2c198a995e4be7044e3f9490399539f026803bf6c8fad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release history Release notifications | RSS feed

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page