Skip to main content

Beautiful markdown viewer and renderer for CLI, CI/CD, and automated workflows

Project description

Markdown Viewer

View, export, and translate markdown files โ€” straight from the terminal

License: MIT Python PyPI Security

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 chromium is 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:

  1. Starts a background server on port 5000 (silently โ€” no extra window opens)
  2. Opens your browser directly to the rendered file
  3. 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)
![Alt text](https://example.com/image.png)

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

  1. Fork the repository
  2. Create a branch: git checkout -b feature/my-feature
  3. Make your changes and add tests: poetry run pytest
  4. Open a pull request

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


๐Ÿ™ Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markdown_viewer_app-1.1.2.tar.gz (44.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markdown_viewer_app-1.1.2-py3-none-any.whl (54.9 kB view details)

Uploaded Python 3

File details

Details for the file markdown_viewer_app-1.1.2.tar.gz.

File metadata

  • Download URL: markdown_viewer_app-1.1.2.tar.gz
  • Upload date:
  • Size: 44.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.14.3 Windows/11

File hashes

Hashes for markdown_viewer_app-1.1.2.tar.gz
Algorithm Hash digest
SHA256 05034384ad90e0a8dc36a920470344c45d8b391a5ee854684a163c52a505cf26
MD5 447d76a24b6410334310e0d604adea83
BLAKE2b-256 e04d8e10dacbdb1214d9f324b1c893c0befe05d1a493cb5e07ce43329bd1e6a0

See more details on using hashes here.

File details

Details for the file markdown_viewer_app-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for markdown_viewer_app-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7066572809dbf18964386c376d438c42a0e0cd06699b0391cb8075bfbc438f8a
MD5 4d81c150ccb299018eb32d735a44cab5
BLAKE2b-256 0aff80c0f8562cb49345474ac728f24b3bf078af0997701a8ddf7bc8b9db8187

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page