diff --git a/.gitignore b/.gitignore
index 9b4291b..2c5047e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@
# Packaging
.cask
+
+.markdown-preview.html
diff --git a/README.md b/README.md
index c2dd859..24e84ee 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
Markdown preview mode
===========================
+
[![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)
@@ -34,6 +35,19 @@ Select your browser from `Value menu`. If it's not there, follow [EmacsWiki: Bro
In order to change preview styling, run `M-x customize-option` -> `markdown-preview-style`
and specify a URL to your favourite markdown css file.
+## Client javascript
+
+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))
+```
+
## Websocket port
Adjustable by `M-x customize-option` -> `markdown-preview-port`.
diff --git a/markdown-preview-mode.el b/markdown-preview-mode.el
index f45af2d..4a27095 100644
--- a/markdown-preview-mode.el
+++ b/markdown-preview-mode.el
@@ -61,6 +61,9 @@
:group 'markdown-preview
:type 'string)
+(defvar markdown-preview-javascript (list "http://code.jquery.com/jquery-1.11.0.min.js")
+ "List of javascript libs for preview.")
+
(defvar markdown-preview--websocket-server nil
"`markdown-preview' Websocket server.")
@@ -90,6 +93,13 @@
(insert-file-contents markdown-preview--preview-template)
(if (search-forward "${MD_STYLE}" nil t)
(replace-match markdown-preview-style t))
+ (if (search-forward "${MD_JS}" nil t)
+ (replace-match
+ (mapconcat (lambda (x)
+ (concat "" ))
+ markdown-preview-javascript
+ "\n")
+ t))
(if (search-forward "${WS_HOST}" nil t)
(replace-match markdown-preview-host t))
(if (search-forward "${WS_PORT}" nil t)
@@ -182,8 +192,7 @@
(markdown-preview--stop-idle-timer)
(let ((preview-file (concat (file-name-directory (buffer-file-name)) markdown-preview-file-name)))
(if (file-exists-p preview-file)
- (delete-file preview-file)))
- )
+ (delete-file preview-file))))
;;;###autoload
(defun markdown-preview-open-browser ()
diff --git a/preview.html b/preview.html
index 78d0166..1521174 100644
--- a/preview.html
+++ b/preview.html
@@ -10,7 +10,7 @@
line-height: 1.2em;
}
-
+ ${MD_JS}