org-export: Do not strip link type by default during export

* lisp/ox-html.el (org-html-link):
* lisp/ox-latex.el (org-latex-link):
* lisp/ox-man.el (org-man-link):
* lisp/ox-md.el (org-md-link):
* lisp/ox-odt.el (org-odt-link--inline-image):
* lisp/ox-texinfo.el (org-texinfo-link): Preserve link type during
export for all the links, not just for a hard-coded subset.
* etc/ORG-NEWS (Built-in HTML, LaTeX, Man, Markdown, ODT, and Texinfo
exporters preserve the link protocol during export): Document the
breaking change.

Link: https://list.orgmode.org/orgmode/878r9nofpw.fsf@localhost/
This commit is contained in:
Ihor Radchenko 2024-02-05 16:39:05 +01:00
parent b0c3c90574
commit 72b0e9ff04
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
7 changed files with 25 additions and 19 deletions

View File

@ -13,6 +13,24 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** Important announcements and breaking changes
*** Built-in HTML, LaTeX, Man, Markdown, ODT, and Texinfo exporters preserve the link protocol during export
Previously, some link types where not exported as =protocol:uri= but
as bare =uri=. This is now changed.
When a link is known by Org mode and does not have a custom ~:export~
parameter (see A.3 Adding Hyperlink Types section of the manual), the
link protocol is now not stripped.
For example, if one adds a link type =tel=, but does not define
~:export~ parameter
: (org-link-set-parameters "tel")
=[[tel:12345][John Doe]]= link will be correctly exported to LaTeX as
=\href{tel:12345}{John Doe}=, not =\href{12345}{John Doe}=.
However, links like =[[elisp:(+ 1 2)]]= will be exported as
=\url{elisp:(+ 1 2)}=, which may be somewhat unexpected.
*** When ~org-link-file-path-type~ is a function, its argument is now a filename as it is read by ~org-insert-link~; not an absolute path
Previously, when ~org-link-file-path-type~ is set to a function, the

View File

@ -3231,8 +3231,6 @@ INFO is a plist holding contextual information. See
(desc (org-string-nw-p desc))
(path
(cond
((member type '("http" "https" "ftp" "mailto" "news"))
(url-encode-url (concat type ":" raw-path)))
((string= "file" type)
;; During publishing, turn absolute file names belonging
;; to base directory into relative file names. Otherwise,
@ -3259,7 +3257,7 @@ INFO is a plist holding contextual information. See
(concat raw-path
"#"
(org-publish-resolve-external-link option path t))))))
(t raw-path)))
(t (url-encode-url (concat type ":" raw-path)))))
(attributes-plist
(org-combine-plists
;; Extract attributes from parent's paragraph. HACK: Only

View File

@ -2943,12 +2943,10 @@ INFO is a plist holding contextual information. See
link (plist-get info :latex-inline-image-rules)))
(path (org-latex--protect-text
(pcase type
((or "http" "https" "ftp" "mailto" "doi")
(concat type ":" raw-path))
("file"
(org-export-file-uri raw-path))
(_
raw-path)))))
(concat type ":" raw-path))))))
(cond
;; Link type is handled by a special function.
((org-export-custom-protocol-maybe link desc 'latex info))

View File

@ -615,10 +615,8 @@ INFO is a plist holding contextual information. See
;; Ensure DESC really exists, or set it to nil.
(desc (and (not (string= desc "")) desc))
(path (pcase type
((or "http" "https" "ftp" "mailto")
(concat type ":" raw-path))
("file" (org-export-file-uri raw-path))
(_ raw-path))))
(_ (concat type ":" raw-path)))))
(cond
;; Link type is handled by a special function.
((org-export-custom-protocol-maybe link desc 'man info))

View File

@ -544,11 +544,9 @@ INFO is a plist holding contextual information. See
(type (org-element-property :type link))
(raw-path (org-element-property :path link))
(path (cond
((member type '("http" "https" "ftp" "mailto"))
(concat type ":" raw-path))
((string-equal type "file")
(org-export-file-uri (funcall link-org-files-as-md raw-path)))
(t raw-path))))
(t (concat type ":" raw-path)))))
(cond
;; Link type is handled by a special function.
((org-export-custom-protocol-maybe link desc 'md info))

View File

@ -2246,11 +2246,9 @@ 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)))
(cond ((member type '("http" "https"))
(concat type ":" raw-path))
((file-name-absolute-p raw-path)
(cond ((file-name-absolute-p raw-path)
(expand-file-name raw-path))
(t raw-path))))
(t (concat type ":" raw-path)))))
(src-expanded (if (file-name-absolute-p src) src
(expand-file-name src (file-name-directory
(plist-get info :input-file)))))

View File

@ -1326,11 +1326,9 @@ INFO is a plist holding contextual information. See
(desc (and (not (string= desc "")) desc))
(path (org-texinfo--sanitize-content
(cond
((member type '("http" "https" "ftp"))
(concat type ":" raw-path))
((string-equal type "file")
(org-export-file-uri raw-path))
(t raw-path)))))
(t (concat type ":" raw-path))))))
(cond
((org-export-custom-protocol-maybe link desc 'texinfo info))
((org-export-inline-image-p link org-texinfo-inline-image-rules)