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 sP/gHn5RWmKNSwAAgWs5BA (envelope-from ) for ; Sat, 16 Apr 2022 07:17:50 +0200 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 eIV9G35RWmK7EwAAauVa8A (envelope-from ) for ; Sat, 16 Apr 2022 07:17:50 +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 19B471B14E for ; Sat, 16 Apr 2022 07:17:50 +0200 (CEST) Received: from localhost ([::1]:42052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nfaoe-0000se-Q9 for larch@yhetil.org; Sat, 16 Apr 2022 01:17:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nfanh-0000sW-0X for emacs-orgmode@gnu.org; Sat, 16 Apr 2022 01:16:49 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:34437) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nfanf-0005Dv-4J for emacs-orgmode@gnu.org; Sat, 16 Apr 2022 01:16:48 -0400 Received: by mail-pg1-x52d.google.com with SMTP id t4so9745076pgc.1 for ; Fri, 15 Apr 2022 22:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=I3K/gQo4cf8MWg3Khg/zQDsyxja9CXTI400WYvFemf4=; b=UtxGYGLvYkj6U6vv9j7ytT1psA2hYkBAThvbSkELPrcl9RLR61kTmuCZedj68xDO55 pL3G+utc1oW6BeT9c6mgIEERNvCJxLGDMrEhD6ft5S4ZzcW5FdRd/19xxMH6/Zh24PY7 M2mjsMsKjxG9ikN+gQ1N8SvN75MTHKjk9p2prGn8/BndCfKBXEqKIUwrCLRdojSGWqty xOi0ULmGYHiMn6Ha15T0aBXoWuDgStI4ucbPdb+/dY7tHbwBLqPaVLUNGPHTZbSmkE79 lrYBmrEfaqwaTGReY0Lz47cAvixLO/IVwVzBPc6ifEhev3Kv206cm0MZ0SmvvHq1EWBx Llvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=I3K/gQo4cf8MWg3Khg/zQDsyxja9CXTI400WYvFemf4=; b=efVaosNE4jn7TEv2gVgaQWiLp/dx24EdO5MheJiSs9kJBRkkr9v+dD3NitOCf7zqhh acGhWJChTf/AjDdoGRzs1iR1BLroLgNA4+vQ1/D3GIl8UqDJ1t3FcRYPlT2B77kgmETv J3FaxFJwk70+BFgyp3lsHbbwfQbE83cA4PX64AIbwShAjCCzYRAknQ/fRn+FSEDW+miW bjwvJAg8w13zC4uetjKi0DzztNs2I+0X/tTY6D9UmmAbbmCxlVYZxcleBQdnfU0feIi5 h9rEPiAQXDpy85ypJ8pUum9tnVXmqud9rJSDpEa+n/2gYw8f6XMu8/Ost4F8WW1q91g6 BQsQ== X-Gm-Message-State: AOAM531nGYqOyKnuecDMjoRSAilu5cZUAlQf13h3ys4dktUFu+3AQmt4 taKYPb748rJvZUhnycgtf+z9HUK1rkYnRA== X-Google-Smtp-Source: ABdhPJwd2Yd689ZuwkxC6NeCcqCKCEhxIOd7OQ6oV1s6x0EM5KIwhh+8DOu8hjawQuVKLLgo7fiobA== X-Received: by 2002:a05:6a00:729:b0:4f7:77ed:c256 with SMTP id 9-20020a056a00072900b004f777edc256mr2109112pfm.1.1650086205357; Fri, 15 Apr 2022 22:16:45 -0700 (PDT) Received: from localhost ([134.73.240.160]) by smtp.gmail.com with ESMTPSA id m10-20020a17090a414a00b001cb776494a5sm10442821pjg.0.2022.04.15.22.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 22:16:44 -0700 (PDT) From: Ihor Radchenko To: Nicolas Goaziou , emacs-orgmode@gnu.org Subject: [PATCH] org-element-export-snippet-parser: Fix snippets without ending @@ Date: Sat, 16 Apr 2022 13:17:38 +0800 Message-ID: <87ee1xd2tp.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=yantar92@gmail.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650086270; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=I3K/gQo4cf8MWg3Khg/zQDsyxja9CXTI400WYvFemf4=; b=YtYIbzQnkh8K9Y2u0moR43LGJWVb52+eKvQwFM4YWISzhggIG6su++q0+fwLXF/PUgrojZ jJcCxDtPAKPTvHasYWsh7xHyt+IMJeBd4Yo5h5UhRrJl9eA7VeIYs0NMbWyk3W718znOjH Xafhq2RTL2RnC3E3iNdvg+hLjGlL+r9SNH3YUW0J0x5pNGYPxIBjUoPpuUbvVQc80ROAjU oXlGEPOQuifyD0SaOPqFl8ytn9g1gxA/FrM7kq5FtKrXd186Lh5Y+jLoTQBgfqxbG9hNKt 5+7b72imBwl1ETVLyPsGTf+Buip0XQPblu26HfchggRIk8c9TJnDQaukGtth8g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650086270; a=rsa-sha256; cv=none; b=Qv9P2mNAdmoAYOYcEH2AwROZvpLNjz0HGLq/UkYgkf4vwZ7gF/M/0B00OuZ5qvIRvURWUy SxAJ4OqIB27v3fOwyvNSIDfRXOl1SNGT7rtnyRGMollqlkQaYRiKOwGR/zewjkwYC/oxmH oCKqSB3jIdJTvMS1uSUABwhIcmsLW1UbhdIuojmNIODuk1qd4dg3XOJp7+jLvpj/VyS0ki NHJifIPwcOJ/3a6qZSfZhWCba0Z8c8KPqcHwra4VK/fuw3nOGvaC0lY0TD7HV93ejFMMyY PNLM0H1jRWYGJIK5RSEnuJt7Nlnjw2ewop5T8OWH+DYZvmL4ytrj1JxsSs4kbA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UtxGYGLv; 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: -9.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UtxGYGLv; 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: 19B471B14E X-Spam-Score: -9.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: trIC2S1NT/Y6 --=-=-= Content-Type: text/plain There is an edge case when parsing export snippets: @@html:fo aksjdaksjd ajs d askdjas aksj daj sao@@ Our current parser recognises the opening "@@html:" as a standalone snippet. Unless I misunderstand something, it is not intentional. The fix is attached. Nicolas, unless you have any objections, I will install the attached patch to bugfix. Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-element-export-snippet-parser-Fix-snippets-witho.patch >From c866dcc8e593da2fca2611b100b4ab3ea9641e03 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Sat, 16 Apr 2022 13:08:57 +0800 Subject: [PATCH] org-element-export-snippet-parser: Fix snippets without ending @@ * lisp/org-element.el (org-element-export-snippet-parser): Do not recognise snippets without closing @@ as empty "@@backend:" snippets. Example: @@html:fo aksjdaksjd ajs d askdjas aksj daj sao@@ Reported in https://github.com/lucasvreis/org-parser/blob/master/SPEC.org#export-snippets --- lisp/org-element.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 9db1406b3..661902e04 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -2980,8 +2980,9 @@ (defun org-element-export-snippet-parser () (when (and (looking-at "@@\\([-A-Za-z0-9]+\\):") (setq contents-end (save-match-data (goto-char (match-end 0)) - (re-search-forward "@@" nil t) - (match-beginning 0)))) + (when + (re-search-forward "@@" nil t) + (match-beginning 0))))) (let* ((begin (match-beginning 0)) (back-end (match-string-no-properties 1)) (value (buffer-substring-no-properties -- 2.35.1 --=-=-= Content-Type: text/plain Parsed buffer without patch: Note (export-snippet (:back-end "html" :value "@@html:" :begin 1 :end 8 :post-blank 0 :parent #2)) (org-data (:begin 1 :contents-begin 1 :contents-end 52 :end 52 :robust-begin 3 :robust-end 50 :post-blank 0 :post-affiliated 1 :path "/tmp/bug.org" :mode org-data :CATEGORY "bug" :granularity nil) (section (:begin 1 :end 52 :contents-begin 1 :contents-end 52 :robust-begin 1 :robust-end 50 :post-blank 0 :post-affiliated 1 :mode first-section :granularity nil :parent #0) (paragraph (:begin 1 :end 29 :contents-begin 1 :contents-end 28 :post-blank 1 :post-affiliated 1 :mode top-comment :granularity nil :parent #1) (export-snippet (:back-end "html" :value "@@html:" :begin 1 :end 8 :post-blank 0 :parent #2)) #("fo aksjdaksjd ajs d\n" 0 20 (:parent #2))) (paragraph (:begin 29 :end 52 :contents-begin 29 :contents-end 52 :post-blank 0 :post-affiliated 29 :mode nil :granularity nil :parent #1) #("askdjas aksj daj sao@@\n" 0 23 (:parent #2))))) With patch: (org-data (:begin 1 :contents-begin 1 :contents-end 52 :end 52 :robust-begin 3 :robust-end 50 :post-blank 0 :post-affiliated 1 :path "/tmp/bug.org" :mode org-data :CATEGORY "bug" :granularity nil) (section (:begin 1 :end 52 :contents-begin 1 :contents-end 52 :robust-begin 1 :robust-end 50 :post-blank 0 :post-affiliated 1 :mode first-section :granularity nil :parent #0) (paragraph (:begin 1 :end 29 :contents-begin 1 :contents-end 28 :post-blank 1 :post-affiliated 1 :mode top-comment :granularity nil :parent #1) #("@@html:fo aksjdaksjd ajs d\n" 0 27 (:parent #2))) (paragraph (:begin 29 :end 52 :contents-begin 29 :contents-end 52 :post-blank 0 :post-affiliated 29 :mode nil :granularity nil :parent #1) #("askdjas aksj daj sao@@\n" 0 23 (:parent #2))))) --=-=-=--