* [PATCH] better parsing of latex fragments
@ 2014-07-13 14:03 Florian Beck
2014-07-16 20:08 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: Florian Beck @ 2014-07-13 14:03 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 135 bytes --]
Hi,
this patch allows, once again, latex fragments inside parentheses and
also fragments like $\left(\frac12\right.$
--
Florian Beck
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-latex-fragments-inside-parenthesis-and-ending.patch --]
[-- Type: text/x-diff, Size: 1855 bytes --]
From 3ef8041c8dd8acbdf810f72feb8e9e104545badb Mon Sep 17 00:00:00 2001
From: Florian Beck <fb@miszellen.de>
Date: Sun, 13 Jul 2014 14:59:24 +0200
Subject: [PATCH] Allow latex fragments inside parentheses and those ending with
punctuation.
* lisp/org-element.el:
(org-element-latex-fragment-parser): more lenient regexps
*
testing/lisp/test-org-element.el (test-org-element/latex-fragment-parser): add tests
---
lisp/org-element.el | 4 ++--
testing/lisp/test-org-element.el | 8 ++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 7aa8208..7d10d61 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -2918,8 +2918,8 @@ Assume point is at the beginning of the LaTeX fragment."
(and (not (eq (char-before) ?$))
(search-forward "$" nil t 2)
(not (memq (char-before (match-beginning 0))
- '(?\s ?\t ?\n ?, ?.)))
- (looking-at "\\([- \t.,?;:'\"]\\|$\\)")
+ '(?\s ?\t ?\n)))
+ (looking-at "\\([[:space:][:punct:]]\\|$\\)")
(point)))
(case (char-after (1+ (point)))
(?\( (search-forward "\\)" nil t))
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index b2b0c52..788f13b 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1337,6 +1337,14 @@ e^{i\\pi}+1=0
(org-test-with-temp-text "\\[a\\]"
(org-element-map
(org-element-parse-buffer) 'latex-fragment 'identity)))
+ (should
+ (org-test-with-temp-text "($a$)"
+ (org-element-map
+ (org-element-parse-buffer) 'latex-fragment 'identity)))
+ (should
+ (org-test-with-temp-text "$\\left(a\right.$"
+ (org-element-map
+ (org-element-parse-buffer) 'latex-fragment 'identity)))
;; Test fragment at the beginning of an item.
(should
(eq 'latex-fragment
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] better parsing of latex fragments
2014-07-13 14:03 [PATCH] better parsing of latex fragments Florian Beck
@ 2014-07-16 20:08 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2014-07-16 20:08 UTC (permalink / raw)
To: Florian Beck; +Cc: emacs-orgmode
Hello,
Florian Beck <fb@fbeck.net> writes:
> this patch allows, once again, latex fragments inside parentheses and
> also fragments like $\left(\frac12\right.$
AFAIR, this syntax wasn't valid before. This limitation is due to the
fact that $ is also a currency.
In doubt, use \(...\).
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-16 20:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-13 14:03 [PATCH] better parsing of latex fragments Florian Beck
2014-07-16 20:08 ` Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).