Function: org-export-insert-image-links
org-export-insert-image-links is a byte-compiled function defined in
ox.el.gz.
Signature
(org-export-insert-image-links DATA INFO &optional RULES)
Documentation
Insert image links in DATA.
Org syntax does not support nested links. Nevertheless, some export backends support images as descriptions of links. Since images are really links to image files, we need to make an exception about links nesting.
This function recognizes links whose contents are really images and turn them into proper nested links. It is meant to be used as a parse tree filter in backends supporting such constructs.
DATA is a parse tree. INFO is the current state of the export process, as a plist.
A description is a valid images if it matches any rule in RULES,
if non-nil, or org-export-default-inline-image-rule otherwise.
See org-export-inline-image-p for more information about the
structure of RULES.
Return modified DATA.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(defun org-export-insert-image-links (data info &optional rules)
"Insert image links in DATA.
Org syntax does not support nested links. Nevertheless, some
export backends support images as descriptions of links. Since
images are really links to image files, we need to make an
exception about links nesting.
This function recognizes links whose contents are really images
and turn them into proper nested links. It is meant to be used
as a parse tree filter in backends supporting such constructs.
DATA is a parse tree. INFO is the current state of the export
process, as a plist.
A description is a valid images if it matches any rule in RULES,
if non-nil, or `org-export-default-inline-image-rule' otherwise.
See `org-export-inline-image-p' for more information about the
structure of RULES.
Return modified DATA."
(let ((link-re (format "\\`\\(?:%s\\|%s\\)\\'"
org-link-plain-re
org-link-angle-re))
(case-fold-search t))
(org-element-map data 'link
(lambda (l)
(let ((contents (org-element-interpret-data (org-element-contents l))))
(when (and (org-string-nw-p contents)
(string-match link-re contents))
(let ((type (match-string 1 contents))
(path (match-string 2 contents)))
(when (cl-some (lambda (rule)
(and (string= type (car rule))
(string-match-p (cdr rule) path)))
(or rules org-export-default-inline-image-rule))
;; Replace contents with image link.
(org-element-adopt
(org-element-set-contents l)
(with-temp-buffer
(save-excursion (insert contents))
(org-element-link-parser))))))))
info nil nil t))
data)