Function: org-export-as
org-export-as is an autoloaded and byte-compiled function defined in
ox.el.gz.
Signature
(org-export-as BACKEND &optional SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST)
Documentation
Transcode current Org buffer into BACKEND code.
See info node (org)Advanced Export Configuration for the details of the transcoding process.
BACKEND is either an export backend, as returned by, e.g.,
org-export-create-backend, or a symbol referring to
a registered backend.
If narrowing is active in the current buffer, only transcode its narrowed part.
If a region is active, transcode that region.
When optional argument SUBTREEP is non-nil, transcode the sub-tree at point, extracting information from the headline properties first.
When optional argument VISIBLE-ONLY is non-nil, don't export contents of hidden elements.
When optional argument BODY-ONLY is non-nil, only return body code, without surrounding template.
Optional argument EXT-PLIST, when provided, is a property list with external parameters overriding Org default settings, but still inferior to file-local settings.
Return code as a string.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
;;;###autoload
(defun org-export-as
(backend &optional subtreep visible-only body-only ext-plist)
"Transcode current Org buffer into BACKEND code.
See info node `(org)Advanced Export Configuration' for the details of
the transcoding process.
BACKEND is either an export backend, as returned by, e.g.,
`org-export-create-backend', or a symbol referring to
a registered backend.
If narrowing is active in the current buffer, only transcode its
narrowed part.
If a region is active, transcode that region.
When optional argument SUBTREEP is non-nil, transcode the
sub-tree at point, extracting information from the headline
properties first.
When optional argument VISIBLE-ONLY is non-nil, don't export
contents of hidden elements.
When optional argument BODY-ONLY is non-nil, only return body
code, without surrounding template.
Optional argument EXT-PLIST, when provided, is a property list
with external parameters overriding Org default settings, but
still inferior to file-local settings.
Return code as a string."
(when (symbolp backend) (setq backend (org-export-get-backend backend)))
(org-export-barf-if-invalid-backend backend)
(org-fold-core-ignore-modifications
(save-excursion
(save-restriction
;; Narrow buffer to an appropriate region or subtree for
;; parsing. If parsing subtree, be sure to remove main
;; headline, planning data and property drawer.
(cond ((org-region-active-p)
(narrow-to-region (region-beginning) (region-end)))
(subtreep
(org-narrow-to-subtree)
(goto-char (point-min))
(org-end-of-meta-data)
;; Make the region include top heading in the subtree.
;; This way, we will be able to retrieve its export
;; options when calling
;; `org-export--get-subtree-options'.
(when (bolp) (backward-char))
(narrow-to-region (point) (point-max))))
;; Initialize communication channel with original buffer
;; attributes, unavailable in its copy.
(let* ((org-export-current-backend (org-export-backend-name backend))
(info (org-combine-plists
(org-export--get-export-attributes
backend subtreep visible-only body-only)
(org-export--get-buffer-attributes))))
;; Update communication channel and get parse tree. Buffer
;; isn't parsed directly. Instead, all buffer modifications
;; and consequent parsing are undertaken in a temporary copy.
(org-export-with-buffer-copy
(font-lock-mode -1)
(setq info (org-export--annotate-info
backend info subtreep visible-only ext-plist))
;; Eventually transcode TREE. Wrap the resulting string into
;; a template.
(let* ((body (org-element-normalize-string
(or (org-export-data (plist-get info :parse-tree) info)
"")))
(inner-template (cdr (assq 'inner-template
(plist-get info :translate-alist))))
(full-body (org-export-filter-apply-functions
(plist-get info :filter-body)
(if (not (functionp inner-template)) body
(funcall inner-template body info))
info))
(template (cdr (assq 'template
(plist-get info :translate-alist))))
(output
(if (or (not (functionp template)) body-only) full-body
(funcall template full-body info))))
;; Call citation export finalizer.
(when (plist-get info :with-cite-processors)
(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)
output info)))))))))