Export pdfview link types to links with file relative paths

This commit is contained in:
Gerard Vermeulen 2022-02-16 07:01:42 +01:00
parent 5a7fba5ee2
commit f04fe6f2a5

View File

@ -1422,13 +1422,15 @@ this document to =html= and LaTeX correctly.
:store #'org-pdfview-store-link)
(defun org-pdfview-export (link description backend _)
"Export a \"pdfview\" type link."
"Export a \"pdfview\" type link.
The paths of the links export as file relative paths in order to
facilate moving single directories or whole directory trees."
(let ((path (if (string-match "\\(.+\\)::.+" link)
(match-string 1 link)
link))
(desc (or description link)))
(when (stringp path)
(setq path (expand-file-name path))
(setq path (file-relative-name path))
(pcase backend
(`html (format "<a href=\"%s\">%s</a>" path desc))
(`latex (format "\\href{%s}{%s}" path desc))