Function: org-cite-process-citations
org-cite-process-citations is a byte-compiled function defined in
oc.el.gz.
Signature
(org-cite-process-citations INFO)
Documentation
Replace all citations in the parse tree.
INFO is the communication channel, as a plist. Parse tree is modified by side-effect.
Source Code
;; Defined in /usr/src/emacs/lisp/org/oc.el.gz
(defun org-cite-process-citations (info)
"Replace all citations in the parse tree.
INFO is the communication channel, as a plist. Parse tree is modified
by side-effect."
(dolist (cite (org-cite-list-citations info))
(let ((replacement (org-cite-export-citation cite nil info))
(blanks (or (org-element-post-blank cite) 0)))
(if (null replacement)
;; Before removing the citation, transfer its `:post-blank'
;; property to the object before, if any.
(org-cite--set-previous-post-blank cite blanks info)
;; 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'.
(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)
;; Handle `:post-blank' before replacing value.
(let ((output (concat (org-trim replacement)
(make-string blanks ?\s))))
(org-element-insert-before (org-export-raw-string output) cite)))
;; Single element.
(`(,(pred symbolp) . ,_)
(org-cite--set-post-blank replacement blanks)
(org-element-insert-before replacement cite))
;; Secondary string: splice objects at cite's place.
;; Transfer `:post-blank' to the last object.
((pred consp)
(let ((last nil))
(dolist (datum replacement)
(setq last datum)
(org-element-insert-before datum cite))
(org-cite--set-post-blank last blanks)))
(_
(error "Invalid return value from citation export processor: %S"
replacement))))
(org-element-extract cite))))