Browse Source

ox-ascii: Handle custom export functions for links

* lisp/ox-ascii.el (org-ascii-link): Obey to export function provided
  through `org-add-link-type'.
(org-ascii--describe-links): Do not turn links above into notes.
Nicolas Goaziou 10 years ago
parent
commit
8b0823b3e0
1 changed files with 23 additions and 10 deletions
  1. 23 10
      lisp/ox-ascii.el

+ 23 - 10
lisp/ox-ascii.el

@@ -926,6 +926,13 @@ channel."
 	;; any description: destination is already visible in the
 	;; paragraph.
 	((not (org-element-contents link)) nil)
+	;; Do not add a link already handled by custom export
+	;; functions.
+	((let ((protocol (nth 2 (assoc type org-link-protocols)))
+	       (path (org-element-property :path link)))
+	   (and (functionp protocol)
+		(funcall protocol (org-link-unescape path) anchor 'ascii)))
+	 nil)
 	(t
 	 (concat
 	  (org-ascii--fill-string
@@ -1509,8 +1516,7 @@ CONTENTS is nil.  INFO is a plist holding contextual
 
 DESC is the description part of the link, or the empty string.
 INFO is a plist holding contextual information."
-  (let ((raw-link (org-element-property :raw-link link))
-	(type (org-element-property :type link)))
+  (let ((type (org-element-property :type link)))
     (cond
      ((string= type "coderef")
       (let ((ref (org-element-property :path link)))
@@ -1529,17 +1535,24 @@ INFO is a plist holding contextual information."
 		   (org-export-get-ordinal
 		    destination info nil 'org-ascii--has-caption-p)))
 	      (if number
-		(if (atom number) (number-to-string number)
-		  (mapconcat #'number-to-string number "."))
+		  (if (atom number) (number-to-string number)
+		    (mapconcat #'number-to-string number "."))
 		;; Unnumbered headline.
 		(when (eq 'headline (org-element-type destination))
-		  (format "[%s]" (org-export-data
-				  (org-element-property :title destination) info)))))))))
+		  (format "[%s]"
+			  (org-export-data
+			   (org-element-property :title destination)
+			   info)))))))))
+     ((let ((protocol (nth 2 (assoc type org-link-protocols)))
+	    (path (org-element-property :path link)))
+	(and (functionp protocol)
+	     (funcall protocol (org-link-unescape path) desc 'ascii))))
      (t
-      (if (not (org-string-nw-p desc)) (format "[%s]" raw-link)
-	(concat (format "[%s]" desc)
-		(and (not (plist-get info :ascii-links-to-notes))
-		     (format " (%s)" raw-link))))))))
+      (let ((raw-link (org-element-property :raw-link link)))
+	(if (not (org-string-nw-p desc)) (format "[%s]" raw-link)
+	  (concat (format "[%s]" desc)
+		  (and (not (plist-get info :ascii-links-to-notes))
+		       (format " (%s)" raw-link)))))))))
 
 
 ;;;; Node Properties