From 1b0b331f92abc1ca7e04f71fe7ff60da57c719b8 Mon Sep 17 00:00:00 2001 Message-ID: <1b0b331f92abc1ca7e04f71fe7ff60da57c719b8.1721815865.git.yantar92@posteo.net> In-Reply-To: <540c8ef21c26df79cf48f58afb4e88130985e2f7.1721815865.git.yantar92@posteo.net> References: <540c8ef21c26df79cf48f58afb4e88130985e2f7.1721815865.git.yantar92@posteo.net> From: Ihor Radchenko Date: Wed, 24 Jul 2024 11:51:21 +0200 Subject: [PATCH 2/3] org-export-as: Allow the return value to be a list of strings; add INFO * lisp/ox.el (org-export-as): Allow the transcoders to return list of strings and return it. When returning a string, put INFO plist as text property. Do not remove text properties assigned by the transcoders. (org-export-data): Document that list of strings may be returned. --- lisp/ox.el | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index bdee71082..a76b3b353 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1930,7 +1930,7 @@ (defun org-export-data (data info) The `:filter-parse-tree' filters are not applied. -Return a string." +Return a string or a list of strings." (or (gethash data (plist-get info :exported-data)) ;; Handle broken links according to ;; `org-export-with-broken-links'. @@ -2969,7 +2969,9 @@ (defun org-export-as with external parameters overriding Org default settings, but still inferior to file-local settings. -Return code as a string." +Return code as a string or a list of strings. +The returned strings will have their `org-export-info' property set to +export information channel." (when (symbolp backend) (setq backend (org-export-get-backend backend))) (org-export-barf-if-invalid-backend backend) (org-fold-core-ignore-modifications @@ -3009,15 +3011,25 @@ (defun org-export-as (let ((output (or (org-export-data (plist-get info :parse-tree) info) ""))) + (setq output (ensure-list output)) ;; Call citation export finalizer. (when (plist-get info :with-cite-processors) - (setq output (org-cite-finalize-export output info))) + (setq output + (mapcar + (lambda (o) (org-cite-finalize-export o info)) + output))) (let ((filters (plist-get info :filter-final-output))) - ;; 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 filters output info)))))))))) + ;; Call final-output filter and return result. + (setq output + (mapcar + (lambda (o) (org-export-filter-apply-functions filters o info)) + output))) + ;; Apply org-export-info property. + (setq output + (mapcar + (lambda (o) (org-add-props o nil 'org-export-info info)) + output)) + (if (length= output 1) (car output) output)))))))) (defun org-export-transcode-org-data (_ body info) "Transcode `org-data' node with BODY. Return transcoded string. -- 2.45.2