From: Ihor Radchenko <yantar92@gmail.com>
To: "Juan Manuel Macías" <maciaschain@posteo.net>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] Re: [BUG] Underlined text in parentheses is not exported correctly
Date: Fri, 31 Dec 2021 22:43:07 +0800 [thread overview]
Message-ID: <87pmpcygw4.fsf@localhost> (raw)
In-Reply-To: <87v8z52eom.fsf@posteo.net>
[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]
Juan Manuel Macías <maciaschain@posteo.net> writes:
>> The priority appears to be intentional.
>
> I see. But then the compatibility with the rest of the emphasis is
> broken. I mean, the user would expect things like (_underline_) will be
> exported as (\uline{underline}), in the same way that (/emphasis/) is
> exported as (\emph{emphasis}). I would say there is a slight
> inconsistency in the syntax here.
I agree with you. I think that the initial intention was to avoid
parsing things like (x+y)_1+x_2 as underline.
However, thinking about it more, I feel that prioritising underline
should work better. The underline parser recently got changed into a
stricter version. Now, only underlines starting after spaces,-,(,',",
and { are recognised as an underlines.
So, the attached patch is changing the priority of the parsing.
Maybe Nicolas knows some tricky cases when the patch makes things wrong,
but those cases are certainly not covered by tests.
Best,
Ihor
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-underline-parser-inside-parenthesis.patch --]
[-- Type: text/x-diff, Size: 2454 bytes --]
From 12272f1ea89c169dcbece009c3a227e354019366 Mon Sep 17 00:00:00 2001
Message-Id: <12272f1ea89c169dcbece009c3a227e354019366.1640961654.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Fri, 31 Dec 2021 22:39:03 +0800
Subject: [PATCH] Fix underline parser inside parenthesis
* lisp/org-element.el (org-element--object-lex): prioritise underline
parser over subscript. `org-element-underline-parser' is more strict
compared to `org-element-subscript-parser'.
* testing/lisp/test-org-element.el (test-org-element/underline-parser):
Add test.
Fixes https://list.orgmode.org/87v8z52eom.fsf@posteo.net/T/#t
---
lisp/org-element.el | 8 ++++----
testing/lisp/test-org-element.el | 11 ++++++++++-
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 45ddc79b7..c9d1d80bb 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4850,10 +4850,10 @@ (defun org-element--object-lex (restriction)
(pcase (char-after)
(?^ (and (memq 'superscript restriction)
(org-element-superscript-parser)))
- (?_ (or (and (memq 'subscript restriction)
- (org-element-subscript-parser))
- (and (memq 'underline restriction)
- (org-element-underline-parser))))
+ (?_ (or (and (memq 'underline restriction)
+ (org-element-underline-parser))
+ (and (memq 'subscript restriction)
+ (org-element-subscript-parser))))
(?* (and (memq 'bold restriction)
(org-element-bold-parser)))
(?/ (and (memq 'italic restriction)
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 338204eab..b58d71c8c 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -2661,7 +2661,16 @@ (ert-deftest test-org-element/underline-parser ()
(org-test-with-temp-text "_first line\nsecond line_"
(org-element-map
(org-element-parse-buffer) 'underline #'identity nil t)))
- '("first line\nsecond line"))))
+ '("first line\nsecond line")))
+ ;; Starting after non-blank
+ (should
+ (eq 'underline
+ (org-test-with-temp-text "(_under<point>line_)"
+ (org-element-type (org-element-context)))))
+ (should-not
+ (eq 'underline
+ (org-test-with-temp-text "x_under<point>line_)"
+ (org-element-type (org-element-context))))))
;;;; Verbatim
--
2.32.0
next prev parent reply other threads:[~2021-12-31 14:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-31 10:14 [BUG] Underlined text in parentheses is not exported correctly Juan Manuel Macías
2021-12-31 11:08 ` Juan Manuel Macías
2021-12-31 11:13 ` Ihor Radchenko
2021-12-31 11:31 ` Juan Manuel Macías
2021-12-31 14:43 ` Ihor Radchenko [this message]
2022-01-01 11:28 ` [PATCH] " Juan Manuel Macías
2024-04-01 12:34 ` Ihor Radchenko
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=87pmpcygw4.fsf@localhost \
--to=yantar92@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=maciaschain@posteo.net \
/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 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).