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
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.
โจ 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 markdown-viewer --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
- deep-translator โ Translation via MyMemory API
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.1.tar.gz.
File metadata
- Download URL: markdown_viewer_app-1.1.1.tar.gz
- Upload date:
- Size: 43.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62c597cab90e51d7bafbed8f96e9cb76d9b9f41b8ecc9f6cdb66eb700ea2f7f0
|
|
| MD5 |
bdf18c4ad12c40d7913a0ab983d7b09e
|
|
| BLAKE2b-256 |
48b1a41a1fca1e2f1591a27b9188b6224e94009a740e17881e759e040ef6d1c1
|
File details
Details for the file markdown_viewer_app-1.1.1-py3-none-any.whl.
File metadata
- Download URL: markdown_viewer_app-1.1.1-py3-none-any.whl
- Upload date:
- Size: 54.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c161a5bb1a73c528456885f6d3036f6e8b8804087679144e1b557e89449e856
|
|
| MD5 |
00bf120fba07f4965521e047bf0ea616
|
|
| BLAKE2b-256 |
089a10f00aef0d9b8d24bd83eef6996c499a2a48ce613d40ee95ccc18196979e
|