branch: externals/denote commit 9f91b9b6a9d1269f3f009e6e99e5299253be1b0e Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Revise how denote-link-ol-export converts links to files in HTML The previous design assumed that every file that is linked to will get an ".html" extension. But this is not correct, such as with PDF files. Thanks to Morten Kjeldgaard for reporting the bug in issue 614: <https://github.com/protesilaos/denote/issues/614>. --- README.org | 16 ++++++++-------- denote.el | 13 +++++++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.org b/README.org index e1275ba6a3..871c2f02a5 100644 --- a/README.org +++ b/README.org @@ -6391,14 +6391,14 @@ Denote is meant to be a collective effort. Every bit of help matters. Friesen, Jonathan Sahar, Johan Bolmsjö, Jonas Großekathöfer, Jousimies, Juanjo Presa, Julian Hoch, Kai von Fintel, Kaushal Modi, Kolmas, Lukas C. Bossert, M. Hadi Timachi, Maikol Solis, Mark Olson, - Mirko Hernandez, Niall Dooley, Nick Bell, Oliver Epper, Paul van - Gelder, Peter Prevos, Peter Smith, Riccardo Giannitrapani, Samuel W. - Flint, Sergio Rey, Suhail Singh, Shreyas Ragavan, Stefan Thesing, - Summer Emacs, Sven Seebeck, Taoufik, TJ Stankus, Vick (VicZz), - Viktor Haag, Vineet C. Kulkarni, Wade Mealing, Wilf, Yi Liu, Ypot, - atanasj, azegas, babusri, bdillahu, coherentstate, doolio, duli, - drcxd, elge70, elliottw, fingerknight, hpgisler, - hyperfocus1337,johkneisl, jtpavlock, juh, leafarbelm, + Mirko Hernandez, Morten Kjeldgaard, Niall Dooley, Nick Bell, Oliver + Epper, Paul van Gelder, Peter Prevos, Peter Smith, Riccardo + Giannitrapani, Samuel W. Flint, Sergio Rey, Suhail Singh, Shreyas + Ragavan, Stefan Thesing, Summer Emacs, Sven Seebeck, Taoufik, TJ + Stankus, Vick (VicZz), Viktor Haag, Vineet C. Kulkarni, Wade + Mealing, Wilf, Yi Liu, Ypot, atanasj, azegas, babusri, bdillahu, + coherentstate, doolio, duli, drcxd, elge70, elliottw, fingerknight, + hpgisler, hyperfocus1337,johkneisl, jtpavlock, juh, leafarbelm, mentalisttraceur, mjkalyan, pRot0ta1p, rbenit68, relict007, sarcom-sar, sienic, skissue, sundar bp, yetanotherfossman, zadca123 diff --git a/denote.el b/denote.el index 1c0a6feae1..6f43e3a9c1 100644 --- a/denote.el +++ b/denote.el @@ -6410,22 +6410,27 @@ Also see the user option `denote-org-store-link-to-heading'." (concat "denote:" file-id)))) org-store-link-plist)))) + (defun denote-link--ol-export-get-relative-html (path) + "Return relative PATH for Org export purposes. +Add an .html extension if PATH is an Org file." + (file-relative-name + (if (string= (file-name-extension path) "org") + (concat (file-name-sans-extension path) ".html") + path))) + ;;;###autoload (defun denote-link-ol-export (link description format) "Export a `denote:' link from Org files. The LINK, DESCRIPTION, and FORMAT are handled by the export backend." (pcase-let* ((`(,path ,query ,file-search) (denote-link--ol-resolve-link-to-target link :full-data)) - (anchor (when path (file-relative-name (file-name-sans-extension path)))) (desc (cond (description) (file-search (format "denote:%s::%s" query file-search)) (t (concat "denote:" query))))) (if path (pcase format - ('html (if file-search - (format "<a href=\"%s.html%s\">%s</a>" anchor file-search desc) - (format "<a href=\"%s.html\">%s</a>" anchor desc))) + ('html (format "<a href=\"%1$s%3$s\">%2$s</a>" (denote-link--ol-export-get-relative-html path) desc (or file-search ""))) ('latex (format "\\href{%s}{%s}" (replace-regexp-in-string "[\\{}$%&_#~^]" "\\\\\\&" path) desc)) ('texinfo (format "@uref{%s,%s}" path desc)) ('ascii (format "[%s] <denote:%s>" desc path))