diff --git a/modules/lang/markdown/autoload.el b/modules/lang/markdown/autoload.el index 84d5533c8..44d942c33 100644 --- a/modules/lang/markdown/autoload.el +++ b/modules/lang/markdown/autoload.el @@ -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)))) diff --git a/modules/lang/markdown/config.el b/modules/lang/markdown/config.el index db111e2c0..a187d917e 100644 --- a/modules/lang/markdown/config.el +++ b/modules/lang/markdown/config.el @@ -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 - ;; https://github.com/jrblevin/markdown-mode/issues/328. - (advice-add :markdown-match-generic-metadata - :override #'+markdown-disable-front-matter-fontification-a) + ;; 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. + (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