From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 4EopKfukIWRE7gAASxT56A (envelope-from ) for ; Mon, 27 Mar 2023 16:15:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id ELWZKPukIWRBzgAAauVa8A (envelope-from ) for ; Mon, 27 Mar 2023 16:15:23 +0200 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 0410321E2 for ; Mon, 27 Mar 2023 16:15:22 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=pJe9ZDE6; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1679926523; 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=xatUtTCejzJNXHk5RQqUZjx8knEatki31QVzSGqgAVY=; b=Eia0MDmLvGyr669H8gYlPe27yh+3C+/Y2Ev1oyknh0kx7/0yqoLmd9GNaFw7ycoTIz+xce bsf2UdOyvy+mEya8pSpwC0AZmf3VUVrS6iNRLx1z0uVl6aov+5GfKYvjin4Aw7eXqSiFgr aE+aVPwuCn3Ms+opfGJ0AkOdmpPdtVzUP9lf8KUmjqWNFtRxE6Uc29tyvO27uom1u7nPm8 D8XIxCIj4YYDU71Ioy71dN7CWI10G8+WG6s+awp2dIVs8f3vm87LJh2r8OLKxDIyBiM6ND Lj+Ck0BqHcHZHbKB7FvoOLcDuVloRKUgXJFGAb3/LlYnT13nK4DzfloCmkeUtw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679926523; a=rsa-sha256; cv=none; b=eAY1hOcyVRYoZNvndFMKIubQgWyiMGcZi2QHjwWUuFU3mxVd4sQrcgobFqJvy91CoemKoZ rGj7PZgJr2yy5qEycVyYynEYu36ubAGAl/zGJ7Gn63yEYC6sLiFNlHjiaeuzWWOd9FZAlC HK4Vrm2H57wM1TWrh8QSyMhiJ4WVKIpTx/9vG1B00BLxsXhJGoRikB+hWwD8yhAJzwBa2c ywtvlh5QPgasxY8cMpwaWWGP4XBaMmSLUvt48Vy7clhjdyVahwxaCqVal59t39N4F/Cb0i EDB96mRhNXvixyce3r/ZPQldf+D07W03GUj0JND41VdRkZxXEZd12+ZmFMLa2w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=pJe9ZDE6; 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"; dmarc=pass (policy=none) header.from=posteo.net Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pgnc2-0004Ii-IK; Mon, 27 Mar 2023 10:14:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgnbz-0004FO-U7 for emacs-orgmode@gnu.org; Mon, 27 Mar 2023 10:14:15 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pgnbx-0005Pi-JF for emacs-orgmode@gnu.org; Mon, 27 Mar 2023 10:14:15 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2E664240153 for ; Mon, 27 Mar 2023 16:14:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1679926451; bh=34bo4Lr+cJW5Mi/e/bVSuXsI2Otixut5e2cjfm1YCK0=; h=From:To:Cc:Subject:Date:From; b=pJe9ZDE6U3wThFa+os6BWdn6Yufrr96MAn5tZNSUgbh6KYyVpVCLWcHvLPugOXNXI VpjW8PEEFiscwkbZ1f52yS6q9Y/WN9Mp8tk8v3elUvSBU9mMtEyBaGxMfnkOcJisuc EMYNy5TlWz8U+HBXp73T39KHArEWCQCkWWBB1Rgk8v9Xx59fjJyV054iQZrWJiAehL in7WLfZ+zUMuB6ciHHp8uOFn12H+FcMY1Kjl5Lz5HU9MgNxX56vispm+ixffx7lhGS fl53nPF/fLXeKQ14f6/ljfJTwDJLvXJvT0YmZlajr3194eS4L/cVpDnRVrFasfNWN9 0+rcjOGW3sE4A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PlZYt46rTz6trs; Mon, 27 Mar 2023 16:14:10 +0200 (CEST) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] No space after footnote with org-export-with-footnotes set to nil [9.6.1 ( @ /Users/test/.emacs.d/elpa/28.0/develop/org-9.6.1/)] In-Reply-To: <87zg8jwp26.fsf@localhost> References: <5BB5EF8E-6D40-4055-99AE-BF596E5E8C98@gmail.com> <851a585b-ea53-b24f-438b-ffd9b36d29f5@gmail.com> <87v8jh4z2d.fsf@localhost> <9302738a-b351-0422-22ad-e764aade01e5@gmail.com> <87o7p7z9k3.fsf@localhost> <0D66BE43-7FF4-4B96-A1EC-03AF5FCA93B5@gmail.com> <878rgbz7w1.fsf@localhost> <5571340B-0551-4DA1-AFA1-3A7C94C8DDB7@gmail.com> <875ybfz71b.fsf@localhost> <2b73ed2c-214b-36f9-d695-9137a37a88f3@gmail.com> <877cvsfyr1.fsf@localhost> <87y1o6p02i.fsf@localhost> <87v8j8yfjk.fsf@localhost> <87zg8jwp26.fsf@localhost> Date: Mon, 27 Mar 2023 14:16:08 +0000 Message-ID: <87lejith3r.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: X-Migadu-Queue-Id: 0410321E2 X-Spam-Score: -6.25 X-Migadu-Spam-Score: -6.25 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: FDuvv6DwCk4h --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Max Nikulin writes: > >>> [previous object ] >> >> Yes, you do. >> >> I expected some complications due to newline characters (not line break >> markup objects), but they are not included in :post-blank and >> represented as "\n" string objects. > > Newlines are tricky. They may or may not be significant. > For example, in CJK paragraphs, newlines are to be stripped. > > I think that a reasonable thing to do could be not adding newlines if > the previous object is a plain string ending with a newline. I think that using max(n1,n2) is an overkill. There is no reason to alter existing spaces before, if any. I am attaching tentative patch that simply keeps spaces, but if and only if the previous object does not end with whitespace (including newline). --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-export-prune-tree-Ensure-spaces-when-removing-ob.patch >From 656c32d075d939aa69bc315bc91515930680377c Mon Sep 17 00:00:00 2001 Message-Id: <656c32d075d939aa69bc315bc91515930680377c.1679926405.git.yantar92@posteo.net> From: Ihor Radchenko Date: Mon, 27 Mar 2023 16:11:32 +0200 Subject: [PATCH] org-export--prune-tree: Ensure spaces when removing objects * lisp/ox.el (org-export--prune-tree): If the removed object has trailing spaces and previous object does not have, keep the trailing spaces. * etc/ORG-NEWS (Blank lines after removed objects are not retained during export): Document the change. Reported-by: Andrea Lazzarini Link: https://orgmode.org/list/87o7p7z9k3.fsf@localhost --- etc/ORG-NEWS | 21 +++++++++++++++++++++ lisp/ox.el | 19 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index ac233a986..caf140279 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -145,6 +145,27 @@ execution completes. The new ~:async~ header allows users to continue editing with Emacs while a ~:session~ block executes. ** Miscellaneous +*** Blank lines after removed objects are not retained during export + +When certain objects in Org document are to be excluded from export, +spaces after these objects were previously removed as well. + +For example, if ~org-export-with-footnotes~ is set to nil, the footnote in + +: Pellentesque dapibus suscipit ligula.[fn:1] Donec posuere augue in quam. + +would be removed, leading to the following exported ASCII document + +: Pellentesque dapibus suscipit ligula.Donec posuere augue in quam. + +This is because spaces after footnote (and other markup) are +considered a part of the preceding AST object in Org. + +Now, unless there is a whitespace before an object to be removed, +spaces are preserved during export: + +: Pellentesque dapibus suscipit ligula. Donec posuere augue in quam. + *** Remove undocumented ~:target~ header parameter in ~ob-clojure~ The ~:target~ header was only used internally to distinguish diff --git a/lisp/ox.el b/lisp/ox.el index f9fc9a99b..206f0536d 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -2752,7 +2752,24 @@ (defun org-export--prune-tree (data info) (let ((type (org-element-type data))) (if (org-export--skip-p data info selected excluded) (if (memq type '(table-cell table-row)) (push data ignore) - (org-element-extract-element data)) + (let ((post-blank (org-element-property :post-blank data))) + (if (or (not post-blank) (zerop post-blank) + (eq 'element (org-element-class data))) + (org-element-extract-element data) + ;; Keep spaces in place of removed + ;; element, if necessary. + ;; Example: "Foo.[10%] Bar" would become + ;; "Foo.Bar" if we do not keep spaces. + (let ((previous (org-export-get-previous-element data info))) + (if (or (not previous) + (pcase (org-element-type previous) + (`plain-text + (string-match-p + (rx whitespace eos) previous)) + (_ (org-element-property :post-blank previous)))) + ;; Previous object ends with whitespace already. + (org-element-extract-element data) + (org-element-set-element data (make-string post-blank ?\s))))))) (if (and (eq type 'headline) (eq (plist-get info :with-archived-trees) 'headline) -- 2.39.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--