ox: Handle failure to localize link

* lisp/ox.el (org-export-link-localise): When no local copy of the link
resource could be fetched, produce a warning message and do nothing
instead of setting the link :path to nil.
This commit is contained in:
TEC 2022-12-10 21:36:58 +08:00 committed by Ihor Radchenko
parent 47bcdce19b
commit 0db972ad63
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 11 additions and 6 deletions

View File

@ -4612,12 +4612,17 @@ If LINK refers to a remote resource, modify it to point to a local
downloaded copy. Otherwise, return unchanged LINK."
(when (org-export-link-remote-p link)
(let* ((local-path (org-export-link--remote-local-copy link)))
(setcdr link
(thread-first (cadr link)
(plist-put :type "file")
(plist-put :path local-path)
(plist-put :raw-link (concat "file:" local-path))
list))))
(if local-path
(setcdr link
(thread-first (cadr link)
(plist-put :type "file")
(plist-put :path local-path)
(plist-put :raw-link (concat "file:" local-path))
list))
(display-warning
'(org export)
(format "unable to obtain local copy of %s"
(org-element-property :raw-link link))))))
link)
;;;; For References