Function: org-export-with-backend

org-export-with-backend is a byte-compiled function defined in ox.el.gz.

Signature

(org-export-with-backend BACKEND DATA &optional CONTENTS INFO)

Documentation

Call a transcoder from BACKEND on DATA.

BACKEND is an export back-end, as returned by, e.g., org-export-create-backend, or a symbol referring to a registered back-end. DATA is an Org element, object, secondary string or string. CONTENTS, when non-nil, is the transcoded contents of DATA element, as a string. INFO, when non-nil, is the communication channel used for export, as a plist.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
;;;; For Derived Back-ends
;;
;; `org-export-with-backend' is a function allowing to locally use
;; another back-end to transcode some object or element.  In a derived
;; back-end, it may be used as a fall-back function once all specific
;; cases have been treated.

(defun org-export-with-backend (backend data &optional contents info)
  "Call a transcoder from BACKEND on DATA.
BACKEND is an export back-end, as returned by, e.g.,
`org-export-create-backend', or a symbol referring to
a registered back-end.  DATA is an Org element, object, secondary
string or string.  CONTENTS, when non-nil, is the transcoded
contents of DATA element, as a string.  INFO, when non-nil, is
the communication channel used for export, as a plist."
  (when (symbolp backend) (setq backend (org-export-get-backend backend)))
  (org-export-barf-if-invalid-backend backend)
  (let ((type (org-element-type data)))
    (when (memq type '(nil org-data raw))
      (error "No foreign transcoder available"))
    (let* ((all-transcoders (org-export-get-all-transcoders backend))
	   (transcoder (cdr (assq type all-transcoders))))
      (unless (functionp transcoder) (error "No foreign transcoder available"))
      (let ((new-info
	     (org-combine-plists
	      info (list
		    :back-end backend
		    :translate-alist all-transcoders
		    :exported-data (make-hash-table :test #'eq :size 401)))))
	;; `:internal-references' are shared across back-ends.
	(prog1 (if (eq type 'plain-text)
		   (funcall transcoder data new-info)
		 (funcall transcoder data contents new-info))
	  (plist-put info :internal-references
		     (plist-get new-info :internal-references)))))))