Allow using relative links from the file to preview, references issue #11

Change the implementation of "markdown-preview--open-browser-preview" to
copy "preview.html" into the directory of the Markdown file to be
previewed and browse-url that file instead.
This commit is contained in:
Jean-Baptiste Lab 2016-08-23 09:48:37 +02:00
parent 625c041efd
commit 90b964e27d
1 changed files with 6 additions and 1 deletions

View File

@ -74,7 +74,12 @@
(defun markdown-preview--open-browser-preview ()
"Open the markdown preview in the browser."
(browse-url markdown-preview--preview-url))
(let* ((dir-of-buffer-to-preview (file-name-directory
(buffer-file-name (get-buffer (buffer-name)))))
(preview-file (concat dir-of-buffer-to-preview ".markdown-preview.html")))
(if (not (file-exists-p preview-file))
(copy-file markdown-preview--preview-url preview-file))
(browse-url preview-file)))
(defun markdown-preview--stop-websocket-server ()
"Stop the `markdown-preview' websocket server."