Quellcode durchsuchen

Fix bug with handling of targets in ASCII export.

Target text used to disappear, now it is kept as it should be.
Carsten Dominik vor 16 Jahren
Ursprung
Commit
c0a779bd9d
2 geänderte Dateien mit 14 neuen und 5 gelöschten Zeilen
  1. 7 0
      lisp/ChangeLog
  2. 7 5
      lisp/org-exp.el

+ 7 - 0
lisp/ChangeLog

@@ -1,3 +1,10 @@
+2008-11-26  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-exp.el (org-export-as-ascii): Remove the handling of
+	targets.
+	(org-export-ascii-preprocess): Handle targets already in this
+	function.
+
 2008-11-25  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-timer.el (org-timer-start-time): Define this variable.

+ 7 - 5
lisp/org-exp.el

@@ -2397,10 +2397,7 @@ underlined headlines.  The default is 3."
     (while (setq line (pop lines))
       ;; Remove the quoted HTML tags.
       (setq line (org-html-expand-for-ascii line))
-      ;; Remove targets
-      (while (string-match "<<<?[^<>]*>>>?[ \t]*\n?" line)
-	(setq line (replace-match "" t t line)))
-      ;; Replace internal links
+      ;; Replace links with the description when possible
       (while (string-match org-bracket-link-regexp line)
 	(setq line (replace-match
 		    (if (match-end 3) "[\\3]" "[\\1]")
@@ -2483,13 +2480,18 @@ underlined headlines.  The default is 3."
 
 (defun org-export-ascii-preprocess ()
   "Do extra work for ASCII export"
+  ;; Put quotes around verbatim text
   (goto-char (point-min))
   (while (re-search-forward org-verbatim-re nil t)
     (goto-char (match-end 2))
     (backward-delete-char 1) (insert "'")
     (goto-char (match-beginning 2))
     (delete-char 1) (insert "`")
-    (goto-char (match-end 2))))
+    (goto-char (match-end 2)))
+  (goto-char (point-min))
+  ;; Remove target markers
+  (while (re-search-forward  "<<<?\\([^<>]*\\)>>>?\\([ \t]*\\)" nil t)
+    (replace-match "\\1\\2")))
 
 (defun org-search-todo-below (line lines level)
   "Search the subtree below LINE for any TODO entries."