From a6e0578a86b3713965db1ce45e4fe590321fa756 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Tue, 18 Jan 2022 22:42:55 +0100 Subject: Update markdown-mode --- .emacs.d/lisp/markdown-mode.el | 59 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index a4d08fd..009eed3 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el @@ -995,7 +995,7 @@ Compatible with Pandoc, Python Markdown, PHP Markdown Extra, and Leanpub.") "Regular expression for Leanpub section markers and related syntax.") (defconst markdown-regex-sub-superscript - "\\(?:^\\|[^\\~^]\\)\\(?1:\\(?2:[~^]\\)\\(?3:[[:alnum:]]+\\)\\(?4:\\2\\)\\)" + "\\(?:^\\|[^\\~^]\\)\\(?1:\\(?2:[~^]\\)\\(?3:[+-\u2212]?[[:alnum:]]+\\)\\(?4:\\2\\)\\)" "The regular expression matching a sub- or superscript. The leading un-numbered group matches the character before the opening tilde or carat, if any, ensuring that it is not a @@ -2970,7 +2970,8 @@ $..$ or `markdown-regex-math-inline-double' for matching $$..$$." (defun markdown-match-math-double (last) "Match double quoted $$..$$ math from point to LAST." (when markdown-enable-math - (when (and (char-equal (char-after) ?$) + (when (and (< (1+ (point)) (point-max)) + (char-equal (char-after) ?$) (char-equal (char-after (1+ (point))) ?$) (not (bolp)) (not (char-equal (char-before) ?\\)) @@ -3383,7 +3384,7 @@ SEQ may be an atom or a sequence." (margin-char-width (/ margin-pixel-width (default-font-width)))) (set-window-margins nil margin-char-width)) ;; As a fallback, simply set margin based on character count. - (set-window-margins nil markdown-marginalize-headers-margin-width))) + (set-window-margins nil (1+ markdown-marginalize-headers-margin-width)))) (defun markdown-fontify-headings (last) "Add text properties to headings from point to LAST." @@ -3425,11 +3426,11 @@ SEQ may be an atom or a sequence." t)) (defun markdown-fontify-tables (last) - (when (and (re-search-forward "|" last t) - (markdown-table-at-point-p)) - (font-lock-append-text-property - (line-beginning-position) (min (1+ (line-end-position)) (point-max)) - 'face 'markdown-table-face) + (when (re-search-forward "|" last t) + (when (markdown-table-at-point-p) + (font-lock-append-text-property + (line-beginning-position) (min (1+ (line-end-position)) (point-max)) + 'face 'markdown-table-face)) (forward-line 1) t)) @@ -3449,27 +3450,27 @@ SEQ may be an atom or a sequence." (defun markdown-fontify-list-items (last) "Apply font-lock properties to list markers from point to LAST." - (when (and (markdown-match-list-items last) - (not (markdown-code-block-at-point-p (match-beginning 2)))) - (let* ((indent (length (match-string-no-properties 1))) - (level (/ indent markdown-list-indent-width)) ;; level = 0, 1, 2, ... - (bullet (nth (mod level (length markdown-list-item-bullets)) - markdown-list-item-bullets))) - (add-text-properties - (match-beginning 2) (match-end 2) '(face markdown-list-face)) - (when markdown-hide-markup - (cond - ;; Unordered lists - ((string-match-p "[\\*\\+-]" (match-string 2)) - (add-text-properties - (match-beginning 2) (match-end 2) `(display ,bullet))) - ;; Definition lists - ((string-equal ":" (match-string 2)) - (let ((display-string - (char-to-string (markdown--first-displayable - markdown-definition-display-char)))) - (add-text-properties (match-beginning 2) (match-end 2) - `(display ,display-string))))))) + (when (markdown-match-list-items last) + (when (not (markdown-code-block-at-point-p (match-beginning 2))) + (let* ((indent (length (match-string-no-properties 1))) + (level (/ indent markdown-list-indent-width)) ;; level = 0, 1, 2, ... + (bullet (nth (mod level (length markdown-list-item-bullets)) + markdown-list-item-bullets))) + (add-text-properties + (match-beginning 2) (match-end 2) '(face markdown-list-face)) + (when markdown-hide-markup + (cond + ;; Unordered lists + ((string-match-p "[\\*\\+-]" (match-string 2)) + (add-text-properties + (match-beginning 2) (match-end 2) `(display ,bullet))) + ;; Definition lists + ((string-equal ":" (match-string 2)) + (let ((display-string + (char-to-string (markdown--first-displayable + markdown-definition-display-char)))) + (add-text-properties (match-beginning 2) (match-end 2) + `(display ,display-string)))))))) t)) (defun markdown-fontify-hrs (last) -- cgit v1.3