Merge branch 'maint'
This commit is contained in:
commit
df0c345eac
|
@ -2982,16 +2982,8 @@ Assume point is at the beginning of the LaTeX fragment."
|
|||
(save-excursion
|
||||
(let* ((begin (point))
|
||||
(after-fragment
|
||||
(if (eq (char-after) ?$)
|
||||
(if (eq (char-after (1+ (point))) ?$)
|
||||
(search-forward "$$" nil t 2)
|
||||
(and (not (eq (char-before) ?$))
|
||||
(search-forward "$" nil t 2)
|
||||
(not (memq (char-before (match-beginning 0))
|
||||
'(?\s ?\t ?\n ?, ?.)))
|
||||
(looking-at-p
|
||||
"\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)")
|
||||
(point)))
|
||||
(cond
|
||||
((not (eq ?$ (char-after)))
|
||||
(pcase (char-after (1+ (point)))
|
||||
(?\( (search-forward "\\)" nil t))
|
||||
(?\[ (search-forward "\\]" nil t))
|
||||
|
@ -2999,8 +2991,21 @@ Assume point is at the beginning of the LaTeX fragment."
|
|||
;; Macro.
|
||||
(and (looking-at "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\
|
||||
\\|\\({[^{}\n]*}\\)\\)*")
|
||||
(match-end 0))))))
|
||||
(post-blank (if (not after-fragment) (throw 'no-object nil)
|
||||
(match-end 0)))))
|
||||
((eq ?$ (char-after (1+ (point))))
|
||||
(search-forward "$$" nil t 2))
|
||||
(t
|
||||
(and (not (eq ?$ (char-before)))
|
||||
(not (memq (char-after (1+ (point)))
|
||||
'(?\s ?\t ?\n ?, ?. ?\;)))
|
||||
(search-forward "$" nil t 2)
|
||||
(not (memq (char-before (match-beginning 0))
|
||||
'(?\s ?\t ?\n ?, ?.)))
|
||||
(looking-at-p
|
||||
"\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)")
|
||||
(point)))))
|
||||
(post-blank
|
||||
(if (not after-fragment) (throw 'no-object nil)
|
||||
(goto-char after-fragment)
|
||||
(skip-chars-forward " \t")))
|
||||
(end (point)))
|
||||
|
|
|
@ -1548,10 +1548,16 @@ e^{i\\pi}+1=0
|
|||
|
||||
(ert-deftest test-org-element/latex-fragment-parser ()
|
||||
"Test `latex-fragment' parser."
|
||||
;; Basic $...$ test.
|
||||
(should
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$a$"
|
||||
(org-element-type (org-element-context)))))
|
||||
;; Test valid characters after $...$ construct.
|
||||
(should-not
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$a$a"
|
||||
(org-element-type (org-element-context)))))
|
||||
(should
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$a$!"
|
||||
|
@ -1576,18 +1582,46 @@ e^{i\\pi}+1=0
|
|||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$a$'"
|
||||
(org-element-type (org-element-context)))))
|
||||
;; Test forbidden characters inside $...$.
|
||||
(should-not
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$a$a"
|
||||
(org-test-with-temp-text "$.a$"
|
||||
(org-element-type (org-element-context)))))
|
||||
(should-not
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$,a$"
|
||||
(org-element-type (org-element-context)))))
|
||||
(should-not
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$;a$"
|
||||
(org-element-type (org-element-context)))))
|
||||
(should-not
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$ a$"
|
||||
(org-element-type (org-element-context)))))
|
||||
(should-not
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$a.$"
|
||||
(org-element-type (org-element-context)))))
|
||||
(should-not
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$a,$"
|
||||
(org-element-type (org-element-context)))))
|
||||
(should-not
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$a $"
|
||||
(org-element-type (org-element-context)))))
|
||||
;; Test $$...$$.
|
||||
(should
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "$$a$$"
|
||||
(org-element-type (org-element-context)))))
|
||||
;; Test \(...\).
|
||||
(should
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "\\(a\\)"
|
||||
(org-element-type (org-element-context)))))
|
||||
;; Test \[...\].
|
||||
(should
|
||||
(eq 'latex-fragment
|
||||
(org-test-with-temp-text "\\[a\\]"
|
||||
|
|
Loading…
Reference in New Issue