blob: 2536904adea2bb1811c91e8795ce889bb11e978d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
;;; markdown-config --- Settings for Editing Markdown -*- lexical-binding: t; coding: utf-8; -*-
;; author Craig Jennings <c@cjennings.net>
;;; Commentary:
;;; Code:
;;;; ------------------------- Markdown-Mode -------------------------
(use-package markdown-mode
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:bind (:map markdown-mode-map
("<f2>" . markdown-preview)) ;; use same key as compile for consistency
:init (setq markdown-command "multimarkdown"))
;; Register markdown as a known org-src-block language so `org-lint'
;; stops warning on `#+begin_src markdown ... #+end_src' and `C-c ''
;; inside such a block opens it in `markdown-mode' instead of falling
;; back to fundamental-mode.
(with-eval-after-load 'org
(add-to-list 'org-src-lang-modes '("markdown" . markdown)))
;;;; ------------------------- Impatient-Mode ------------------------
;; allows for live previews of your html
;; see: https://github.com/skeeto/impatient-mode
(use-package impatient-mode
:defer t
:config
(setq imp-set-user-filter 'markdown-html))
;;;; --------------------- WIP: Markdown-Preview ---------------------
;; the filter to apply to markdown before impatient-mode pushes it to the server
(defun markdown-preview ()
(interactive)
(httpd-start)
(impatient-mode 1)
(setq imp-user-filter #'cj/markdown-html)
(cl-incf imp-last-state)
(imp--notify-clients)
;; (browse-url-generic-function 'browse-url-xdg-open)
(browse-url-generic "https://localhost:8080/imp" 1))
(defun cj/markdown-html (buffer)
(princ (with-current-buffer buffer
(format "<!DOCTYPE html><html><title>Impatient Markdown</title><xmp theme=\"united\" style=\"display:none;\"> %s </xmp><script src=\"http://ndossougbe.github.io/strapdown/dist/strapdown.js\"></script></html>"
(buffer-substring-no-properties (point-min) (point-max))))
(current-buffer)))
(provide 'markdown-config)
;;; markdown-config.el ends here
|