summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2026-03-02 05:49:35 +0100
committerSimeon Simeonov2026-03-02 05:49:35 +0100
commit5ae7014a54984c194f103d406f9fbdbafb277885 (patch)
treee328b0c2ce2379547b79101ba4aed64a1bc04ebd
parentaaac90c9b05e490660176dc6109b9e58c3bbe3c1 (diff)
Upgrade markdown-mode
-rw-r--r--.emacs.d/lisp/markdown-mode.el27
1 files changed, 17 insertions, 10 deletions
diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el
index ddeaf7b..160975c 100644
--- a/.emacs.d/lisp/markdown-mode.el
+++ b/.emacs.d/lisp/markdown-mode.el
@@ -847,9 +847,9 @@ Groups 1 and 3 match the opening and closing tags.
847Group 2 matches the key sequence.") 847Group 2 matches the key sequence.")
848 848
849(defconst markdown-regex-gfm-code-block-open 849(defconst markdown-regex-gfm-code-block-open
850 "^[[:blank:]]*\\(?1:```\\)\\(?2:[[:blank:]]*{?[[:blank:]]*\\)\\(?3:[^`[:space:]]+?\\)?\\(?:[[:blank:]]+\\(?4:.+?\\)\\)?\\(?5:[[:blank:]]*}?[[:blank:]]*\\)$" 850 "^[[:blank:]]*\\(?1:`\\{3,\\}\\)\\(?2:[[:blank:]]*{?[[:blank:]]*\\)\\(?3:[^`[:space:]]+?\\)?\\(?:[[:blank:]]+\\(?4:.+?\\)\\)?\\(?5:[[:blank:]]*}?[[:blank:]]*\\)$"
851 "Regular expression matching opening of GFM code blocks. 851 "Regular expression matching opening of GFM code blocks.
852Group 1 matches the opening three backquotes and any following whitespace. 852Group 1 matches the opening three or more backquotes.
853Group 2 matches the opening brace (optional) and surrounding whitespace. 853Group 2 matches the opening brace (optional) and surrounding whitespace.
854Group 3 matches the language identifier (optional). 854Group 3 matches the language identifier (optional).
855Group 4 matches the info string (optional). 855Group 4 matches the info string (optional).
@@ -857,9 +857,9 @@ Group 5 matches the closing brace (optional), whitespace, and newline.
857Groups need to agree with `markdown-regex-tilde-fence-begin'.") 857Groups need to agree with `markdown-regex-tilde-fence-begin'.")
858 858
859(defconst markdown-regex-gfm-code-block-close 859(defconst markdown-regex-gfm-code-block-close
860 "^[[:blank:]]*\\(?1:```\\)\\(?2:\\s *?\\)$" 860 "^[[:blank:]]*\\(?1:`\\{3,\\}\\)\\(?2:\\s *?\\)$"
861 "Regular expression matching closing of GFM code blocks. 861 "Regular expression matching closing of GFM code blocks.
862Group 1 matches the closing three backquotes. 862Group 1 matches the closing three or more backquotes.
863Group 2 matches any whitespace and the final newline.") 863Group 2 matches any whitespace and the final newline.")
864 864
865(defconst markdown-regex-pre 865(defconst markdown-regex-pre
@@ -1008,6 +1008,13 @@ Group 3 matches the mathematical expression contained within.
1008Group 2 matches the opening slashes, and is used internally to 1008Group 2 matches the opening slashes, and is used internally to
1009match the closing slashes.") 1009match the closing slashes.")
1010 1010
1011(defsubst markdown-make-gfm-fence-regex (num-backticks &optional end-of-line)
1012 "Return regexp matching a GFM code fence at least NUM-BACKTICKS long.
1013END-OF-LINE is the regexp construct to indicate end of line; $ if
1014missing."
1015 (format "%s%d%s%s" "^[[:blank:]]*\\([`]\\{" num-backticks ",\\}\\)"
1016 (or end-of-line "$")))
1017
1011(defsubst markdown-make-tilde-fence-regex (num-tildes &optional end-of-line) 1018(defsubst markdown-make-tilde-fence-regex (num-tildes &optional end-of-line)
1012 "Return regexp matching a tilde code fence at least NUM-TILDES long. 1019 "Return regexp matching a tilde code fence at least NUM-TILDES long.
1013END-OF-LINE is the regexp construct to indicate end of line; $ if 1020END-OF-LINE is the regexp construct to indicate end of line; $ if
@@ -1421,7 +1428,7 @@ giving the bounds of the current and parent list items."
1421 (markdown-get-yaml-metadata-end-border markdown-yaml-metadata-end) 1428 (markdown-get-yaml-metadata-end-border markdown-yaml-metadata-end)
1422 markdown-yaml-metadata-section) 1429 markdown-yaml-metadata-section)
1423 ((,markdown-regex-gfm-code-block-open markdown-gfm-block-begin) 1430 ((,markdown-regex-gfm-code-block-open markdown-gfm-block-begin)
1424 (,markdown-regex-gfm-code-block-close markdown-gfm-block-end) 1431 (markdown-make-gfm-fence-regex markdown-gfm-block-end)
1425 markdown-gfm-code)) 1432 markdown-gfm-code))
1426 "Mapping of regular expressions to \"fenced-block\" constructs. 1433 "Mapping of regular expressions to \"fenced-block\" constructs.
1427These constructs are distinguished by having a distinctive start 1434These constructs are distinguished by having a distinctive start
@@ -1687,12 +1694,12 @@ MIDDLE-BEGIN is the start of the \"middle\" section of the block."
1687 (put-text-property close-begin close-end 1694 (put-text-property close-begin close-end
1688 (cl-cadadr fence-spec) close-data)))) 1695 (cl-cadadr fence-spec) close-data))))
1689 1696
1690(defun markdown--triple-quote-single-line-p (begin) 1697(defun markdown--code-fence-single-line-p (begin)
1691 (save-excursion 1698 (save-excursion
1692 (goto-char begin) 1699 (goto-char begin)
1693 (save-match-data 1700 (save-match-data
1694 (and (search-forward "```" nil t) 1701 (and (re-search-forward "`\\{3,\\}" nil t)
1695 (search-forward "```" (line-end-position) t))))) 1702 (re-search-forward "`\\{3,\\}" (line-end-position) t)))))
1696 1703
1697(defun markdown-syntax-propertize-fenced-block-constructs (start end) 1704(defun markdown-syntax-propertize-fenced-block-constructs (start end)
1698 "Propertize according to `markdown-fenced-block-pairs' from START to END. 1705 "Propertize according to `markdown-fenced-block-pairs' from START to END.
@@ -1749,7 +1756,7 @@ start which was previously propertized."
1749 0))) 1756 0)))
1750 (prop (cl-cadar correct-entry))) 1757 (prop (cl-cadar correct-entry)))
1751 (when (or (not (eq prop 'markdown-gfm-block-begin)) 1758 (when (or (not (eq prop 'markdown-gfm-block-begin))
1752 (not (markdown--triple-quote-single-line-p block-start))) 1759 (not (markdown--code-fence-single-line-p block-start)))
1753 ;; get correct match data 1760 ;; get correct match data
1754 (save-excursion 1761 (save-excursion
1755 (beginning-of-line) 1762 (beginning-of-line)
@@ -10551,7 +10558,7 @@ rows and columns and the column alignment."
10551 10558
10552;;;###autoload 10559;;;###autoload
10553(add-to-list 'auto-mode-alist 10560(add-to-list 'auto-mode-alist
10554 '("\\.\\(?:md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)\\'" . markdown-mode)) 10561 '("\\.\\(?:md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\|mdx\\)\\'" . markdown-mode))
10555 10562
10556 10563
10557;;; GitHub Flavored Markdown Mode ============================================ 10564;;; GitHub Flavored Markdown Mode ============================================