diff --git a/modules/lang/markdown/autoload.el b/modules/lang/markdown/autoload.el index c0445c35e..1ae173fc1 100644 --- a/modules/lang/markdown/autoload.el +++ b/modules/lang/markdown/autoload.el @@ -1,26 +1,5 @@ ;;; lang/markdown/autoload.el -*- lexical-binding: t; -*- -;; Implement strike-through formatting -(defvar +markdown--regex-del - "\\(^\\|[^\\]\\)\\(\\(~\\{2\\}\\)\\([^ \n \\]\\|[^ \n ]\\(?:.\\|\n[^\n]\\)*?[^\\ ]\\)\\(\\3\\)\\)") - -;;;###autoload -(defun +markdown/insert-del () - "Surround region in github strike-through delimiters." - (interactive) - (let ((delim "~~")) - (if (markdown-use-region-p) - ;; Active region - (cl-destructuring-bind (beg . end) - (markdown-unwrap-things-in-region - (region-beginning) (region-end) - +markdown--regex-del 2 4) - (markdown-wrap-or-insert delim delim nil beg end)) - ;; Bold markup removal, bold word at point, or empty markup insertion - (if (thing-at-point-looking-at +markdown--regex-del) - (markdown-unwrap-thing-at-point nil 2 4) - (markdown-wrap-or-insert delim delim 'word nil nil))))) - ;;;###autoload (defun +markdown-flyspell-word-p () "Return t if point is on a word that should be spell checked. @@ -95,3 +74,36 @@ available. Returns its exit code." shell-file-name nil output-buffer nil shell-command-switch exe))) + +;; +;;; Commands + +;;;###autoload +(defun +markdown/insert-del () + "Surround region in github strike-through delimiters." + (interactive) + (let ((regexp "\\(^\\|[^\\]\\)\\(\\(~\\{2\\}\\)\\([^ \n \\]\\|[^ \n ]\\(?:.\\|\n[^\n]\\)*?[^\\ ]\\)\\(\\3\\)\\)") + (delim "~~")) + (if (markdown-use-region-p) + ;; Active region + (cl-destructuring-bind (beg . end) + (markdown-unwrap-things-in-region + (region-beginning) (region-end) + regexp 2 4) + (markdown-wrap-or-insert delim delim nil beg end)) + ;; Bold markup removal, bold word at point, or empty markup insertion + (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))))