[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals-release/org d6f0e9e 1/2: oc: Be stricter when introduci
From: |
ELPA Syncer |
Subject: |
[elpa] externals-release/org d6f0e9e 1/2: oc: Be stricter when introducing spaces before citations |
Date: |
Sun, 3 Oct 2021 18:57:18 -0400 (EDT) |
branch: externals-release/org
commit d6f0e9e105009fd197f52dc5b755d59748d6f986
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>
oc: Be stricter when introducing spaces before citations
* lisp/oc.el (org-cite-process-citations): Add a space before citation
only if it is preceded by a quotation mark.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add
tests.
Reported-by: Denis Maier <denismaier@mailbox.org>
<http://lists.gnu.org/r/emacs-orgmode/2021-09/msg00085.html>
---
lisp/oc.el | 10 ++++++----
testing/lisp/test-oc.el | 25 ++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/lisp/oc.el b/lisp/oc.el
index fd80ba9..ac8cafb 100644
--- a/lisp/oc.el
+++ b/lisp/oc.el
@@ -1274,11 +1274,13 @@ by side-effect."
;; Before removing the citation, transfer its `:post-blank'
;; property to the object before, if any.
(org-cite--set-previous-post-blank cite blanks info)
- ;; We want to be sure any non-note citation is preceded by
- ;; a space. This is particularly important when using
+ ;; Make sure there is a space between a quotation mark and
+ ;; a citation. This is particularly important when using
;; `adaptive' note rule. See `org-cite-note-rules'.
- (unless (org-cite-inside-footnote-p cite t)
- (org-cite--set-previous-post-blank cite 1 info))
+ (let ((previous (org-export-get-previous-element cite info)))
+ (when (and (org-string-nw-p previous)
+ (string-suffix-p "\"" previous))
+ (org-cite--set-previous-post-blank cite 1 info)))
(pcase replacement
;; String.
((pred stringp)
diff --git a/testing/lisp/test-oc.el b/testing/lisp/test-oc.el
index fc90a21..995559b 100644
--- a/testing/lisp/test-oc.el
+++ b/testing/lisp/test-oc.el
@@ -1273,7 +1273,7 @@ arguments. Replace citation with \"@\" character in the
output."
(list "b" (org-element-create 'bold nil "c"))) " ")))))
-;;; TEST capabilities.
+;;; Test capabilities.
(ert-deftest test-org-cite/activate-capability ()
"Test \"activate\" capability."
;; Standard test.
@@ -1393,6 +1393,29 @@ arguments. Replace citation with \"@\" character in the
output."
'((section . (lambda (_ c _) c))
(paragraph . (lambda (_ c _) c))
(bold . (lambda (&rest _) "bold")))))))))
+ ;; Make sure to have a space between a quote and a citation.
+ (should
+ (equal "\"quotation\" citation\n"
+ (org-test-with-temp-text "\"quotation\"[cite:@key]"
+ (let ((org-cite--processors nil)
+ (org-cite-export-processors '((t . (foo nil nil)))))
+ (org-cite-register-processor 'foo
+ :export-citation (lambda (&rest _) "citation"))
+ (org-export-as (org-export-create-backend
+ :transcoders
+ '((section . (lambda (_ c _) c))
+ (paragraph . (lambda (_ c _) c)))))))))
+ (should
+ (equal "\"quotation\" citation\n"
+ (org-test-with-temp-text "\"quotation\" [cite:@key]"
+ (let ((org-cite--processors nil)
+ (org-cite-export-processors '((t . (foo nil nil)))))
+ (org-cite-register-processor 'foo
+ :export-citation (lambda (&rest _) "citation"))
+ (org-export-as (org-export-create-backend
+ :transcoders
+ '((section . (lambda (_ c _) c))
+ (paragraph . (lambda (_ c _) c)))))))))
;; Regular bibliography export.
(should
(eq 'success