From 83696bf21fe48ff3b698d20872aee6c46f5d2566 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 21 Jan 2024 13:44:50 +0100 Subject: [PATCH] org-export-activate-smart-quotes: Fix edge case with multiple secondary strings * lisp/ox.el (org-export--smart-quote-status): Do not hash quote status by parent syntax node - it will create clashes when parent has multiple secondary strings. Instead, hash by parent + secondary string property. * testing/lisp/test-ox.el (test-org-export/activate-smart-quotes): Add new test case. Reported-by: William Denton Link: https://orgmode.org/list/TarY7-tR4TEmIu8jawOtTyyi03K93WIg7DsS1eXNylelCy2Hv-6OFNKOMQMukf70Tzf3uO_2F1Qe7xwrzb43SpJc4jxJZLN3W0MioKYbgzI=@williamdenton.org --- lisp/ox.el | 4 ++-- testing/lisp/test-ox.el | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index 34ea32b3b..32ca2ff10 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5854,7 +5854,7 @@ INFO is the current export state, as a plist." (let ((table (make-hash-table :test #'eq))) (plist-put info :smart-quote-cache table) table))) - (value (gethash parent cache 'missing-data))) + (value (gethash (cons parent (org-element-secondary-p s)) cache 'missing-data))) (if (not (eq value 'missing-data)) (cdr (assq s value)) (let (level1-open full-status) (org-element-map @@ -5922,7 +5922,7 @@ INFO is the current export state, as a plist." (when current-status (push (cons text (nreverse current-status)) full-status)))) info nil org-element-recursive-objects) - (puthash parent full-status cache) + (puthash (cons parent (org-element-secondary-p s)) full-status cache) (cdr (assq s full-status)))))) (defun org-export-activate-smart-quotes (s encoding info &optional original) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index e59c20cae..63babe8cd 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -4229,6 +4229,14 @@ This test does not cover listings and custom environments." (org-element-map tree 'plain-text (lambda (s) (org-export-activate-smart-quotes s :html info)) info))))) + ;; Smart quotes when object has multiple secondary strings. + (should + (equal '(" “prefix” " " “suffix”") + (let ((org-export-default-language "en")) + (org-test-with-parsed-data "[cite:; \"prefix\" @key \"suffix\";]" + (org-element-map tree 'plain-text + (lambda (s) (org-export-activate-smart-quotes s :html info)) + info))))) ;; Smart quotes in document keywords. (should (equal '("“" "”")