diff --git a/CHANGES.md b/CHANGES.md index 69bc1cbc..a758f211 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,11 @@ *Under development* +* Bug fixes: + - Don't highlight superscript/subscript in math inline/block [GH-802][] + + [gh-802]: https://github.com/jrblevin/markdown-mode/issues/802 + # Markdown Mode 2.6 * **Breaking changes:** diff --git a/markdown-mode.el b/markdown-mode.el index 0cf1b545..f549870b 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -1140,6 +1140,10 @@ If POS is not given, use point instead." thereis (memq face faces)) (memq face-prop faces)))) +(defsubst markdown--math-block-p (&optional pos) + (when markdown-enable-math + (markdown--face-p (or pos (point)) '(markdown-math-face)))) + (defun markdown-syntax-propertize-extend-region (start end) "Extend START to END region to include an entire block of text. This helps improve syntax analysis for block constructs. @@ -3588,7 +3592,8 @@ SEQ may be an atom or a sequence." (when (markdown-search-until-condition (lambda () (and (not (markdown-code-block-at-point-p)) (not (markdown-inline-code-at-point-p)) - (not (markdown-in-comment-p)))) + (not (markdown-in-comment-p)) + (not (markdown--math-block-p)))) markdown-regex-sub-superscript last t) (let* ((subscript-p (string= (match-string 2) "~")) (props diff --git a/tests/markdown-test.el b/tests/markdown-test.el index c8213d82..29f18c33 100644 --- a/tests/markdown-test.el +++ b/tests/markdown-test.el @@ -6183,6 +6183,18 @@ Detail: https://github.com/jrblevin/markdown-mode/issues/352" (markdown-test-range-has-face 9 9 'markdown-math-face) (markdown-test-range-has-face 10 11 'markdown-markup-face)))) +(ert-deftest test-markdown-math/caret-in-math-inline () + "Test for carets in math inline. +Details: https://github.com/jrblevin/markdown-mode/issues/802" + (let ((markdown-enable-math t)) + (markdown-test-string "$a^b^c$" + (markdown-test-range-has-face 3 3 'markdown-math-face) + (markdown-test-range-has-face 5 5 'markdown-math-face)) + + (markdown-test-string "$$a^b^c$$" + (markdown-test-range-has-face 4 4 'markdown-math-face) + (markdown-test-range-has-face 6 6 'markdown-math-face)))) + (ert-deftest test-markdown-math/math-inline-small-buffer () "Test that font-lock parsing works with a single dollar." (let ((markdown-enable-math t))