Function: org-texinfo-link

org-texinfo-link is a byte-compiled function defined in ox-texinfo.el.gz.

Signature

(org-texinfo-link LINK DESC INFO)

Documentation

Transcode a LINK object from Org to Texinfo.

DESC is the description part of the link, or the empty string. INFO is a plist holding contextual information. See org-export-data.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-texinfo.el.gz
(defun org-texinfo-link (link desc info)
  "Transcode a LINK object from Org to Texinfo.
DESC is the description part of the link, or the empty string.
INFO is a plist holding contextual information.  See
`org-export-data'."
  (let* ((type (org-element-property :type link))
	 (raw-path (org-element-property :path link))
	 ;; Ensure DESC really exists, or set it to nil.
	 (desc (and (not (string= desc "")) desc))
	 (path (org-texinfo--sanitize-content
		(cond
		 ((string-equal type "file")
		  (org-export-file-uri 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)
      (org-texinfo--inline-image link info))
     ((equal type "radio")
      (let ((destination (org-export-resolve-radio-link link info)))
	(if (not destination) desc
	  (org-texinfo--@ref destination desc info))))
     ((member type '("custom-id" "id" "fuzzy"))
      (let ((destination
	     (if (equal type "fuzzy")
		 (org-export-resolve-fuzzy-link link info)
	       (org-export-resolve-id-link link info))))
	(pcase (org-element-type destination)
	  (`nil
	   (format org-texinfo-link-with-unknown-path-format path))
	  ;; Id link points to an external file.
	  (`plain-text
	   (if desc (format "@uref{file://%s,%s}" destination desc)
	     (format "@uref{file://%s}" destination)))
	  ((or `headline
	       ;; Targets within headlines cannot be turned into
	       ;; @anchor{}, so we refer to the headline parent
	       ;; directly.
	       (and `target
		    (guard
		     (org-element-type-p
		      (org-element-parent destination)
                      'headline))))
	   (let ((headline (org-element-lineage destination 'headline t)))
	     (org-texinfo--@ref headline desc info)))
	  (_ (org-texinfo--@ref destination desc info)))))
     ((string= type "mailto")
      (format "@email{%s}"
	      (concat path (and desc (concat ", " desc)))))
     ;; External link with a description part.
     ((and path desc) (format "@uref{%s, %s}" path desc))
     ;; External link without a description part.
     (path (format "@uref{%s}" path))
     ;; No path, only description.  Try to do something useful.
     (t
      (format (plist-get info :texinfo-link-with-unknown-path-format) desc)))))