A Markdown previewer that shows markdown files in your browser.
mdp converts markdown files to HTML and opens them in your browser. It supports GitHub Flavored Markdown and custom themes.
$ mdp README.md
Generated: /Users/you/.mdp/README.htmlYou can pass more than one file. Each file is converted and opened in its own tab, and --watch regenerates whichever file changes.
$ mdp --watch README.md CHANGELOG.md
Generated: /Users/you/.mdp/README.html
Generated: /Users/you/.mdp/CHANGELOG.html
Watching for changes... (Ctrl+C to stop)mdp [options] <markdown-file>...
--config <config-file> path to config file
--watch watch for file changes and regenerate
--list list generated files
--help show help message
brew install masawada/tap/mdpDownload the latest archive from GitHub Releases and install:
tar xzf mdp_*.tar.gz
sudo install mdp /usr/local/bin/$ go install github.com/masawada/mdp/cmd/mdp@latestgit clone https://github.com/masawada/mdp.git
cd mdp
make
sudo install mdp /usr/local/bin/mdp rewrites relative image paths into file:// URLs based on the directory of the markdown file, so the browser can show images next to the markdown without copying them. This works for both  and raw <img> tags (with unsafe: true). URLs that already have a scheme, such as https:// or data:, stay as they are.
mdp reads the file given by --config. Without the flag, it looks for a configuration file in these locations, in order:
$UserConfigDir/mdp/config.yaml$UserConfigDir/mdp/config.yml$HOME/.config/mdp/config.yaml$HOME/.config/mdp/config.yml
If no file is found, it uses the defaults.
$UserConfigDir comes from os.UserConfigDir():
- macOS:
~/Library/Application Support - Linux:
~/.config(or$XDG_CONFIG_HOME)
# Output directory for generated HTML files (default: ~/.mdp)
output_dir: ~/.mdp
# Command to open browser (default: open on macOS, xdg-open on Linux)
browser_command: open
# Theme name (optional, looks for themes/<name>.html in config directory)
theme: custom
# Convert newlines in paragraphs to <br> (default: false)
hard_wraps: false
# Allow raw HTML in markdown (default: false)
unsafe: falseTo create a custom theme, put an HTML template file in the themes/ directory under your config directory.
For example, a theme named custom lives at themes/custom.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{.Title}}</title>
<style>
body { font-family: sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
</style>
</head>
<body>
{{.Content}}
</body>
</html>| Variable | Description |
|---|---|
{{.Title}} |
Document title extracted from the markdown |
{{.Content}} |
Rendered HTML content |
mdp picks the title from the markdown file in this order:
titlefield in YAML front-matter- First heading in the document
"Untitled"(default)
Example with front-matter:
---
title: My Document Title
---
# Heading
Content here.Here {{.Title}} is "My Document Title".
MIT