org-element: Fix $...$ fragments followed by an apostrophe
* lisp/org-element.el (org-element-latex-fragment-parser): * lisp/org.el (org-latex-regexps): Allow an apostrophe right after a fragment. * testing/lisp/test-org-element.el (test-org-element/latex-fragment-parser): Add test. In Text mode, and, as a consequence, in Org mode, "'" is not treated as punctuation, but as word constituent. The apostrophe isn't caught by "\s." regexp. Reported-by: Joe Corneli <holtzermann17@gmail.com> <http://permalink.gmane.org/gmane.emacs.orgmode/113464>
This commit is contained in:
parent
0255538701
commit
c0369a7984
|
@ -3040,7 +3040,8 @@ Assume point is at the beginning of the LaTeX fragment."
|
||||||
(search-forward "$" nil t 2)
|
(search-forward "$" nil t 2)
|
||||||
(not (memq (char-before (match-beginning 0))
|
(not (memq (char-before (match-beginning 0))
|
||||||
'(?\s ?\t ?\n ?, ?.)))
|
'(?\s ?\t ?\n ?, ?.)))
|
||||||
(looking-at "\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|$\\)")
|
(looking-at-p
|
||||||
|
"\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)")
|
||||||
(point)))
|
(point)))
|
||||||
(pcase (char-after (1+ (point)))
|
(pcase (char-after (1+ (point)))
|
||||||
(?\( (search-forward "\\)" nil t))
|
(?\( (search-forward "\\)" nil t))
|
||||||
|
|
|
@ -535,10 +535,10 @@ An entry can be toggled between COMMENT and normal with
|
||||||
|
|
||||||
(defconst org-latex-regexps
|
(defconst org-latex-regexps
|
||||||
'(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
|
'(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
|
||||||
;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([ .,?;:'\")]\\|$\\)" 2 nil)
|
;; ("$" "\\([ \t(]\\|^\\)\\(\\(\\([$]\\)\\([^ \t\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \t\n,.$]\\)\\4\\)\\)\\([ \t.,?;:'\")]\\|$\\)" 2 nil)
|
||||||
;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
|
;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
|
||||||
("$1" "\\([^$]\\|^\\)\\(\\$[^ \r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|$\\)" 2 nil)
|
("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil)
|
||||||
("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \r\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|$\\)" 2 nil)
|
("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ \t\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \t\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil)
|
||||||
("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
|
("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
|
||||||
("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
|
("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
|
||||||
("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
|
("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
|
||||||
|
|
|
@ -1558,6 +1558,10 @@ e^{i\\pi}+1=0
|
||||||
(eq 'latex-fragment
|
(eq 'latex-fragment
|
||||||
(org-test-with-temp-text "$a$ "
|
(org-test-with-temp-text "$a$ "
|
||||||
(org-element-type (org-element-context)))))
|
(org-element-type (org-element-context)))))
|
||||||
|
(should
|
||||||
|
(eq 'latex-fragment
|
||||||
|
(org-test-with-temp-text "$a$'"
|
||||||
|
(org-element-type (org-element-context)))))
|
||||||
(should-not
|
(should-not
|
||||||
(eq 'latex-fragment
|
(eq 'latex-fragment
|
||||||
(org-test-with-temp-text "$a$a"
|
(org-test-with-temp-text "$a$a"
|
||||||
|
|
Loading…
Reference in New Issue