diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2021-04-19 18:15:14 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2021-07-09 08:47:14 +0200 |
commit | 2c2b7203947a7ab18e3d74bf9238b06c89bf9aaa (patch) | |
tree | 499b17f665caf90db4eb28e3a2bc37d1c3952a84 | |
parent | 44156353c939bbe01d43e814744eae42fc282e56 (diff) | |
download | org-mode-2c2b7203947a7ab18e3d74bf9238b06c89bf9aaa.tar.gz |
ox: Plug citations into export process
* lisp/ox.el (org-export-as): Add citation pre-processing.
-rw-r--r-- | lisp/ox.el | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -74,6 +74,8 @@ (require 'cl-lib) (require 'ob-exp) +(require 'oc) +(require 'oc-basic) ;default value for `org-cite-export-processors' (require 'ol) (require 'org-element) (require 'org-macro) @@ -140,7 +142,9 @@ (:with-tasks nil "tasks" org-export-with-tasks) (:with-timestamps nil "<" org-export-with-timestamps) (:with-title nil "title" org-export-with-title) - (:with-todo-keywords nil "todo" org-export-with-todo-keywords)) + (:with-todo-keywords nil "todo" org-export-with-todo-keywords) + ;; Citations processing. + (:cite-export "CITE_EXPORT" nil org-cite-export-processors)) "Alist between export properties and ways to set them. The key of the alist is the property name, and the value is a list @@ -2988,6 +2992,10 @@ Return code as a string." (setq info (org-combine-plists info (org-export-get-environment backend subtreep ext-plist))) + ;; Pre-process citations environment, i.e. install + ;; bibliography list, and citation processor in INFO. + (org-cite-store-bibliography info) + (org-cite-store-export-processor info) ;; De-activate uninterpreted data from parsed keywords. (dolist (entry (append (org-export-get-all-options backend) org-export-options-alist)) @@ -3021,6 +3029,11 @@ Return code as a string." ;; Now tree is complete, compute its properties and add them ;; to communication channel. (setq info (org-export--collect-tree-properties tree info)) + ;; Process citations and bibliography. Replace each citation + ;; and "print_bibliography" keyword in the parse tree with + ;; the output of the selected citation export processor. + (org-cite-process-citations info) + (org-cite-process-bibliography info) ;; Eventually transcode TREE. Wrap the resulting string into ;; a template. (let* ((body (org-element-normalize-string @@ -3033,16 +3046,19 @@ Return code as a string." (funcall inner-template body info)) info)) (template (cdr (assq 'template - (plist-get info :translate-alist))))) + (plist-get info :translate-alist)))) + (output + (if (or (not (functionp template)) body-only) full-body + (funcall template full-body info)))) + ;; Call citation export finalizer. + (setq output (org-cite-finalize-export output info)) ;; Remove all text properties since they cannot be ;; retrieved from an external process. Finally call ;; final-output filter and return result. (org-no-properties (org-export-filter-apply-functions (plist-get info :filter-final-output) - (if (or (not (functionp template)) body-only) full-body - (funcall template full-body info)) - info)))))))) + output info)))))))) ;;;###autoload (defun org-export-string-as (string backend &optional body-only ext-plist) |