Preview Github markdown - as you type
The most exciting part in a project's lifetime is bragging about how awesome it is, usually in it's README file. However, to get the wording and formatting just right, one would need to write the file using Github's online editor, switching back and forth between editing and previewing, loosing all the efficiencies of using a copy of the vim text editor.
- Preview rendered markdown as you type
- Output is rendered as if it was already on github
- Editor-friendly
- Scroll synchronization, inspired by Ghost — since v0.2.2
- Heading anchors — since v1.0.1-next
The server is running on node and requires npm to install:
$ npm install -g gh-preview@1.0.0-next
To run the server manually, use the gh-preview
command.
Note that the vim plugin will start the server automatically if it is not
already running at the given port.
Usage:
gh-preview [--port=<port>]
Options:
-p, --port=<port> The port to bind to [Default: 1234]
Feel free to contribute an editor plugin for your favourite editor and open an issue on github to have it mentioned here.
Simply have your editor perform HTTP POST
requests to the running
gh-preview instance. The plugin may optionally start a new gh-preview server.
For command line usage, refer to the README
.
To see an example usage, check out the tests and the vim plugin. From the tests:
import request from 'request';
request.post({
url: 'localhost:${ port }/api/doc'
, json: { 'file': '/bar/foo.md'
, 'markdown': '# Foo!' }});
This will create a document titled foo.md
, with the markdown being
# Foo!
. The markdown will then be rendered on the client, as served by
the gh-preview
server.
Github uses pygments for their syntax highlighting,
whereas this project uses highlight.js
- which, while awesome - is not
pygments
and differences are bound to occur.
Since this a very purpose-driven project - that is to be able to interactively preview markdown files before publishing to github - work on this project is not focused and hence the following items, albeit relatively simple tasks, are likely to remain wishes for the future to come.
- Show the caret in the output
- Improve scroll synchronization
Business as usual. Get started by running the test suite:
npm run test
Then fix bug / add feature and submit a pull request.