ghpreview
When you're writing a README for your project, you want a way to preview the
Markdown locally before you push it. ghpreview
is a command-line utility that
opens your Markdown file in a browser. It uses Github styling and (optionally)
automatically refreshes every time you save your source.
While README files are the most common use case, `ghpreview** works with any Markdown file.
Prerequisites
You'll need the icu library:
-
Ubuntu/Debian:
sudo apt-get install libicu-dev
-
Mac OS:
brew install icu4c
You might also need to install cmake
for building native extensions from the dependencies.
Installation
$ gem install ghpreview
Usage
$ ghpreview README.md
This will open your default browser with a preview of README.md exactly as it
will appear on Github. For a live-updating preview, use the -w
(or --watch
)
option:
$ ghpreview -w README.md
To use an alternate browser, use the -a
(or --application
) option:
# On Mac:
$ ghpreview -a Safari.app README.md
# On GNU/Linux:
$ ghpreview -a konqueror README.md
Why is this better than X?
There are several tools available for previewing Markdown files, and many that provide a Github-like style. I've personally used Marked, Mou, and the vim-markdown plugin. All are good tools, but none are able to truly reproduce the custom features added to Github Flavored Markdown. This is especially notable with fenced code blocks and syntax highlighting.
ghpreview
is an accurate preview because it uses Github's own HTML
processing filters to generate the HTML,
and Github's own stylesheets to style it
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Write specs (
bundle exec rspec spec
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request