~bzg/org-mode

72b0e9ff0460aa1d2c734a6d22d970c9942fa188 — Ihor Radchenko 3 months ago b0c3c90
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/
7 files changed, 25 insertions(+), 19 deletions(-)

M etc/ORG-NEWS
M lisp/ox-html.el
M lisp/ox-latex.el
M lisp/ox-man.el
M lisp/ox-md.el
M lisp/ox-odt.el
M lisp/ox-texinfo.el
M etc/ORG-NEWS => etc/ORG-NEWS +18 -0
@@ 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

M lisp/ox-html.el => lisp/ox-html.el +1 -3
@@ 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

M lisp/ox-latex.el => lisp/ox-latex.el +1 -3
@@ 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))

M lisp/ox-man.el => lisp/ox-man.el +1 -3
@@ 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))

M lisp/ox-md.el => lisp/ox-md.el +1 -3
@@ 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))

M lisp/ox-odt.el => lisp/ox-odt.el +2 -4
@@ 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)))))

M lisp/ox-texinfo.el => lisp/ox-texinfo.el +1 -3
@@ 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)