org-element: Be stricter when matching arguments in LaTeX environments
* lisp/org-element.el (org-element--current-element): Be stricter when matching arguments in LaTeX environments. In particular, do not allow anything else than options and arguments in the opening line. * testing/lisp/test-org-element.el: Add tests.
This commit is contained in:
parent
a8d0e76b7d
commit
7d37898371
|
@ -3775,7 +3775,8 @@ element it has to parse."
|
||||||
(goto-char (car affiliated))
|
(goto-char (car affiliated))
|
||||||
(org-element-keyword-parser limit nil))
|
(org-element-keyword-parser limit nil))
|
||||||
;; LaTeX Environment.
|
;; LaTeX Environment.
|
||||||
((looking-at "[ \t]*\\\\begin{\\([A-Za-z0-9*]+\\)}")
|
((looking-at
|
||||||
|
"[ \t]*\\\\begin{[A-Za-z0-9*]+}\\(\\[.*?\\]\\|{.*?}\\)*[ \t]*$")
|
||||||
(org-element-latex-environment-parser limit affiliated))
|
(org-element-latex-environment-parser limit affiliated))
|
||||||
;; Drawer and Property Drawer.
|
;; Drawer and Property Drawer.
|
||||||
((looking-at org-drawer-regexp)
|
((looking-at org-drawer-regexp)
|
||||||
|
|
|
@ -1136,11 +1136,19 @@ e^{i\\pi}+1=0
|
||||||
:value
|
:value
|
||||||
(org-element-map
|
(org-element-map
|
||||||
(org-element-parse-buffer) 'latex-environment 'identity nil t)))))
|
(org-element-parse-buffer) 'latex-environment 'identity nil t)))))
|
||||||
;; Allow environments with options.
|
;; Allow environments with options and arguments.
|
||||||
(should
|
(should
|
||||||
(eq 'latex-environment
|
(eq 'latex-environment
|
||||||
(org-test-with-temp-text
|
(org-test-with-temp-text
|
||||||
"\\begin{theorem}[Euler]\ne^{i\\pi}+1=0\n\\end{theorem}"
|
"\\begin{theorem}[Euler]\ne^{i\\pi}+1=0\n\\end{theorem}"
|
||||||
|
(org-element-type (org-element-at-point)))))
|
||||||
|
(should
|
||||||
|
(eq 'latex-environment
|
||||||
|
(org-test-with-temp-text "\\begin{env}{arg}\nvalue\n\\end{env}"
|
||||||
|
(org-element-type (org-element-at-point)))))
|
||||||
|
(should-not
|
||||||
|
(eq 'latex-environment
|
||||||
|
(org-test-with-temp-text "\\begin{env}{arg} something\nvalue\n\\end{env}"
|
||||||
(org-element-type (org-element-at-point))))))
|
(org-element-type (org-element-at-point))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue