Stop org-mode export adding file:// to relative links

This commit is contained in:
mez 2025-04-20 11:18:34 +01:00
parent b8890b0176
commit ba3fb5be9f

View file

@ -548,6 +548,21 @@ Export external links as ~target= “_blank”~, from [[https://emacs.stackexcha
'my-org-export-add-target-blank-to-http-links) 'my-org-export-add-target-blank-to-http-links)
#+END_SRC #+END_SRC
Get rid of =file://= using the same method.
#+BEGIN_SRC emacs-lisp
(defun my-org-export-correct-file-links (text backend info)
"Add target=\"_blank\" to external links."
(when (and
(org-export-derived-backend-p backend 'html)
(string-match "href=\"file[^\"]+" text))
(string-match "file://" text)
(replace-match "" nil nil text)))
(add-to-list 'org-export-filter-link-functions
'my-org-export-correct-file-links)
#+END_SRC
*** Packages *** Packages
**** =org-agenda-property= **** =org-agenda-property=