فهرست منبع

Fix bug with protecting LaTeX macros

The regular expression was not optimal, and if there was a horizontal
rule, search would not start from the beginning of the buffer but from
after the rule!
Carsten Dominik 16 سال پیش
والد
کامیت
41d82c78f9
2فایلهای تغییر یافته به همراه10 افزوده شده و 5 حذف شده
  1. 5 0
      lisp/ChangeLog
  2. 5 5
      lisp/org-latex.el

+ 5 - 0
lisp/ChangeLog

@@ -1,5 +1,10 @@
 2009-12-16  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-latex.el (org-export-latex-preprocess): Better version of
+	the regular expression for protecting LaTeX macros.
+	(org-export-latex-preprocess): Start searching for macros to
+	protect from beginning of buffer.
+
 	* org-exp.el (org-export-target-internal-links): Check for
 	protectedness earlier in the string.
 

+ 5 - 5
lisp/org-latex.el

@@ -1877,11 +1877,11 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
      (replace-match (org-export-latex-protect-string "\\hrule") t t)))
 
   ;; Protect LaTeX commands like \command[...]{...} or \command{...}
-  (let ((re (concat "\\\\[a-zA-Z]+\\(?:"
-		    "\\[.*\\]"
-		    "\\)?"
-		    "\\(" (org-create-multibrace-regexp "{" "}" 3)
-		    "\\)\\{1,3\\}")))
+  (goto-char (point-min))
+  (let ((re (concat
+	     "\\\\[a-zA-Z]+"
+	     "\\(?:\\[[^][\n]*?\\]\\)*"
+	     "\\(" (org-create-multibrace-regexp "{" "}" 3) "\\)\\{1,3\\}")))
     (while (re-search-forward re nil t)
       (unless (save-excursion (goto-char (match-beginning 0))
 			      (equal (char-after (point-at-bol)) ?#))