Browse Source

Bugfix: Avoid emphasis processing across lines and fields in tables.

Emphasis processing could cause problems in tables, with spurious
matches for the emphasis regexp across field boundaries and even
lines.  Fixed now.
Carsten Dominik 16 years ago
parent
commit
b2842d2b7e
2 changed files with 13 additions and 3 deletions
  1. 4 2
      lisp/org-exp.el
  2. 9 1
      lisp/org-export-latex.el

+ 4 - 2
lisp/org-exp.el

@@ -2097,8 +2097,10 @@ This is to make sure that the line-processing export backends
 can work correctly."
 can work correctly."
   (goto-char (point-min))
   (goto-char (point-min))
   (while (re-search-forward org-emph-re nil t)
   (while (re-search-forward org-emph-re nil t)
-    (if (not (= (char-after (match-beginning 3))
-		(char-after (match-beginning 4))))
+    (if (and (not (= (char-after (match-beginning 3))
+		     (char-after (match-beginning 4))))
+	     (save-excursion (goto-char (match-beginning 0))
+			     (save-match-data (not (org-at-table-p)))))
 	(org-if-unprotected
 	(org-if-unprotected
 	 (subst-char-in-region (match-beginning 0) (match-end 0)
 	 (subst-char-in-region (match-beginning 0) (match-end 0)
 			       ?\n ?\  t)
 			       ?\n ?\  t)

+ 9 - 1
lisp/org-export-latex.el

@@ -1153,8 +1153,16 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
     ;; The match goes one char after the *string*
     ;; The match goes one char after the *string*
     (let ((emph (assoc (match-string 3)
     (let ((emph (assoc (match-string 3)
 		       org-export-latex-emphasis-alist))
 		       org-export-latex-emphasis-alist))
+	  (beg (match-beginning 0))
+	  (end (match-end 0))
 	  rpl)
 	  rpl)
-      (unless (get-text-property (1- (point)) 'org-protected)
+      (unless (or (get-text-property (1- (point)) 'org-protected)
+		  (save-excursion
+		    (goto-char (match-beginning 1))
+		    (save-match-data
+		      (and (org-at-table-p)
+			   (string-match
+			    "[|\n]" (buffer-substring beg end))))))
 	(setq rpl (concat (match-string 1)
 	(setq rpl (concat (match-string 1)
 			  (format (org-export-latex-protect-char-in-string
 			  (format (org-export-latex-protect-char-in-string
 				   '("\\" "{" "}") (cadr emph))
 				   '("\\" "{" "}") (cadr emph))