diff --git a/README.md b/README.md index c7f30dd..04a9693 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,11 @@ Select your browser from `Value menu`. If it's not there, follow [EmacsWiki: Bro [Solarized-dark](http://thomasf.github.io/solarized-css/) +In order to change preview styling, run `M-x customize-option` -> `markdown-preview-style` +and specify your favourite markdonw css URI. + +## Websocket port + +Adjustable by `M-x customize-option` -> `markdown-preview-port`. + ## El-get recipe included diff --git a/markdown-preview-mode.el b/markdown-preview-mode.el index 21002bc..95abdb7 100644 --- a/markdown-preview-mode.el +++ b/markdown-preview-mode.el @@ -27,17 +27,26 @@ (require 'websocket) (require 'markdown-mode) -(defgroup markdown-preview-mode nil +(defgroup markdown-preview nil "Markdown preview mode" :group 'text - :prefix "mdpm:") + :prefix "mdpm:" + :link '(url-link "https://github.com/ancane/markdown-preview-mode")) + +(defcustom markdown-preview-port 7379 + "Markdown preview websocket server port" + :group 'markdown-preview + :type 'integer) + +(defcustom markdown-preview-style "http://thomasf.github.io/solarized-css/solarized-dark.min.css" + "Markdown preview style URI" + :group 'markdown-preview + :type 'string) -(defvar mdpm:websocket-port 7379) (defvar mdpm:websocket-server nil) (defvar mdpm:local-client nil) (defvar mdpm:remote-clients nil) (defvar mdpm:preview-url (concat (file-name-directory load-file-name) "preview.html")) -(defvar mdpm:style "http://thomasf.github.io/solarized-css/solarized-dark.min.css") (defun mdpm:open-browser-preview () (browse-url mdpm:preview-url)) @@ -58,7 +67,7 @@ (when (not mdpm:websocket-server) (setq mdpm:websocket-server (websocket-server - mdpm:websocket-port + markdown-preview-port :on-message (lambda (websocket frame) (mapc (lambda (ws) (websocket-send-text ws @@ -76,7 +85,7 @@ (when (not mdpm:local-client) (setq mdpm:local-client (websocket-open - (format "ws://localhost:%d" mdpm:websocket-port) + (format "ws://localhost:%d" markdown-preview-port) :on-error (lambda (ws type err) (message "error connecting")) :on-close (lambda (websocket) @@ -93,7 +102,7 @@ (concat "