Browse Source

Fix bug in ASCII export: correctly set the `type' variable.

* org-ascii.el (org-export-as-ascii): Fix bug in ASCII export:
  use `org-bracket-link-analytic-regexp++' to match the link
  type.
Bastien Guerry 14 years ago
parent
commit
86f4ef6d19
1 changed files with 8 additions and 9 deletions
  1. 8 9
      lisp/org-ascii.el

+ 8 - 9
lisp/org-ascii.el

@@ -311,7 +311,7 @@ publishing directory."
 		  :add-text (plist-get opt-plist :text))
 		  :add-text (plist-get opt-plist :text))
 		 "\n"))
 		 "\n"))
 	 thetoc have-headings first-heading-pos
 	 thetoc have-headings first-heading-pos
-	 table-open table-buffer link-buffer link desc desc0 rpl wrap fnc)
+	 table-open table-buffer link-buffer link type desc desc0 rpl wrap fnc)
     (let ((inhibit-read-only t))
     (let ((inhibit-read-only t))
       (org-unmodified
       (org-unmodified
        (remove-text-properties (point-min) (point-max)
        (remove-text-properties (point-min) (point-max)
@@ -347,7 +347,7 @@ publishing directory."
 
 
       (if (and (or author email)
       (if (and (or author email)
 	       org-export-author-info)
 	       org-export-author-info)
-	  (insert(concat (nth 1 lang-words) ": " (or author "")
+	  (insert (concat (nth 1 lang-words) ": " (or author "")
 			  (if (and org-export-email-info
 			  (if (and org-export-email-info
 				   email (string-match "\\S-" email))
 				   email (string-match "\\S-" email))
 			      (concat " <" email ">") "")
 			      (concat " <" email ">") "")
@@ -431,10 +431,11 @@ publishing directory."
       ;; Remove the quoted HTML tags.
       ;; Remove the quoted HTML tags.
       (setq line (org-html-expand-for-ascii line))
       (setq line (org-html-expand-for-ascii line))
       ;; Replace links with the description when possible
       ;; Replace links with the description when possible
-      (while (string-match org-bracket-link-regexp line)
-	(setq link (match-string 1 line)
-	      desc0 (match-string 3 line)
-	      desc (or desc0 (match-string 1 line)))
+      (while (string-match org-bracket-link-analytic-regexp++ line)
+	(setq link (concat (match-string 1 line) (match-string 3 line))
+	      type (match-string 1 line)
+	      desc0 (match-string 5 line)
+	      desc (or desc0 link))
 	(if (and (> (length link) 8)
 	(if (and (> (length link) 8)
 		 (equal (substring link 0 8) "coderef:"))
 		 (equal (substring link 0 8) "coderef:"))
 	    (setq line (replace-match
 	    (setq line (replace-match
@@ -443,9 +444,7 @@ publishing directory."
 				      (substring link 8)
 				      (substring link 8)
 				      org-export-code-refs)))
 				      org-export-code-refs)))
 			t t line))
 			t t line))
-	  (setq rpl (concat "["
-			    (or (match-string 3 line) (match-string 1 line))
-			    "]"))
+	  (setq rpl (concat "[" desc "]"))
 	  (if (functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
 	  (if (functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
 	      (setq rpl (or (save-match-data
 	      (setq rpl (or (save-match-data
 			      (funcall fnc (org-link-unescape path)
 			      (funcall fnc (org-link-unescape path)