Skip to content

Commit

Permalink
Merge pull request #168 from kleinschmidt/dfk/display-math-regex
Browse files Browse the repository at this point in the history
use non-greedy *? for display math content
  • Loading branch information
syohex authored Sep 28, 2016
2 parents e89c377 + e49d6c0 commit c81e26f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ Groups 1 and 3 match opening and closing dollar signs.
Group 3 matches the mathematical expression contained within.")

(defconst markdown-regex-math-display
"^\\(\\\\\\[\\)\\(\\(?:.\\|\n\\)*\\)?\\(\\\\\\]\\)$"
"^\\(\\\\\\[\\)\\(\\(?:.\\|\n\\)*?\\)?\\(\\\\\\]\\)$"
"Regular expression for itex \[..\] display mode expressions.
Groups 1 and 3 match the opening and closing delimiters.
Group 2 matches the mathematical expression contained within.")
Expand Down Expand Up @@ -6476,9 +6476,9 @@ This is an exact copy of `line-number-at-pos' for use in emacs21."
;; Update font lock keywords with extensions
(setq markdown-mode-font-lock-keywords
(append
(markdown-mode-font-lock-keywords-math)
markdown-mode-font-lock-keywords-basic
(markdown-mode-font-lock-keywords-wiki-links)
(markdown-mode-font-lock-keywords-math)))
(markdown-mode-font-lock-keywords-wiki-links)))
;; Update font lock defaults
(setq font-lock-defaults
'(markdown-mode-font-lock-keywords
Expand Down
9 changes: 8 additions & 1 deletion tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -3745,7 +3745,14 @@ this is not header line
(markdown-test-range-has-face 212 215 markdown-markup-face)
(markdown-test-range-has-face 218 218 markdown-markup-face)
(markdown-test-range-has-face 219 223 markdown-math-face)
(markdown-test-range-has-face 224 224 markdown-markup-face)))
(markdown-test-range-has-face 224 224 markdown-markup-face)
(markdown-test-range-has-face 350 351 markdown-markup-face)
(markdown-test-range-has-face 352 356 markdown-math-face)
(markdown-test-range-has-face 357 358 markdown-markup-face)
(markdown-test-range-has-face 359 391 nil)
(markdown-test-range-has-face 392 393 markdown-markup-face)
(markdown-test-range-has-face 394 398 markdown-math-face)
(markdown-test-range-has-face 399 400 markdown-markup-face)))

(ert-deftest test-markdown-math/font-lock-italics ()
"Test markdown math mode with underscores."
Expand Down
4 changes: 4 additions & 0 deletions tests/math.text
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ $e_{ik}$ in the statement the theorem about $V_k$

$**η = (-1)^{k(n-k)}sη$, where $**η$, is the Hodge star applied twice.

\[ a_1 \]
This is neither math nor italic
\[ a_2 \]

<!-- Local Variables: -->
<!-- markdown-enable-math: t -->
<!-- End: -->

0 comments on commit c81e26f

Please sign in to comment.