Merge branch 'bugfix'

This commit is contained in:
Nicolas Goaziou 2021-10-04 00:01:22 +02:00
commit 1acacd6049
2 changed files with 41 additions and 12 deletions

View File

@ -152,10 +152,10 @@ triplet following the pattern
(NAME BIBLIOGRAPHY-STYLE CITATION-STYLE) (NAME BIBLIOGRAPHY-STYLE CITATION-STYLE)
There, NAME is the name of a registered citation processor providing export There, NAME is the name of a registered citation processor providing export
functionality, as a symbol. BIBLIOGRAPHY-STYLE (resp. CITATION-STYLE) is the functionality, as a symbol. BIBLIOGRAPHY-STYLE (respectively CITATION-STYLE)
desired default style to use when printing a bibliography (resp. exporting a is the desired default style to use when printing a bibliography (respectively
citation), as a string or nil. Both BIBLIOGRAPHY-STYLE and CITATION-STYLE are exporting a citation), as a string or nil. Both BIBLIOGRAPHY-STYLE and
optional. NAME is mandatory. CITATION-STYLE are optional. NAME is mandatory.
The export process selects the citation processor associated to the current The export process selects the citation processor associated to the current
export back-end, or the most specific back-end the current one is derived from, export back-end, or the most specific back-end the current one is derived from,
@ -502,8 +502,8 @@ This function assumes S precedes CITATION."
(defun org-cite--move-punct-before (punct citation s info) (defun org-cite--move-punct-before (punct citation s info)
"Move punctuation PUNCT before CITATION object. "Move punctuation PUNCT before CITATION object.
String S contains PUNCT. The function assumes S follows CITATION. String S contains PUNCT. INFO is the export state, as a property list.
Parse tree is modified by side-effect." The function assumes S follows CITATION. Parse tree is modified by side-effect."
(if (equal s punct) (if (equal s punct)
(org-element-extract-element s) ;it would be empty anyway (org-element-extract-element s) ;it would be empty anyway
(org-element-set-element s (substring s (length punct)))) (org-element-set-element s (substring s (length punct))))
@ -877,6 +877,9 @@ modified by side-effect."
INFO is the export state, as a property list. INFO is the export state, as a property list.
Optional argument RULE is the punctuation rule used, as a triplet. When nil,
rule is determined according to `org-cite-note-rules', which see.
Optional argument PUNCT is a list of punctuation marks to be considered. Optional argument PUNCT is a list of punctuation marks to be considered.
When nil, it defaults to `org-cite-punctuation-marks'. When nil, it defaults to `org-cite-punctuation-marks'.
@ -1274,11 +1277,13 @@ by side-effect."
;; Before removing the citation, transfer its `:post-blank' ;; Before removing the citation, transfer its `:post-blank'
;; property to the object before, if any. ;; property to the object before, if any.
(org-cite--set-previous-post-blank cite blanks info) (org-cite--set-previous-post-blank cite blanks info)
;; We want to be sure any non-note citation is preceded by ;; Make sure there is a space between a quotation mark and
;; a space. This is particularly important when using ;; a citation. This is particularly important when using
;; `adaptive' note rule. See `org-cite-note-rules'. ;; `adaptive' note rule. See `org-cite-note-rules'.
(unless (org-cite-inside-footnote-p cite t) (let ((previous (org-export-get-previous-element cite info)))
(org-cite--set-previous-post-blank cite 1 info)) (when (and (org-string-nw-p previous)
(string-suffix-p "\"" previous))
(org-cite--set-previous-post-blank cite 1 info)))
(pcase replacement (pcase replacement
;; String. ;; String.
((pred stringp) ((pred stringp)
@ -1384,7 +1389,8 @@ ARG is the prefix argument received when calling `org-open-at-point', or nil."
;;; Meta-command for citation insertion (insert capability) ;;; Meta-command for citation insertion (insert capability)
(defun org-cite--allowed-p (context) (defun org-cite--allowed-p (context)
"Non-nil when a citation can be inserted at point." "Non-nil when a citation can be inserted at point.
CONTEXT is the element or object at point, as returned by `org-element-context'."
(let ((type (org-element-type context))) (let ((type (org-element-type context)))
(cond (cond
;; No citation in attributes, except in parsed ones. ;; No citation in attributes, except in parsed ones.

View File

@ -1273,7 +1273,7 @@ arguments. Replace citation with \"@\" character in the output."
(list "b" (org-element-create 'bold nil "c"))) " "))))) (list "b" (org-element-create 'bold nil "c"))) " ")))))
;;; TEST capabilities. ;;; Test capabilities.
(ert-deftest test-org-cite/activate-capability () (ert-deftest test-org-cite/activate-capability ()
"Test \"activate\" capability." "Test \"activate\" capability."
;; Standard test. ;; Standard test.
@ -1393,6 +1393,29 @@ arguments. Replace citation with \"@\" character in the output."
'((section . (lambda (_ c _) c)) '((section . (lambda (_ c _) c))
(paragraph . (lambda (_ c _) c)) (paragraph . (lambda (_ c _) c))
(bold . (lambda (&rest _) "bold"))))))))) (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. ;; Regular bibliography export.
(should (should
(eq 'success (eq 'success