Function: org-export--prune-tree
org-export--prune-tree is a byte-compiled function defined in
ox.el.gz.
Signature
(org-export--prune-tree DATA INFO)
Documentation
Prune non exportable elements from DATA.
DATA is the parse tree to traverse. INFO is the plist holding export info. Also set :ignore-list in INFO to a list of objects which should be ignored during export, but not removed from tree.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(defun org-export--prune-tree (data info)
"Prune non exportable elements from DATA.
DATA is the parse tree to traverse. INFO is the plist holding
export info. Also set `:ignore-list' in INFO to a list of
objects which should be ignored during export, but not removed
from tree."
(letrec ((ignore nil)
;; First find trees containing a select tag, if any.
(selected (org-export--selected-trees data info))
;; List tags that prevent export of headlines.
(excluded (cl-mapcan (lambda (tag) (org-tags-expand tag t))
(plist-get info :exclude-tags)))
(walk-data
(lambda (data)
;; Prune non-exportable elements and objects from tree.
;; As a special case, special rows and cells from tables
;; are stored in IGNORE, as they still need to be
;; accessed during export.
(when data
(let ((type (org-element-type data)))
(if (org-export--skip-p data info selected excluded)
(if (memq type '(table-cell table-row)) (push data ignore)
(org-element-extract-element data))
(if (and (eq type 'headline)
(eq (plist-get info :with-archived-trees)
'headline)
(org-element-property :archivedp data))
;; If headline is archived but tree below has
;; to be skipped, remove contents.
(org-element-set-contents data)
;; Move into recursive objects/elements.
(mapc walk-data (org-element-contents data)))
;; Move into secondary string, if any.
(dolist (p (cdr (assq type
org-element-secondary-value-alist)))
(mapc walk-data (org-element-property p data))))))))
(definitions
;; Collect definitions before possibly pruning them so as
;; to avoid parsing them again if they are required.
(org-element-map data '(footnote-definition footnote-reference)
(lambda (f)
(cond
((eq 'footnote-definition (org-element-type f)) f)
((and (eq 'inline (org-element-property :type f))
(org-element-property :label f))
f)
(t nil))))))
;; If a select tag is active, also ignore the section before the
;; first headline, if any.
(when selected
(let ((first-element (car (org-element-contents data))))
(when (eq (org-element-type first-element) 'section)
(org-element-extract-element first-element))))
;; Prune tree and communication channel.
(funcall walk-data data)
(dolist (entry (append
;; Priority is given to back-end specific options.
(org-export-get-all-options (plist-get info :back-end))
org-export-options-alist))
(when (eq (nth 4 entry) 'parse)
(funcall walk-data (plist-get info (car entry)))))
(let ((missing (org-export--missing-definitions data definitions)))
(funcall walk-data missing)
(org-export--install-footnote-definitions missing data))
;; Eventually set `:ignore-list'.
(plist-put info :ignore-list ignore)))