ox-odt: Fix regression when exporting file links after 72b0e9ff0

* lisp/ox-odt.el (org-odt-link--inline-image): Fix file path expansion
code.  Explicitly assert that the passed link must be a file
link (otherwise, the rest of the function logic does not make any
sense).
(org-odt-link): Remove special handling of http, https, ftp, and
mailto links, following the idea behind 72b0e9ff0.  Fix coderef link
handling - they must use raw coderef, not coderef:<ref>.

Reported-by: Fraga, Eric <e.fraga@ucl.ac.uk>
Link: https://orgmode.org/list/87r0f3ndvy.fsf@ucl.ac.uk
This commit is contained in:
Ihor Radchenko 2024-04-20 15:19:11 +03:00
parent 942a7320d0
commit 769018718c
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 9 additions and 10 deletions

View File

@ -2253,11 +2253,11 @@ SHORT-CAPTION are strings."
LINK is the link pointing to the inline image. INFO is a plist
used as a communication channel."
(cl-assert (org-element-type-p element 'link))
(let* ((src (let* ((type (org-element-property :type element))
(raw-path (org-element-property :path element)))
(cl-assert (equal "file" (org-element-property :type element)))
(let* ((src (let ((raw-path (org-element-property :path element)))
(cond ((file-name-absolute-p raw-path)
(expand-file-name raw-path))
(t (concat type ":" raw-path)))))
(t raw-path))))
(src-expanded (if (file-name-absolute-p src) src
(expand-file-name src (file-name-directory
(plist-get info :input-file)))))
@ -2682,8 +2682,6 @@ INFO is a plist holding contextual information. See
(imagep (org-export-inline-image-p
link (plist-get info :odt-inline-image-rules)))
(path (cond
((member type '("http" "https" "ftp" "mailto"))
(concat type ":" raw-path))
((string= type "file")
(let ((path-uri (org-export-file-uri raw-path)))
(if (string-prefix-p "file://" path-uri)
@ -2693,9 +2691,10 @@ INFO is a plist holding contextual information. See
;; archive. The directory containing the odt file
;; is "../".
(concat "../" path-uri))))
(t raw-path)))
(t (concat type ":" raw-path))))
;; Convert & to &amp; for correct XML representation
(path (replace-regexp-in-string "&" "&amp;" path)))
(path (replace-regexp-in-string "&" "&amp;" path))
(raw-path (replace-regexp-in-string "&" "&amp;" raw-path)))
(cond
;; Link type is handled by a special function.
((org-export-custom-protocol-maybe link desc 'odt info))
@ -2774,10 +2773,10 @@ INFO is a plist holding contextual information. See
;; Coderef: replace link with the reference name or the
;; equivalent line number.
((string= type "coderef")
(let* ((line-no (format "%d" (org-export-resolve-coderef path info)))
(href (concat "coderef-" path)))
(let* ((line-no (format "%d" (org-export-resolve-coderef raw-path info)))
(href (concat "coderef-" raw-path)))
(format
(org-export-get-coderef-format path desc)
(org-export-get-coderef-format raw-path desc)
(format
"<text:bookmark-ref text:reference-format=\"number\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
href line-no))))