A lightweight, native macOS application for viewing Markdown and HTML files with elegant styling and powerful navigation features.
- Multi-format support: View
.md,.markdown,.html, and.htmfiles - Beautiful themes: 16 built-in CSS themes for different viewing preferences
- Fast navigation: Navigate between multiple files with keyboard shortcuts
- Search functionality: Find and navigate through text within documents
- Print support: Optimized printing with proper page formatting
- Font control: Adjust font size on the fly
- File operations: Save rendered HTML, open new files
- Custom styling: Use your own CSS files for personalized themes
-
macOS (any recent version)
-
Pandoc for Markdown rendering:
brew install pandoc
-
Clone this repository:
git clone https://github.com/yourusername/mdviewer.git cd mdviewer -
Make the script executable:
chmod +x mdviewer.swift
-
Run the application:
./mdviewer.swift
# Open file selector dialog
./mdviewer.swift
# View specific files
./mdviewer.swift README.md
./mdviewer.swift "*.md"
./mdviewer.swift "docs/*.html"
# Use custom CSS theme
./mdviewer.swift --css assets/github.css "*.md"
# Generate HTML output without opening viewer
./mdviewer.swift README.md --output rendered.html| Key | Action |
|---|---|
j |
Previous file |
k |
Next file |
0 |
First file |
$ |
Last file |
o |
Open new files |
w |
Save current file as HTML |
p |
Print document |
q |
Quit application |
+ |
Increase font size |
- |
Decrease font size |
= |
Reset font size |
/ |
Search in document |
n |
Next search result |
N |
Previous search result |
Home |
Scroll to top |
The application includes 16 beautiful themes in the assets/ directory:
academic.css- Clean academic styleamber.css- Warm amber tonesbusiness.css- Professional business lookclean.css- Minimal clean designelegant.css- Elegant serif typographygithub.css- GitHub-style inspired formattinggruvbox.css- Popular retro color schememinimalistic.css- Ultra-minimal designmodern.css- Modern sans-serif stylingretro.css- Vintage terminal looksakura.css- Gentle pink themesand.css- Desert-inspired colorsscholary.css- Academic paper stylesynthwave.css- Cyberpunk neon themetufte.css- Edward Tufte-inspired layoutwater.css- Cool blue tones
Use any theme with:
./mdviewer.swift --css assets/github.css your-file.mdUSAGE:
mdviewer.swift [OPTIONS] [MASKS...]
OPTIONS:
--help Show help message and exit
--css FILE Use a custom CSS file for styling
--output FILE Write rendered HTML to FILE and exit (no window)
MASKS:
One or more file patterns, e.g. *.md docs/*.html my*.*
Only .html, .htm, .md, .markdown files are supported.
If no masks provided, a file selector dialog appears.
./mdviewer.swift "*.md"./mdviewer.swift --css assets/synthwave.css README.md./mdviewer.swift --css assets/elegant.css --output website.html README.md./mdviewer.swift "docs/*.md" "*.markdown"MDViewer is built as a single Swift file (mdviewer.swift) using:
- Cocoa: Native macOS windowing and UI
- WebKit: HTML rendering engine
- Pandoc: Markdown to HTML conversion
- Swift: Modern, safe systems programming
The application creates a native macOS window with a WebKit view for rendering content. Markdown files are converted to HTML using Pandoc with embedded resources for offline viewing.
mdviewer/
├── mdviewer.swift # Main application (single file)
├── assets/ # CSS theme collection
│ ├── github.css
│ ├── modern.css
│ └── ... # 14 other themes
├── README.md # This file
└── CLAUDE.md # Development guidance
- Fork the repository
- Create a feature branch
- Make your changes
- Test with various file types and themes
- Submit a pull request
To add a new CSS theme:
- Create a new
.cssfile in theassets/directory - Follow the existing theme structure
- Test with various Markdown content
- Ensure print media queries work properly
This project is open source. Feel free to use, modify, and distribute as needed.
Add screenshots here showing the application with different themes
If you see a pandoc error, install it with:
brew install pandocIf the script won't run, make it executable:
chmod +x mdviewer.swiftEnsure your CSS file path is correct and readable:
ls -la path/to/your/custom.css- Pandoc - Universal document converter
- Marked 2 - Commercial Markdown preview app
- MacDown - Open source Markdown editor
MDViewer - Simple, elegant Markdown and HTML viewing for macOS