Browse Source

Protect LaTeX macros in AUTHOR lines

Carsten Dominik 15 years ago
parent
commit
f376feb5fb
2 changed files with 13 additions and 1 deletions
  1. 3 0
      lisp/ChangeLog
  2. 10 1
      lisp/org-latex.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2009-10-20  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-latex.el (org-export-latex-fontify-headline): Protect TeX
+	macros in author lines and similar stuff.
+
 	* org.el (org-file-tags): Fix docstring.
 	(org-get-buffer-tags): Add the #+FILETAGS tags.
 	("ecb"): Maks ecb show context after jumping into an Org file.

+ 10 - 1
lisp/org-latex.el

@@ -984,7 +984,7 @@ OPT-PLIST is the options plist for current buffer."
      ;; insert author info
      (if (plist-get opt-plist :author-info)
 	 (format "\\author{%s}\n"
-		 (org-export-latex-fontify-headline (or author user-full-name)));????????????????????
+		 (org-export-latex-fontify-headline (or author user-full-name)))
        (format "%%\\author{%s}\n"
 	       (or author user-full-name)))
      ;; insert the date
@@ -1131,6 +1131,15 @@ links, keywords, lists, tables, fixed-width"
     ;; the beginning of the buffer - inserting "\n" is safe here though.
     (insert "\n" string)
     (goto-char (point-min))
+    (let ((re (concat "\\\\[a-zA-Z]+\\(?:"
+		      "\\[.*\\]"
+		      "\\)?"
+		      (org-create-multibrace-regexp "{" "}" 3))))
+      (while (re-search-forward re nil t)
+	(unless (save-excursion (goto-char (match-beginning 0))
+				(equal (char-after (point-at-bol)) ?#))
+	  (add-text-properties (match-beginning 0) (match-end 0)
+			       '(org-protected t)))))
     (when (plist-get org-export-latex-options-plist :emphasize)
       (org-export-latex-fontify))
     (org-export-latex-keywords-maybe)