Markdown previewer - preview markdown files in your browser.
mdp converts a markdown file to HTML and opens it in your browser. It supports GitHub Flavored Markdown and custom themes.
$ mdp README.md
Generated: /Users/you/.mdp/README.htmlmdp [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/Configuration file is loaded from the following locations in order of priority:
--configflag (explicit path)$UserConfigDir/mdp/config.yaml$UserConfigDir/mdp/config.yml$HOME/.config/mdp/config.yaml$HOME/.config/mdp/config.yml- No config file (use defaults)
$UserConfigDir is determined by 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: falseYou can create custom themes by placing HTML template files in the themes/ directory under your config directory.
For example, to use a theme named custom, create themes/custom.html in your config directory:
<!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 |
The title is extracted from the markdown file in the following order of priority:
titlefield in YAML front-matter- First heading in the document
"Untitled"(default)
Example with front-matter:
---
title: My Document Title
---
# Heading
Content here.In this case, {{.Title}} will be "My Document Title".
MIT