From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yH/vGMsWz2E1fAEAgWs5BA (envelope-from ) for ; Fri, 31 Dec 2021 15:42:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id CINfFcsWz2FKLgAAauVa8A (envelope-from ) for ; Fri, 31 Dec 2021 15:42:19 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A86351C87B for ; Fri, 31 Dec 2021 15:42:18 +0100 (CET) Received: from localhost ([::1]:38376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3J6n-0007oj-Ie for larch@yhetil.org; Fri, 31 Dec 2021 09:42:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3J6N-0007jv-5t for emacs-orgmode@gnu.org; Fri, 31 Dec 2021 09:41:51 -0500 Received: from [2a00:1450:4864:20::231] (port=46770 helo=mail-lj1-x231.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n3J6L-0007wt-Cn for emacs-orgmode@gnu.org; Fri, 31 Dec 2021 09:41:50 -0500 Received: by mail-lj1-x231.google.com with SMTP id i11so32882258ljm.13 for ; Fri, 31 Dec 2021 06:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=uPMbgFd7KZxScU6GC7oMlFIoXtMRJrxhqD2J4rVsnJo=; b=UPw1XNbV2cpm0OzDwenP9AW7bSNfDzHoDwayK5CamKAjFTC++6lI0xFLdtDl+sz+jp YdbGfZqYOjxBmdGtMkCSJrbp0Q4EiAUW1LzqeDuVBje9u3RpBe4wd9O3pnddEpo9NtjZ LfCH6dCtd7bAWbEIWVs7wgawqrHcXeRC2Or3CEkR/cvgXI22wnsm8QKy1FuODo2RErQF XC4chU/7ry1AirldQgOxMiOH5Y96JcPd2JvSYEmHTUzV+9F/a5pySVsBYcJhAtu4Xr3B LxLwKb5YHVhCyXGBZbTajhZfuNtiAgr0mdLSD45JjGE72lVhLxgQqG0vSDcZ/TtR3mar mkDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=uPMbgFd7KZxScU6GC7oMlFIoXtMRJrxhqD2J4rVsnJo=; b=Ayrh461UEVGNriU4kCWAqWEO0EF4AzM4ngz95y+QW3Q4/SP8OFnhUEE7+haMPeUz5b oo2ZJcvj9/l7rnfkUAL2LxywjS3e9bsMe++2q33iCsCdQjqK8zLR83qW/FCnOREQDL7I OW3U1d2pzYXuZWfCAWoQ5FG+dYa4M6v8K0Fi6S2mUEbzB1A8kXmjyNrE8vD6YGsdW1b/ hOAgf/Gps340AkwkVqnL/EJLtl48j2FUxKm+n6Dh0HMCzeuBwbsggMs9QcDxAIPhP2UT VsBWjC5Vg0QGMebmM5uqinsFpSqN2aDJnXrW1dHS5QoUKFhsDqcfahT3kggHU+UikW7K 155A== X-Gm-Message-State: AOAM531zCPtmpEX4N5zLQJVoxiOtZh0NTbuudcFZeCJfthxHjc4ciyUG RwKZETfq8EnHtWr/2B0g+pGkaYn7qQU= X-Google-Smtp-Source: ABdhPJxwaXvDYKN9vVJDuXEKKM3jXJe62UyhDOZdhdcKEedOtXVdoLNIyQ5+bwxtqkwR6+KjP3TX1Q== X-Received: by 2002:a2e:b894:: with SMTP id r20mr30116003ljp.304.1640961707702; Fri, 31 Dec 2021 06:41:47 -0800 (PST) Received: from localhost ([158.255.2.9]) by smtp.gmail.com with ESMTPSA id k12sm1881258lfu.285.2021.12.31.06.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 06:41:47 -0800 (PST) From: Ihor Radchenko To: Juan Manuel =?utf-8?Q?Mac=C3=ADas?= Subject: [PATCH] Re: [BUG] Underlined text in parentheses is not exported correctly In-Reply-To: <87v8z52eom.fsf@posteo.net> References: <874k6p3wtq.fsf@posteo.net> <87czld58nk.fsf@localhost> <87v8z52eom.fsf@posteo.net> Date: Fri, 31 Dec 2021 22:43:07 +0800 Message-ID: <87pmpcygw4.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::231 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=yantar92@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640961738; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=uPMbgFd7KZxScU6GC7oMlFIoXtMRJrxhqD2J4rVsnJo=; b=grBvdIXGnI27bosvzG6tUqQaMqfsWb30o62IHGYFCAgaiZYX/N6yBJfV//E3dCqloM8CN8 UQE8uxfstZjCsSy0pyKLdjXpS5wCh9ye8lUbTtuD7T+afnrz2Zx1m+2auDaI73JSWoQOGV EGHFyt+H93AzDMdlziA1ek+1gIedXC6WCQC4IOex82EWWviwwy5PFNdPn1fDnmBqa/5Qhh x/iHzhV0esDCw5LGjHLR/5qsyVnqABPpKxrk1cNbH2R1QZAyct1WImTVo58Pa3gWVqsKWX Orhw6Y5Hmni8tH1nGj4Xc3BM1bXr2cmKc9lfNkp6ovcamV6ziHZkPFYdLHInFQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640961738; a=rsa-sha256; cv=none; b=SxLW1S0iF4YL5gDjhQJeTK1o67ZFOJbK+XfXQUXc18Co0fHU5yYGD+f/65M9KgGs6FBZuM iBlOPRyAcXDUm2+c3uKhp8haJAkbEZY6jOp/gDx1mtBSJaqJo0IfEWfyvPK3iLKyYTL7MP vpWJibnvWIQTT/9cvrRyQNQriuqs8ZT/tb4Wkz+KFMK97vorcImeLon4ZxTLmscuQjO574 oOkSvQFnyJhBWEn5fUaDw2x8oce81xNTZp3GEDuUqogSvWllGAhFD+ual+gwjUwhvyDwOu hNB+IkYVQKBIDRxblczlqsCOgNwKsUmRDEJb2TQD9zcihAinZlf7SifNANIvhg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UPw1XNbV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.78 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UPw1XNbV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: A86351C87B X-Spam-Score: -3.78 X-Migadu-Scanner: scn1.migadu.com X-TUID: ZE/TuKYXVYUD --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Juan Manuel Mac=C3=ADas 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-underline-parser-inside-parenthesis.patch >From 12272f1ea89c169dcbece009c3a227e354019366 Mon Sep 17 00:00:00 2001 Message-Id: <12272f1ea89c169dcbece009c3a227e354019366.1640961654.git.yantar92@gmail.com> From: Ihor Radchenko 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 "(_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 -- 2.32.0 --=-=-=--