|
@@ -2091,7 +2091,11 @@ Return code as a string."
|
|
|
;; resulting from that process. Eventually call
|
|
|
;; `org-export-filter-parse-tree-functions'.
|
|
|
(goto-char (point-min))
|
|
|
- (let ((info (org-export-get-environment backend subtreep ext-plist)))
|
|
|
+ (let ((info (org-export-get-environment backend subtreep ext-plist))
|
|
|
+ ;; Save original file name or buffer in order to properly
|
|
|
+ ;; resolve babel block expansion when body is outside
|
|
|
+ ;; scope.
|
|
|
+ (buf (or (buffer-file-name (buffer-base-buffer)) (current-buffer))))
|
|
|
;; Remove subtree's headline from contents if subtree mode is
|
|
|
;; activated.
|
|
|
(when subtreep (forward-line) (narrow-to-region (point) (point-max)))
|
|
@@ -2105,28 +2109,28 @@ Return code as a string."
|
|
|
(if noexpand (org-element-parse-buffer nil visible-only)
|
|
|
(org-export-with-current-buffer-copy
|
|
|
(org-export-expand-include-keyword)
|
|
|
- (let ((org-current-export-file (current-buffer)))
|
|
|
+ (let ((org-current-export-file buf))
|
|
|
(org-export-blocks-preprocess))
|
|
|
(org-element-parse-buffer nil visible-only)))
|
|
|
backend info)))
|
|
|
- ;; Complete communication channel with tree properties.
|
|
|
- (setq info
|
|
|
- (org-combine-plists
|
|
|
- info
|
|
|
- (org-export-collect-tree-properties raw-data info backend)))
|
|
|
- ;; Transcode RAW-DATA. Also call
|
|
|
- ;; `org-export-filter-final-output-functions'.
|
|
|
- (let* ((body (org-element-normalize-string
|
|
|
- (org-export-data raw-data backend info)))
|
|
|
- (template (intern (format "org-%s-template" backend)))
|
|
|
- (output (org-export-filter-apply-functions
|
|
|
- (plist-get info :filter-final-output)
|
|
|
- (if (or (not (fboundp template)) body-only) body
|
|
|
- (funcall template body info))
|
|
|
- backend info)))
|
|
|
- ;; Maybe add final OUTPUT to kill ring before returning it.
|
|
|
- (when org-export-copy-to-kill-ring (org-kill-new output))
|
|
|
- output))))))
|
|
|
+ ;; Complete communication channel with tree properties.
|
|
|
+ (setq info
|
|
|
+ (org-combine-plists
|
|
|
+ info
|
|
|
+ (org-export-collect-tree-properties raw-data info backend)))
|
|
|
+ ;; Transcode RAW-DATA. Also call
|
|
|
+ ;; `org-export-filter-final-output-functions'.
|
|
|
+ (let* ((body (org-element-normalize-string
|
|
|
+ (org-export-data raw-data backend info)))
|
|
|
+ (template (intern (format "org-%s-template" backend)))
|
|
|
+ (output (org-export-filter-apply-functions
|
|
|
+ (plist-get info :filter-final-output)
|
|
|
+ (if (or (not (fboundp template)) body-only) body
|
|
|
+ (funcall template body info))
|
|
|
+ backend info)))
|
|
|
+ ;; Maybe add final OUTPUT to kill ring, then return it.
|
|
|
+ (when org-export-copy-to-kill-ring (org-kill-new output))
|
|
|
+ output))))))
|
|
|
|
|
|
(defun org-export-to-buffer
|
|
|
(backend buffer &optional subtreep visible-only body-only ext-plist noexpand)
|