org-export: Fix footnotes bug in ODT export
* contrib/lisp/org-export.el (org-export-as): Reorder actions taken to fix footnotes bug in ODT export.
This commit is contained in:
parent
8453ac1bf3
commit
2ff3da0f1a
|
@ -2078,49 +2078,58 @@ to be expanded and Babel code to be executed.
|
||||||
Return code as a string."
|
Return code as a string."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(save-restriction
|
(save-restriction
|
||||||
;; Narrow buffer to an appropriate region for parsing.
|
(let (info tree)
|
||||||
|
;; Narrow buffer to an appropriate region or subtree for
|
||||||
|
;; parsing. If parsing subtree, be sure to remove main
|
||||||
|
;; headline too.
|
||||||
(cond ((org-region-active-p)
|
(cond ((org-region-active-p)
|
||||||
(narrow-to-region (region-beginning) (region-end)))
|
(narrow-to-region (region-beginning) (region-end)))
|
||||||
(subtreep (org-narrow-to-subtree)))
|
(subtreep
|
||||||
;; Retrieve export options (INFO) and parsed tree (RAW-DATA),
|
(org-narrow-to-subtree)
|
||||||
;; Then options can be completed with tree properties. Note:
|
|
||||||
;; Buffer isn't parsed directly. Instead, a temporary copy is
|
|
||||||
;; created, where include keywords are expanded and code blocks
|
|
||||||
;; are evaluated. RAW-DATA is the parsed tree of the buffer
|
|
||||||
;; resulting from that process. Eventually call
|
|
||||||
;; `org-export-filter-parse-tree-functions'.
|
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(let ((info (org-export-get-environment backend subtreep ext-plist))
|
(forward-line)
|
||||||
;; Save original file name or buffer in order to properly
|
(narrow-to-region (point) (point-max))))
|
||||||
;; resolve babel block expansion when body is outside
|
;; 1. Get export environment and tree. Environment is
|
||||||
;; scope.
|
;; relative to the buffer being parsed, which isn't always
|
||||||
(buf (or (buffer-file-name (buffer-base-buffer)) (current-buffer))))
|
;; the original one, depending on the NOEXPAND value.
|
||||||
;; Remove subtree's headline from contents if subtree mode is
|
(if noexpand
|
||||||
;; activated.
|
;; If NOEXPAND is non-nil, simply parse current visible
|
||||||
(when subtreep (forward-line) (narrow-to-region (point) (point-max)))
|
;; part of buffer and retrieve environment from original
|
||||||
;; Install filters in communication channel.
|
;; buffer.
|
||||||
(setq info (org-export-install-filters backend info))
|
(setq info (org-export-get-environment backend subtreep ext-plist)
|
||||||
(let ((raw-data
|
tree (org-element-parse-buffer nil visible-only))
|
||||||
(org-export-filter-apply-functions
|
;; Otherwise, buffer isn't parsed directly. Instead,
|
||||||
(plist-get info :filter-parse-tree)
|
;; a temporary copy is created, where include keywords are
|
||||||
;; If NOEXPAND is non-nil, simply parse current
|
;; expanded and code blocks are evaluated. Environment is
|
||||||
;; visible part of buffer.
|
;; retrieved from that buffer. Moreover, save original file
|
||||||
(if noexpand (org-element-parse-buffer nil visible-only)
|
;; name or buffer in order to properly resolve babel block
|
||||||
|
;; expansion when body is outside scope.
|
||||||
|
(let ((buf (or (buffer-file-name (buffer-base-buffer))
|
||||||
|
(current-buffer))))
|
||||||
(org-export-with-current-buffer-copy
|
(org-export-with-current-buffer-copy
|
||||||
(org-export-expand-include-keyword)
|
(org-export-expand-include-keyword)
|
||||||
(let ((org-current-export-file buf))
|
(let ((org-current-export-file buf))
|
||||||
(org-export-blocks-preprocess))
|
(org-export-blocks-preprocess))
|
||||||
(org-element-parse-buffer nil visible-only)))
|
(setq info (org-export-get-environment backend subtreep ext-plist)
|
||||||
backend info)))
|
tree (org-element-parse-buffer nil visible-only)))))
|
||||||
;; Complete communication channel with tree properties.
|
;; 2. Install user's and developer's filters in communication
|
||||||
|
;; channel. Then call parse-tree filters to get the final
|
||||||
|
;; tree.
|
||||||
|
(setq info (org-export-install-filters backend info))
|
||||||
|
(setq tree
|
||||||
|
(org-export-filter-apply-functions
|
||||||
|
(plist-get info :filter-parse-tree) tree backend info))
|
||||||
|
;; 3. Now tree is complete, compute its properties and add
|
||||||
|
;; them to communication channel.
|
||||||
(setq info
|
(setq info
|
||||||
(org-combine-plists
|
(org-combine-plists
|
||||||
info
|
info
|
||||||
(org-export-collect-tree-properties raw-data info backend)))
|
(org-export-collect-tree-properties tree info backend)))
|
||||||
;; Transcode RAW-DATA. Also call
|
;; 4. Eventually transcode TREE. Wrap the resulting string
|
||||||
;; `org-export-filter-final-output-functions'.
|
;; into a template, if required. Eventually call
|
||||||
|
;; final-output filter.
|
||||||
(let* ((body (org-element-normalize-string
|
(let* ((body (org-element-normalize-string
|
||||||
(org-export-data raw-data backend info)))
|
(org-export-data tree backend info)))
|
||||||
(template (intern (format "org-%s-template" backend)))
|
(template (intern (format "org-%s-template" backend)))
|
||||||
(output (org-export-filter-apply-functions
|
(output (org-export-filter-apply-functions
|
||||||
(plist-get info :filter-final-output)
|
(plist-get info :filter-final-output)
|
||||||
|
@ -2129,7 +2138,7 @@ Return code as a string."
|
||||||
backend info)))
|
backend info)))
|
||||||
;; Maybe add final OUTPUT to kill ring, then return it.
|
;; Maybe add final OUTPUT to kill ring, then return it.
|
||||||
(when org-export-copy-to-kill-ring (org-kill-new output))
|
(when org-export-copy-to-kill-ring (org-kill-new output))
|
||||||
output))))))
|
output)))))
|
||||||
|
|
||||||
(defun org-export-to-buffer
|
(defun org-export-to-buffer
|
||||||
(backend buffer &optional subtreep visible-only body-only ext-plist noexpand)
|
(backend buffer &optional subtreep visible-only body-only ext-plist noexpand)
|
||||||
|
|
Loading…
Reference in New Issue