From ba3fb5be9f71c66baf8ca1c22ef21cbe7c7df0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Sun, 20 Apr 2025 11:18:34 +0100 Subject: [PATCH] Stop org-mode export adding file:// to relative links --- config.org | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/config.org b/config.org index 57533fd..35d51e6 100644 --- a/config.org +++ b/config.org @@ -548,6 +548,21 @@ Export external links as ~target= “_blank”~, from [[https://emacs.stackexcha 'my-org-export-add-target-blank-to-http-links) #+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 **** =org-agenda-property=