lang/markdown: minor refactor

And remove README.markdown support. What madman uses that extension?
This commit is contained in:
Henrik Lissner 2019-10-18 17:26:13 -04:00
parent 75715e4e93
commit 875225cdd9
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 18 additions and 23 deletions

View file

@ -20,6 +20,10 @@ Return nil if on a link url, markup, html, or references."
if (memq face unsafe-faces)
return t)))))
;;
;;; Compilation handlers
;;;###autoload
(defun +markdown-compile (beg end output-buffer)
"Compile markdown into html.
@ -66,6 +70,7 @@ available. Returns its exit code."
(executable-find "markdown")))
(call-process-region beg end exe nil output-buffer nil)))
;;
;;; Commands
@ -86,15 +91,3 @@ available. Returns its exit code."
(if (thing-at-point-looking-at regexp)
(markdown-unwrap-thing-at-point nil 2 4)
(markdown-wrap-or-insert delim delim 'word nil nil)))))
;;
;;; Advice
;;;###autoload
(defun +markdown-disable-front-matter-fontification-a (&rest _)
"Prevent fontification of YAML metadata blocks in `markdown-mode'.
This prevents a mis-feature wherein if the first line of a Markdown document has
a colon in it, then it's distractingly and usually wrongly fontified as a
metadata block. See https://github.com/jrblevin/markdown-mode/issues/328."
(ignore (goto-char (point-max))))

View file

@ -16,17 +16,18 @@ capture, the end position, and the output buffer.")
;;; Packages
(use-package! markdown-mode
:mode ("/README\\(?:\\.\\(?:markdown\\|md\\)\\)?\\'" . gfm-mode)
:mode ("/README\\(?:\\.md\\)?\\'" . gfm-mode)
:init
(setq markdown-enable-wiki-links t
(setq markdown-enable-math t ; syntax highlighting for latex fragments
markdown-enable-wiki-links t
markdown-italic-underscore t
markdown-asymmetric-header t
markdown-make-gfm-checkboxes-buttons t
markdown-gfm-additional-languages '("sh")
markdown-fontify-code-blocks-natively t
markdown-hide-urls nil ; trigger with `markdown-toggle-url-hiding'
markdown-enable-math t ; syntax highlighting for latex fragments
markdown-gfm-uppercase-checkbox t ; for compat with org-mode
markdown-gfm-additional-languages '("sh")
markdown-make-gfm-checkboxes-buttons t
;; Preview/compilation defaults
markdown-command #'+markdown-compile
markdown-open-command
(cond (IS-MAC "open")
@ -47,11 +48,12 @@ capture, the end position, and the output buffer.")
(set-lookup-handlers! '(markdown-mode gfm-mode)
:file #'markdown-follow-thing-at-point)
;; Prevent mis-fontification of YAML metadata blocks in `markdown-mode' which
;; occurs when the first line contains a colon in it. See
;; HACK Prevent mis-fontification of YAML metadata blocks in `markdown-mode'
;; which occurs when the first line contains a colon in it. See
;; https://github.com/jrblevin/markdown-mode/issues/328.
(advice-add :markdown-match-generic-metadata
:override #'+markdown-disable-front-matter-fontification-a)
(defadvice! +markdown-disable-front-matter-fontification-a (&rest _)
:override #'markdown-match-generic-metadata
(ignore (goto-char (point-max))))
(map! :map markdown-mode-map
:n [tab] #'markdown-cycle