From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 8I8xEpq//mULKAEA62LTzQ:P1 (envelope-from ) for ; Sat, 23 Mar 2024 12:40:10 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 8I8xEpq//mULKAEA62LTzQ (envelope-from ) for ; Sat, 23 Mar 2024 12:40:10 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="MWWqh8/r"; 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=1711194010; 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=ONxHZMUqa421ygrgTdvSb25Wfeljw45sLUG2hcGSw64=; b=Q75KRVdt7Etb+XJD43DdGZZeGa22be1sZL4ax/o70G2RZutU7bpCFizKjhANgPy8/cs3S8 lctyx28vkO8ky1RM9HjzgwvRQrFqVx6ziAM5BqYpOfoUcRmk8wuTn20v8peEAT/QOTa5iU fGY/zHauVij1mpWugryz4Bz/TPL2z4dGoY3ryVaV3faBp+4v2mr/+BW3O2H6YoFgoEonDi uduSTBjbe87Hgzq4TY52V8lp/FBZvC0LfvMGdxv6m0ncIdbTbkhWYWrbKfsrVHCbYJieji wy8nARw4wbS3YzZ4VjXRRXfQVIQXZ6foFGWV2lKzf60duXOuJoYEegHjnL1KlQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="MWWqh8/r"; 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-Seal: i=1; s=key1; d=yhetil.org; t=1711194010; a=rsa-sha256; cv=none; b=Jj8PCpQSi8WCFqNdjB0uRyqJVSNh8fiOJOuq3ayxicRHNMZwP9XfHIal7KJa6jINALocYl c2HE5xIP0gq34bCgAhexzZZXmVEUh9CrcKbY6Ejoijsd1bXvTNh+65XgDDh3pUPZZXbqUb TAwRY7y90heZ+kxozSelIKSSnqN7pnwFedPx/5kqWnC9GvPEMzMkB9Ew5h1uvyFF8hvH8z g328u2WbeQRLoTOIRMwFRZY4NJxdECiuDJ2XneHm5AUvs53KV1bFkQ04bS1bbj8bb2nTdo qhi7eRqi6C8ZkyKT9O6wG+RzdZ8lO6RDm7xVuZ4wwC1SM8vY5erLos2c/FXLKQ== 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 DFD1A51ABD for ; Sat, 23 Mar 2024 12:40:09 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnziM-00021Y-M8; Sat, 23 Mar 2024 07:39:06 -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 1rnziJ-00021F-K0 for emacs-orgmode@gnu.org; Sat, 23 Mar 2024 07:39:03 -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 1rnziG-0003h8-3O for emacs-orgmode@gnu.org; Sat, 23 Mar 2024 07:39:02 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C30A5240101 for ; Sat, 23 Mar 2024 12:38:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1711193936; bh=7vDzT9HHEGMT8fcjuPpCjsu1UBQmDu1YfXbq0tZDl54=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=MWWqh8/rjdGGEnawKHIj0j6RAl1MdtiKuwPV1NKtKoStVED/owwnug2WEojQJf4Q3 jBd+IB2gZ/ygLILEWftO7fxM73ZZidFAPLvB6BhUMuGG+L6D2gEIAfSBIkeviYW/xt 3U/Pf2/N24fLNnGsHM69NmyBr3TeRlefDnsbbgaP/s+Lw6wEflEQG1ru/0HK5pkP7r Ld7STgc1VN6+ZZHeIcrbnPBwKIBu1/ovcVGiuJLvuPxaDCBSgdIY1heagmxOS3R2/n Kd1ivKDJB83AwkIl3bRV5rIDxjJ4s/A9zPk13puOfF1g64fnz9Nno2hxlZX6PRqFTj mjpfORCrU6S3Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4V1xzh19Qdz9rxF; Sat, 23 Mar 2024 12:38:56 +0100 (CET) From: Ihor Radchenko To: Juan Manuel =?utf-8?Q?Mac=C3=ADas?= Cc: orgmode Subject: Re: [bug] Smart quotes: confusion of apostrophe with second level quotes In-Reply-To: <875xxfqdpt.fsf@posteo.net> References: <875xxfqdpt.fsf@posteo.net> Date: Sat, 23 Mar 2024 11:38:54 +0000 Message-ID: <874jcxtbxt.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_H4=0.001, RCVD_IN_MSPIKE_WL=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: 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-Spam-Score: -9.43 X-Migadu-Queue-Id: DFD1A51ABD X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -9.43 X-TUID: XPthf+xEXJn/ --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: base64 SnVhbiBNYW51ZWwgTWFjw61hcyA8bWFjaWFzY2hhaW5AcG9zdGVvLm5ldD4gd3JpdGVzOg0KDQo+ ICAg4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB 4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB 4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSB4pSBDQo+ICAgIytPUFRJT05TOiAnOnQNCj4gICAj K2xhbmd1YWdlOmVzDQo+DQo+ICAgIm15IGZyaWVuZHMnIHBhcnR5IGFuZCB0aGUgc3R1ZGVudHMn IHBhcGVycyINCj4gICDilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHi lIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHi lIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIHilIENCj4NCj4gdGhlIGFib3Zl IHByb2R1Y2VzIGluIExhVGVYOg0KPg0KPiAgIFxndWlsbGVtb3RsZWZ0e31teSBmcmllbmRzJycg cGFydHkgYW5kIHRoZSBzdHVkZW50cycnIHBhcGVyc1xndWlsbGVtb3RyaWdodHt9DQo+IC4uLg0K PiBQZXJoYXBzIGEgcG9zc2libGUgc29sdXRpb24gd291bGQgYmUgdG8gYWxsb3cgdGhlIHVzZSBv ZiBhIHNwZWNpZmljLA0KPiBjdXN0b21pemFibGUgY2hhcmFjdGVyLCBvdGhlciB0aGFuIGFuIGFw b3N0cm9waGUsIGZvciBzZWNvbmQtbGV2ZWwNCj4gcXVvdGVzLiBPciBhdCBsZWFzdCBhZGQgc29t ZSBicmllZiB3YXJuaW5nIGluIHRoZSBtYW51YWw6IGluIGNlcnRhaW4NCj4gY29udGV4dHMgaXQg aXMgc2FmZXIgdG8gdXNlIGEgZXhwbGljaXQgVW5pY29kZSBjaGFyYWN0ZXIgZm9yIHRoZQ0KPiBh cG9zdHJvcGhlLg0KDQpJIHRoaW5rIHRoYXQgd2UgY2FuIGFkZHJlc3MgZXhhbXBsZXMgbGlrZSB0 aGlzIHNpbXBseSBieSBub3QgcmVwbGFjaW5nDQp1bmJhbGFuY2VkIHF1b3Rlcy4gVGhlcmUgaXMg YWxyZWFkeSBzb21lIGVmZm9ydCBpbiB0aGUgY29kZSB0b3dhcmRzIHN1Y2gNCnRyZWF0bWVudCwg YnV0IGl0IGlzIG5vdCBjb21wbGV0ZS4NCg0KQ2FuIHlvdSB0cnkgdGhlIGF0dGFjaGVkIHBhdGNo Pw0KDQo= --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-org-export-Do-not-treat-unpaired-and-as-smart-quotes.patch Content-Transfer-Encoding: quoted-printable >From 4a034fbb0029ca7e635f629810a6179df4ca24d9 Mon Sep 17 00:00:00 2001 Message-ID: <4a034fbb0029ca7e635f629810a6179df4ca24d9.1711193777.git.yantar= 92@posteo.net> From: Ihor Radchenko Date: Sat, 23 Mar 2024 14:34:06 +0300 Subject: [PATCH] org-export: Do not treat unpaired ' and " as smart quotes MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/ox.el (org-export--smart-quote-status): When quotes are not balanced, treat " literally and ' as apostrophes. * testing/lisp/test-ox.el (test-org-export/activate-smart-quotes): Fix test with unbalanced " and add new tests for unbalanced quotes. Reported-by: Juan Manuel Mac=C3=ADas Link: https://list.orgmode.org/orgmode/875xxfqdpt.fsf@posteo.net/ --- lisp/ox.el | 45 +++++++++++++++++++++++++++++++++++++++++ testing/lisp/test-ox.el | 29 ++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index 929b306dc..539d31d9d 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5942,6 +5942,51 @@ (defun org-export--smart-quote-status (s info) (when current-status (push (cons text (nreverse current-status)) full-status)))) info nil org-element-recursive-objects) + ;; When quotes are not balanced, threat them as apostrophes. + (setq full-status (nreverse full-status)) + (let (primary-openings secondary-openings) + (dolist (substatus full-status) + (let ((status (cdr substatus))) + (while status + (pcase (car status) + (`apostrophe nil) + (`primary-opening + (push status primary-openings)) + (`secondary-opening + (push status secondary-openings)) + (`secondary-closing + (if secondary-openings + ;; Remove matched opening. + (pop secondary-openings) + ;; No matching openings for a given closing. Replace + ;; it with apostrophe. + (setcar status 'apostrophe))) + (`primary-closing + (when secondary-openings + ;; Some secondary opening quotes are not closed + ;; within "...". Replace them all with apostrophes. + (dolist (opening secondary-openings) + (setcar opening 'apostrophe)) + (setq secondary-openings nil)) + (if primary-openings + ;; Remove matched opening. + (pop primary-openings) + ;; No matching openings for a given closing. + (error "This should no happen")))) + (setq status (cdr status))))) + (when primary-openings + ;; Trailing unclosed " + (unless (=3D 1 (length primary-openings)) + (error "This should not happen")) + ;; Mark for not replacing. + (setcar (car primary-openings) nil) + ;; Mark all the secondary openings and closings after + ;; trailing unclosed " as apostrophes. + (let ((tail (car primary-openings))) + (while tail + (when (memq (car tail) '(secondary-opening secondary-closi= ng)) + (setcar tail 'apostrophe)) + (setq tail (cdr tail)))))) (puthash (cons parent (org-element-secondary-p s)) full-status cache) (cdr (assq s full-status)))))) =20 diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 01e082c9b..16e81c64b 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -4134,9 +4134,9 @@ (ert-deftest test-org-export/activate-smart-quotes () ;; Opening quotes: at the beginning of a paragraph. (should (equal - '("“begin") + '("“begin”") (let ((org-export-default-language "en")) - (org-test-with-parsed-data "\"begin" + (org-test-with-parsed-data "\"begin\"" (org-element-map tree 'plain-text (lambda (s) (org-export-activate-smart-quotes s :html info)) info))))) @@ -4267,6 +4267,31 @@ (ert-deftest test-org-export/activate-smart-quotes () (org-test-with-parsed-data "*\"foo\"*" (org-element-map tree 'plain-text (lambda (s) (org-export-activate-smart-quotes s :html info)) + info nil nil t))))) + ;; Unmatched quotes. + (should + (equal '("\\guillemotleft{}my friends' party and the students' papers\\= guillemotright{} \\guillemotleft{}``mothers''\\guillemotright{}") + (let ((org-export-default-language "es")) + (org-test-with-parsed-data + "\"my friends' party and the students' papers\" \"'mothers= '\"" + (org-element-map tree 'plain-text + (lambda (s) (org-export-activate-smart-quotes s :latex info)) + info nil nil t))))) + (should + (equal '("\"'mothers'") + (let ((org-export-default-language "es")) + (org-test-with-parsed-data + "\"'mothers'" + (org-element-map tree 'plain-text + (lambda (s) (org-export-activate-smart-quotes s :latex info)) + info nil nil t))))) + (should + (equal '("\\guillemotleft{}=CE=BD=CE=B1 '=CF=81=CE=B8=CF=8E =CF=84=CE= =BF =CE=B2=CF=81=CE=AC=CE=B4=CF=85\\guillemotright{}") + (let ((org-export-default-language "el")) + (org-test-with-parsed-data + "\"=CE=BD=CE=B1 '=CF=81=CE=B8=CF=8E =CF=84=CE=BF =CE=B2=CF= =81=CE=AC=CE=B4=CF=85\"" + (org-element-map tree 'plain-text + (lambda (s) (org-export-activate-smart-quotes s :latex info)) info nil nil t)))))) =20 =20 --=20 2.44.0 --=-=-= 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 --=-=-=--