diff --git a/lisp/ox.el b/lisp/ox.el index 21f632edf..f1c6640cc 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -4227,8 +4227,9 @@ Return modified DATA." (and (string= type (car rule)) (string-match-p (cdr rule) path))) (or rules org-export-default-inline-image-rule)) - (org-element-set-contents - l + ;; Replace contents with image link. + (org-element-adopt-elements + (org-element-set-contents l nil) (with-temp-buffer (save-excursion (insert contents)) (org-element-link-parser)))))))) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 9f4a8e5a1..ab1e536a7 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -2757,6 +2757,14 @@ Para2" (org-test-with-parsed-data "[[http://orgmode.org][file:image.png]]" (org-element-map (org-export-insert-image-links tree info) 'link (lambda (l) (org-element-property :type l)))))) + ;; Properly set `:parent' property when replace contents with image + ;; link. + (should + (memq 'link + (org-test-with-parsed-data "[[http://orgmode.org][file:image.png]]" + (org-element-map (org-export-insert-image-links tree info) 'link + (lambda (l) + (org-element-type (org-element-property :parent l))))))) ;; With optional argument RULES, recognize different links as ;; images. (should-not