Beautiful markdown viewer and renderer for CLI, CI/CD, and automated workflows
Project description
Markdown Viewer
Open any markdown file in a full browser UI with one command. Supports PDF and Word export, Mermaid diagrams, math equations, syntax highlighting, and content translation.
๐ฆ Installation
pip install markdown-viewer-app
playwright install chromium
playwright install chromiumis a one-time setup (~140 MB) required for PDF export. Skip it if you don't need PDF export.
๐ Quick Start
# Open a file in your browser
mdview README.md
# Export to PDF
mdview README.md --export-pdf
# Export to Word
mdview README.md --export-word
# Export to both at once
mdview README.md --export-pdf --export-word
# Render to HTML only (no browser โ useful for CI/CD)
mdview README.md --no-browser
# Save HTML to a specific file
mdview README.md -o output.html
# Use a custom port (default is 5000)
mdview README.md -p 5001
# Stop the background server on a custom port
mdview --stop -p 5001
When you run mdview <file>, the app:
- Starts a background server on port 5000 (silently โ no extra window opens)
- Opens your browser directly to the rendered file
- Returns you to the terminal immediately
The server keeps running in the background. Subsequent mdview calls reuse it instantly. Use -p/--port to run multiple servers on different ports simultaneously.
๐ฅ๏ธ CLI Reference
mdview [file] [options]
Arguments
| Argument | Description |
|---|---|
file |
Path to the markdown file to render (optional โ prompts interactively if omitted in a terminal) |
Options
| Flag | Default | Description |
|---|---|---|
-o, --output <path> |
(temp file) | Save rendered HTML to this path instead of a temporary file |
--no-browser |
off | Render without opening a browser window |
--keep |
off | Keep the HTML output file after rendering (saved as <filename>.html next to the source) |
--export-pdf [path] |
โ | Export to PDF; optionally specify an output path |
--export-word [path] |
โ | Export to Word (.docx); optionally specify an output path |
--share-pdf |
โ | Export to PDF and open your email client with it attached |
--share-word |
โ | Export to Word and open your email client with it attached |
-p, --port <port> |
5000 |
Port for the background Flask server |
--stop |
โ | Stop the background server and release the port |
--version |
โ | Print the installed version and exit |
Examples
# --- Viewing ---
mdview README.md # Open in browser (default)
mdview README.md --no-browser # Render without opening browser
mdview README.md --no-browser --keep # Render and save README.html next to the source
# --- HTML output ---
mdview README.md -o docs/out.html # Save rendered HTML to a specific path
mdview README.md --no-browser -o out.html # Save HTML, no browser
# --- PDF export ---
mdview README.md --export-pdf # Export to README.pdf (same directory)
mdview README.md --export-pdf ~/docs/out.pdf # Export to a specific path
# --- Word export ---
mdview README.md --export-word # Export to README.docx
mdview README.md --export-word ~/docs/out.docx
# --- Export both at once ---
mdview README.md --export-pdf --export-word
# --- Email sharing ---
mdview README.md --share-pdf # Export PDF and open email client
mdview README.md --share-word # Export Word and open email client
# --- Server / port management ---
mdview README.md -p 5001 # Open using a custom port
mdview --stop # Stop the default server (port 5000)
mdview --stop -p 5001 # Stop a server on a custom port
# --- CI/CD (non-interactive) ---
# When stdout is not a TTY, browser and server are skipped automatically
mdview README.md -o output.html
# --- Version ---
mdview --version
โจ Features
๐ Rich Markdown Rendering
- Full GitHub Flavored Markdown (GFM) support
- Syntax highlighting for 180+ programming languages
- Tables, task lists, footnotes, blockquotes, and more
- Emoji support with correct Unicode rendering
๐ Diagram Support
- Mermaid: flowcharts, sequence diagrams, pie charts, Gantt charts, state diagrams
- Diagrams are preserved in all export formats
๐ข Math Equations
- KaTeX integration for beautiful math rendering
- Inline:
$E = mc^2$ - Block equations with full LaTeX syntax
๐ Export
- PDF โ high-quality, print-ready (powered by Playwright/Chromium)
- Word (.docx) โ editable documents with preserved formatting
- Silent: no popup dialogs, status bar updates on completion
๐ Translation
- Translate content to 15+ languages directly from the UI
- Preserves markdown formatting and code blocks
- Powered by MyMemory (free API, no key needed)
๐ Security
- CSRF protection on all API endpoints
- Content Security Policy (CSP) headers
- Input validation with Marshmallow schemas
- Path traversal protection
- Localhost-only server binding (127.0.0.1)
๐ ๏ธ Productivity Tools
- Copy all content with one click
- Share via email
- Keyboard shortcuts:
Ctrl+O(open),Ctrl+Shift+C(copy),F5(refresh),F11(fullscreen)
๐ Markdown Reference
Basic Formatting
# Heading 1
## Heading 2
### Heading 3
**bold**, *italic*, ~~strikethrough~~, ==highlighted==
- Unordered list
- Nested item
1. Ordered list
[Link text](https://example.com)

Code Blocks
```python
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
```
```sql
SELECT name, COUNT(*) FROM users GROUP BY name;
```
Tables
| Feature | Markdown Viewer | Typora | VS Code |
|----------------|:---------------:|:------:|:-------:|
| PDF Export | โ
| โ
| โ |
| Word Export | โ
| โ
| โ |
| Translation | โ
| โ | โ |
| Diagrams | โ
| โ
| โ
|
| Free & Open | โ
| โ | โ
|
Mermaid Diagrams
```mermaid
graph TD
A[Start] --> B{Working?}
B -->|Yes| C[Great!]
B -->|No| D[Debug] --> B
```
```mermaid
sequenceDiagram
Client->>Server: Request
Server-->>Client: Response
```
Math Equations
Inline: $x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$
Block:
$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$
Task Lists
- [x] Install Markdown Viewer
- [x] Open first document
- [ ] Try exporting to PDF
๐ง Development Setup
git clone https://github.com/dimpletz/markdown-viewer.git
cd markdown-viewer
poetry install
poetry run playwright install chromium
Run
# Open a file (server auto-reloads on code changes)
poetry run mdview README.md
# Or start the server standalone
poetry run mdview README.md --no-browser
Tests
# Run all tests
poetry run pytest
# With coverage report
poetry run pytest --cov=markdown_viewer --cov-report=html
Project Structure
markdown-viewer/
โโโ markdown_viewer/
โ โโโ app.py # Flask application factory
โ โโโ routes.py # API endpoints
โ โโโ server.py # Server management
โ โโโ cli.py # CLI entry point (mdview)
โ โโโ electron/ # Browser UI (HTML/JS/CSS)
โ โ โโโ renderer/
โ โ โโโ index.html
โ โ โโโ scripts/
โ โ โโโ styles/
โ โโโ exporters/ # PDF & Word export
โ โโโ processors/ # Markdown processing
โ โโโ translators/ # Translation service
โ โโโ utils/ # File handling
โโโ tests/
โโโ docs/
โโโ examples/
๐ Known Limitations
- PDF export requires
playwright install chromium(one-time ~140 MB download) - Translation requires an internet connection
- Word export has limited support for complex CSS styling
๐ More Documentation
๐ค Contributing
- Fork the repository
- Create a branch:
git checkout -b feature/my-feature - Make your changes and add tests:
poetry run pytest - Open a pull request
๐ License
MIT License โ see LICENSE for details.
๐ Acknowledgments
- Flask โ Python web framework
- Python-Markdown โ Markdown parser
- Playwright โ PDF generation via Chromium
- python-docx โ Word document export
- Mermaid โ Diagram rendering
- KaTeX โ Math typesetting
- Pygments โ Syntax highlighting
- DOMPurify โ XSS sanitization
- MyMemory โ Free translation API (called directly via stdlib
urllib)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markdown_viewer_app-1.1.3.tar.gz.
File metadata
- Download URL: markdown_viewer_app-1.1.3.tar.gz
- Upload date:
- Size: 46.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.14.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaad745758856e2584a0ab2712b785cafbf5d7210d719c48eeaa4b8d38a38972
|
|
| MD5 |
6596877f0d34065f84ac666726028410
|
|
| BLAKE2b-256 |
2a9ad7b475ffbaf11a77059ac84e1fa1945d23b01bb3bd71ed96fd2408485646
|
File details
Details for the file markdown_viewer_app-1.1.3-py3-none-any.whl.
File metadata
- Download URL: markdown_viewer_app-1.1.3-py3-none-any.whl
- Upload date:
- Size: 57.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.14.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8dc74696dcda52b152e36ef88719f7a36d66281c3c288f0ac11a6afbc406e68
|
|
| MD5 |
5c8d42527ce0ec5fd99e539c1428fc69
|
|
| BLAKE2b-256 |
e759920547d66d6b6a9173351ece02fedd3d9c0bd826091a02f796ff0b6fcf98
|