Prioritize underline over subscript 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.
* etc/ORG-NEWS (Underline syntax now takes priority over subscript
when both are applicable): Announce the breaking change.

Reported-by: Juan Manuel Macías <maciaschain@posteo.net>
Link: https://list.orgmode.org/87v8z52eom.fsf@posteo.net/T/#t
This commit is contained in:
Ihor Radchenko 2021-12-31 22:39:03 +08:00 committed by Ihor Radchenko
parent a3bcb55365
commit ce5e8ecbb8
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
3 changed files with 25 additions and 5 deletions

View File

@ -13,6 +13,17 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** Important announcements and breaking changes
*** Underline syntax now takes priority over subscript when both are applicable
Previously, Org mode interpreted =(_text_)= as subscript.
Now, the interpretation is changed to underline.
=(_text_)= matches both subscript and underline markup. The
interpretation is changed to keep consistency with other emphasis like
=(*bold*)=.
Most of the users should not be affected by this change - it only applies when character immediately preceding =_= is one of =-=, =(=, ='=, and ={=.
*** ~org-latex-to-mathml-convert-command~ and ~org-latex-to-html-convert-command~ may need to be adjusted
Previously, =%i= placeholders in the

View File

@ -5258,10 +5258,10 @@ to an appropriate container (e.g., a paragraph)."
(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)

View File

@ -3306,7 +3306,16 @@ Outside list"
(= 2
(org-test-with-temp-text "__test__"
(length
(org-element-map (org-element-parse-buffer) 'underline 'identity))))))
(org-element-map (org-element-parse-buffer) 'underline 'identity)))))
;; 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