From: "Sébastien Miquel" <sebastien.miquel@posteo.eu> To: emacs-orgmode <emacs-orgmode@gnu.org> Cc: "Rudolf Adamkovič" <salutis@me.com> Subject: [PATCH] Add support for $…$ latex fragments followed by a dash Date: Mon, 24 Jan 2022 16:42:35 +0000 [thread overview] Message-ID: <f0597d96-a287-2c48-7897-6b8737c95217@posteo.eu> (raw) [-- Attachment #1: Type: text/plain, Size: 380 bytes --] Hi, The attached patch adds support for $…$ latex fragments followed by a dash, such as $n$-th. This pattern is quite common, and the issue was mentionned by Rudolf Adamkovič, here: https://list.orgmode.org/m2mtjvefrf.fsf@me.com/. This extension of the syntax doesn't conflict with the use of $'s in table formulas, or for currency, AFAICT. Regards, -- Sébastien Miquel [-- Attachment #2: 0001-org-element-Support-LaTeX-fragments-followed-by-a-da.patch --] [-- Type: text/x-patch, Size: 3159 bytes --] From b023fff129a5cc3b1f12b9f170f2e018dc34d237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu> Date: Sun, 23 Jan 2022 13:28:03 +0100 Subject: [PATCH] =?UTF-8?q?org-element:=20Support=20$=E2=80=A6$=20LaTeX=20?= =?UTF-8?q?fragments=20followed=20by=20a=20dash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/org-element.el (org-element-latex-fragment-parser): * lisp/org.el (org-latex-regexps): Allow a dash right after a $…$ fragment. * testing/lisp/test-org-element.el (test-org-element/latex-fragment-parser): Add test. Allows such uses as `$n$-th' or `$n$-dimensional'. --- lisp/org-element.el | 2 +- lisp/org.el | 4 ++-- testing/lisp/test-org-element.el | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index b82475a14..40a604578 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3416,7 +3416,7 @@ Assume point is at the beginning of the LaTeX fragment." (not (memq (char-before (match-beginning 0)) '(?\s ?\t ?\n ?, ?.))) (looking-at-p - "\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)") + "\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|-\\|$\\)") (point))))) (post-blank (if (not after-fragment) (throw 'no-object nil) diff --git a/lisp/org.el b/lisp/org.el index 2d439cd05..3a164ee77 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -629,8 +629,8 @@ An entry can be toggled between COMMENT and normal with '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t) ;; ("$" "\\([ \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 - ("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\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) + ("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\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)) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 6d7376a96..2055e3a7b 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -1776,6 +1776,10 @@ e^{i\\pi}+1=0 (eq 'latex-fragment (org-test-with-temp-text "$a$'" (org-element-type (org-element-context))))) + (should + (eq 'latex-fragment + (org-test-with-temp-text "$a$-" + (org-element-type (org-element-context))))) ;; Test forbidden characters inside $...$. (should-not (eq 'latex-fragment -- 2.34.1
next reply other threads:[~2022-01-24 16:43 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-24 16:42 Sébastien Miquel [this message] 2022-01-25 7:56 ` Eric S Fraga 2022-01-25 10:32 ` Sébastien Miquel 2022-01-26 17:15 ` Rudolf Adamkovič 2022-01-27 8:28 ` Ihor Radchenko 2022-01-27 19:15 ` Tim Cross 2022-01-28 14:37 ` Max Nikulin 2022-01-28 16:37 ` Timothy 2022-01-30 15:28 ` Max Nikulin 2022-02-01 14:26 ` Max Nikulin 2022-01-27 19:34 ` Sébastien Miquel 2022-02-01 21:00 ` Rudolf Adamkovič 2022-02-02 2:48 ` João Pedro de Amorim Paula 2022-02-06 19:45 ` Rudolf Adamkovič 2022-02-07 0:00 ` Tim Cross 2022-01-26 6:33 ` Tom Gillespie 2022-01-26 17:49 ` Sébastien Miquel 2022-01-26 21:49 ` Tom Gillespie 2022-01-27 19:11 ` Sébastien Miquel 2022-01-25 18:09 Goran Zuzic 2022-01-27 18:54 autofrettage
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 List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=f0597d96-a287-2c48-7897-6b8737c95217@posteo.eu \ --to=sebastien.miquel@posteo.eu \ --cc=emacs-orgmode@gnu.org \ --cc=salutis@me.com \ --subject='Re: [PATCH] Add support for $…$ latex fragments followed by a dash' \ /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
Code repositories for project(s) associated with this 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).