1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

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>
This commit is contained in:
Nicolas Goaziou 2021-10-03 23:51:43 +02:00
parent 4b346e5157
commit d6f0e9e105
2 changed files with 30 additions and 5 deletions

View File

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

View File

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