Function: org-ascii-link

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

Signature

(org-ascii-link LINK DESC INFO)

Documentation

Transcode a LINK object from Org to ASCII.

DESC is the description part of the link, or the empty string. INFO is a plist holding contextual information.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-ascii.el.gz
;;;; Link

(defun org-ascii-link (link desc info)
  "Transcode a LINK object from Org to ASCII.

DESC is the description part of the link, or the empty string.
INFO is a plist holding contextual information."
  (let ((type (org-element-property :type link)))
    (cond
     ((org-export-custom-protocol-maybe link desc 'ascii info))
     ((string= type "coderef")
      (let ((ref (org-element-property :path link)))
	(format (org-export-get-coderef-format ref desc)
		(org-export-resolve-coderef ref info))))
     ;; Do not apply a special syntax on radio links.  Though, use
     ;; transcoded target's contents as output.
     ((string= type "radio") desc)
     ((member type '("custom-id" "fuzzy" "id"))
      (let ((destination (if (string= type "fuzzy")
			     (org-export-resolve-fuzzy-link link info)
			   (org-export-resolve-id-link link info))))
	(pcase (org-element-type destination)
	  ((guard desc)
	   (if (plist-get info :ascii-links-to-notes)
	       (format "[%s]" desc)
	     (concat desc
		     (format " (%s)"
			     (org-ascii--describe-datum destination info)))))
	  ;; External file.
	  (`plain-text destination)
	  (`headline
	   (if (org-export-numbered-headline-p destination info)
	       (mapconcat #'number-to-string
			  (org-export-get-headline-number destination info)
			  ".")
	     (org-export-data (org-element-property :title destination) info)))
	  ;; Handle enumerable elements and targets within them.
	  ((and (let number (org-export-get-ordinal
			     destination info nil #'org-ascii--has-caption-p))
		(guard number))
	   (if (atom number) (number-to-string number)
	     (mapconcat #'number-to-string number ".")))
	  ;; Don't know what to do.  Signal it.
	  (_ "???"))))
     (t
      (let ((path (org-element-property :raw-link link)))
	(if (not (org-string-nw-p desc)) (format "<%s>" path)
	  (concat (format "[%s]" desc)
		  (and (not (plist-get info :ascii-links-to-notes))
		       (format " (<%s>)" path)))))))))