markdown-preview-mode/README.md

80 lines
2.7 KiB
Markdown
Raw Normal View History

2014-09-14 11:18:24 +02:00
Markdown preview mode
2014-09-13 14:19:34 +02:00
===========================
2016-12-05 14:40:52 +01:00
2016-01-15 08:30:43 +01:00
[![MELPA Stable](http://stable.melpa.org/packages/markdown-preview-mode-badge.svg)](http://stable.melpa.org/#/markdown-preview-mode)
[![MELPA](http://melpa.org/packages/markdown-preview-mode-badge.svg)](http://melpa.org/#/markdown-preview-mode)
2014-09-14 16:41:52 +02:00
## Description
Opens a preview in a browser, updated upon buffer save.
2016-01-10 15:01:10 +01:00
2014-10-23 21:59:45 +02:00
Same preview window is valid across multiple markdown buffers.
2014-10-24 17:12:04 +02:00
Scrolls browser window to keep your editing position visible.
2014-09-14 11:18:24 +02:00
2014-09-15 07:30:13 +02:00
## Usage
2016-01-11 10:47:02 +01:00
2016-01-10 23:57:55 +01:00
`M-x markdown-preview-mode` will open preview in a browser and will start `markdown-mode` if it's not yet running for current buffer. If you've closed the preview window, you can start it over with `M-x markdown-preview-open-browser`. All websockets will be cleaned up on emacs termination. If you'd like to perform cleanup manually run `M-x markdown-preview-cleanup`.
2014-09-14 16:41:52 +02:00
## Multimarkdown
In order to enable multimarkdown support, customize
`M-x customize-option` -> `markdown-command` variable.
Look for `Markdown Command` which is set to `markdown` by default,
set to `multimarkdown` and make sure it's in your PATH.
## Browser
2016-01-10 23:57:55 +01:00
In order to select preferred browser, customize
2014-09-14 16:41:52 +02:00
`M-x customize-option` -> `browse-url-browser-function` option.
Select your browser from `Value menu`. If it's not there, follow [EmacsWiki: Browse Url](http://www.emacswiki.org/emacs/BrowseUrl).
2016-12-11 13:04:36 +01:00
## Stylesheets
2014-09-14 16:41:52 +02:00
2016-12-11 13:04:36 +01:00
Default theme for preview is [Solarized-dark](http://thomasf.github.io/solarized-css/)
2016-12-11 13:04:36 +01:00
Extra css are added with:
2014-09-15 21:39:14 +02:00
2016-12-11 13:04:36 +01:00
```lisp
(add-to-list 'markdown-preview-stylesheets "https://raw.githubusercontent.com/richleland/pygments-css/master/emacs.css")
```
Override theme completely with:
```lisp
(setq markdown-preview-stylesheets (list "http://thomasf.github.io/solarized-css/solarized-light.min.css"))
```
## Extra javascript
2016-12-05 14:40:52 +01:00
If you'd like to include additional javascript for the preview, add this to your init:
```lisp
(add-to-list 'markdown-preview-javascript "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML")
```
or, to make it async:
```lisp
(add-to-list 'markdown-preview-javascript '("http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML" . async))
```
2014-09-15 21:39:14 +02:00
## Websocket port
Adjustable by `M-x customize-option` -> `markdown-preview-port`.
## Installation
### Melpa
*Melpa* recipe is available, so `markdown-preview-mode` is just a `package-install` away!
### el-get
2014-10-27 10:35:20 +01:00
* `M-x el-get-self-update`
* `M-x el-get-install` -> `markdown-preview-mode`
## Dependencies
* [markdown-mode.el](https://github.com/defunkt/markdown-mode)
* [websocket.el](https://github.com/ahyatt/emacs-websocket)
Makes use of `markdown-mode`, which already can transform markdown into html
and `websocket.el` to deliver html to browser.