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 <william@williamdenton.org>
Link: https://orgmode.org/list/TarY7-tR4TEmIu8jawOtTyyi03K93WIg7DsS1eXNylelCy2Hv-6OFNKOMQMukf70Tzf3uO_2F1Qe7xwrzb43SpJc4jxJZLN3W0MioKYbgzI=@williamdenton.org
This commit is contained in:
Ihor Radchenko 2024-01-21 13:44:50 +01:00
parent ac1c72376c
commit 83696bf21f
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 10 additions and 2 deletions

View File

@ -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)

View File

@ -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 '(" &ldquo;prefix&rdquo; " " &ldquo;suffix&rdquo;")
(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 '("&ldquo;" "&rdquo;")