From: Florian Beck <fb@fbeck.net>
To: emacs-orgmode@gnu.org
Subject: [PATCH] better parsing of latex fragments
Date: Sun, 13 Jul 2014 16:03:08 +0200 [thread overview]
Message-ID: <871ttnk27t.fsf@sophokles.streitblatt.de> (raw)
[-- 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
next reply other threads:[~2014-07-14 22:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-13 14:03 Florian Beck [this message]
2014-07-16 20:08 ` [PATCH] better parsing of latex fragments Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871ttnk27t.fsf@sophokles.streitblatt.de \
--to=fb@fbeck.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.