Skip to content

Commit edf3f1e

Browse files
authored
Merge pull request #681 from jrblevin/better-super-sub-script
Support plus sign and Unicode minus sign
2 parents 7b374d3 + 8f6974e commit edf3f1e

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
- Auto set `sh-shell` when `markdown-edit-code-block` enter indirect buffer with `sh-mode`
4949
- Add value check and avoid raising the exception at `markdown-edit-code-block` [GH-663][]
5050
- Add NonGNU ELPA badge to README and website
51-
- Support negative exponent in super script [GH-346][]
51+
- Support plus/negative(also Unicode minus sign) exponent in super script [GH-346][]
5252

5353
* Bug fixes:
5454
- Fix issue with `nil` being returned from `markdown-imenu-create-nested-index` [GH-578][]

markdown-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ Compatible with Pandoc, Python Markdown, PHP Markdown Extra, and Leanpub.")
995995
"Regular expression for Leanpub section markers and related syntax.")
996996

997997
(defconst markdown-regex-sub-superscript
998-
"\\(?:^\\|[^\\~^]\\)\\(?1:\\(?2:[~^]\\)\\(?3:[-]?[[:alnum:]]+\\)\\(?4:\\2\\)\\)"
998+
"\\(?:^\\|[^\\~^]\\)\\(?1:\\(?2:[~^]\\)\\(?3:[+-\u2212]?[[:alnum:]]+\\)\\(?4:\\2\\)\\)"
999999
"The regular expression matching a sub- or superscript.
10001000
The leading un-numbered group matches the character before the
10011001
opening tilde or carat, if any, ensuring that it is not a

tests/markdown-test.el

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3337,11 +3337,24 @@ takes precedence)."
33373337
(markdown-test-range-has-face 4 4 'markdown-markup-face) ; First ^
33383338
(markdown-test-range-has-face 5 6 nil) ; 10
33393339
(markdown-test-range-has-face 7 7 'markdown-markup-face)) ; Second ^
3340-
(markdown-test-string "1.0 x 10^-15^"
3340+
(markdown-test-string "1.0 x 10^-15^
3341+
10^+15^"
3342+
;; -
33413343
(markdown-test-range-has-face 1 8 nil)
33423344
(markdown-test-range-has-face 9 9 'markdown-markup-face)
33433345
(markdown-test-range-has-face 10 12 nil)
3344-
(markdown-test-range-has-face 13 13 'markdown-markup-face)))
3346+
(markdown-test-range-has-face 13 13 'markdown-markup-face)
3347+
;; +
3348+
(markdown-test-range-has-face 15 16 nil)
3349+
(markdown-test-range-has-face 17 17 'markdown-markup-face)
3350+
(markdown-test-range-has-face 18 20 nil)
3351+
(markdown-test-range-has-face 21 21 'markdown-markup-face))
3352+
;; Unicode minus sign
3353+
(markdown-test-string "10^−15^" ;; unicode minus sign U+2212
3354+
(search-forward "^")
3355+
(markdown-test-range-has-face (1- (point)) (1- (point)) 'markdown-markup-face)
3356+
(search-forward "^")
3357+
(markdown-test-range-has-face (1- (point)) (1- (point)) 'markdown-markup-face)))
33453358

33463359
(ert-deftest test-markdown-font-lock/hidden-urls-inline ()
33473360
"Test URL hiding and toggling."

0 commit comments

Comments
 (0)