瀏覽代碼

org-exp: Handle inline comments with new syntax

* lisp/org-exp.el (org-export-handle-comments): Handle inline comments
  with new syntax.
Nicolas Goaziou 12 年之前
父節點
當前提交
40084a55d1
共有 1 個文件被更改,包括 13 次插入18 次删除
  1. 13 18
      lisp/org-exp.el

+ 13 - 18
lisp/org-exp.el

@@ -1985,25 +1985,20 @@ table line.  If it is a link, add it to the line containing the link."
   "Remove comments, or convert to backend-specific format.
   "Remove comments, or convert to backend-specific format.
 ORG-COMMENTSP can be a format string for publishing comments.
 ORG-COMMENTSP can be a format string for publishing comments.
 When it is nil, all comments will be removed."
 When it is nil, all comments will be removed."
-  (let ((re "^\\(#\\|[ \t]*#\\+ \\)\\(.*\n?\\)")
+  (let ((re "^[ \t]*#\\( \\|$\\)"))
-	pos)
     (goto-char (point-min))
     (goto-char (point-min))
-    (while (or (looking-at re)
+    (while (re-search-forward re nil t)
-	       (re-search-forward re nil t))
+      (let ((pos (match-beginning 0))
-      (setq pos (match-beginning 0))
+	    (end (progn (forward-line) (point))))
-      (if (get-text-property pos 'org-protected)
+	(if (get-text-property pos 'org-protected)
-	  (goto-char (1+ pos))
+	    (forward-line)
-	(if (and org-commentsp
+	  (if (not org-commentsp) (delete-region pos end)
-		 (not (equal (char-before (match-end 1)) ?+)))
+	    (add-text-properties pos end '(org-protected t))
-	    (progn (add-text-properties
+	    (replace-match
-		    (match-beginning 0) (match-end 0) '(org-protected t))
+	     (org-add-props
-		   (replace-match (org-add-props
+		 (format org-commentsp (buffer-substring (match-end 0) end))
-				      (format org-commentsp (match-string 2))
+		 nil 'org-protected t)
-				      nil 'org-protected t)
+	     t t)))))))
-				  t t))
-	  (goto-char (1+ pos))
-	  (replace-match "")
-	  (goto-char (max (point-min) (1- pos))))))))
 
 
 (defun org-export-handle-metalines ()
 (defun org-export-handle-metalines ()
   "Remove tables and source blocks metalines.
   "Remove tables and source blocks metalines.