diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2681b6464..771923083 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,10 @@ 2009-12-16 Carsten Dominik + * 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. diff --git a/lisp/org-latex.el b/lisp/org-latex.el index bed39c46a..e481ccd21 100644 --- a/lisp/org-latex.el +++ b/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)) ?#))