diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index b71347145..a3015d9fc 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -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 diff --git a/lisp/org-element.el b/lisp/org-element.el index 5857bc63a..f4eec1695 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -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) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index e309ed97f..c49dc80d1 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -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 "(_underline_)" + (org-element-type (org-element-context))))) + (should-not + (eq 'underline + (org-test-with-temp-text "x_underline_)" + (org-element-type (org-element-context)))))) ;;;; Verbatim