浏览代码

LaTeX export: Fix \nbsp, 2nd attempt

Carsten Dominik 16 年之前
父节点
当前提交
3d1ff31b60
共有 1 个文件被更改,包括 13 次插入3 次删除
  1. 13 3
      lisp/org-latex.el

+ 13 - 3
lisp/org-latex.el

@@ -1549,9 +1549,13 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 
 
   ;; Protect LaTeX entities
   ;; Protect LaTeX entities
   (goto-char (point-min))
   (goto-char (point-min))
-  (while (re-search-forward org-latex-entities-regexp nil t)
-    (add-text-properties (match-beginning 0) (match-end 0)
-			 '(org-protected t)))
+  (let (a)
+    (while (re-search-forward org-latex-entities-regexp nil t)
+      (if (setq a (assoc (match-string 0) org-latex-entities-exceptions))
+	  (replace-match (org-add-props (nth 1 a) nil 'org-protected t)
+			 t t)
+	(add-text-properties (match-beginning 0) (match-end 0)
+			     '(org-protected t)))))
 
 
   ;; Replace radio links
   ;; Replace radio links
   (goto-char (point-min))
   (goto-char (point-min))
@@ -1731,6 +1735,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
    "\\medskip"
    "\\medskip"
    "\\multicolumn"
    "\\multicolumn"
    "\\multiput"
    "\\multiput"
+   ("\\nbsp" "~")
    "\\newcommand"
    "\\newcommand"
    "\\newcounter"
    "\\newcounter"
    "\\newenvironment"
    "\\newenvironment"
@@ -1802,9 +1807,14 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
    "\\vspace")
    "\\vspace")
  "A list of LaTeX commands to be protected when performing conversion.")
  "A list of LaTeX commands to be protected when performing conversion.")
 
 
+(defvar org-latex-entities-exceptions nil)
+
 (defconst org-latex-entities-regexp
 (defconst org-latex-entities-regexp
   (let (names rest)
   (let (names rest)
     (dolist (x org-latex-entities)
     (dolist (x org-latex-entities)
+      (when (consp x)
+	(add-to-list 'org-latex-entities-exceptions x)
+	(setq x (car x)))
       (if (string-match "[a-z][A-Z]$" x)
       (if (string-match "[a-z][A-Z]$" x)
 	  (push x names)
 	  (push x names)
 	(push x rest)))
 	(push x rest)))