浏览代码

org-table: Fix :raw parameter in radio tables

* lisp/org-table.el (org-table--to-generic-cell): Use
  `org-element-interpret' data when parameter :raw is non-nil so
  pseudo elements and objects are not ignored.

* testing/lisp/test-org-table.el (test-org-table/to-latex): Add test.

Thanks to Giuseppe Lipari for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/91559
Nicolas Goaziou 10 年之前
父节点
当前提交
39eb7796e8
共有 2 个文件被更改,包括 18 次插入3 次删除
  1. 13 2
      lisp/org-table.el
  2. 5 1
      testing/lisp/test-org-table.el

+ 13 - 2
lisp/org-table.el

@@ -4850,8 +4850,19 @@ information."
 	 ;; Make sure that contents are exported as Org data when :raw
 	 ;; parameter is non-nil.
 	 ,(when (and backend (plist-get params :raw))
-	    `(setq contents (org-export-data-with-backend
-			     (org-element-contents cell) 'org info)))
+	    `(setq contents
+		   ;; Since we don't know what are the pseudo object
+		   ;; types defined in backend, we cannot pass them to
+		   ;; `org-element-interpret-data'.  As a consequence,
+		   ;; they will be treated as pseudo elements, and
+		   ;; will have newlines appended instead of spaces.
+		   ;; Therefore, we must make sure :post-blank value
+		   ;; is really turned into spaces.
+		   (replace-regexp-in-string
+		    "\n" " "
+		    (org-trim
+		     (org-element-interpret-data
+		      (org-element-contents cell))))))
 	 (when contents
 	   ;; Check if we can apply `:efmt' on CONTENTS.
 	   ,(when efmt

+ 5 - 1
testing/lisp/test-org-table.el

@@ -1452,7 +1452,11 @@ See also `test-org-table/copy-field'."
   ;; Test :booktabs parameter.
   (should
    (org-string-match-p
-    "\\toprule" (orgtbl-to-latex (org-table-to-lisp "| a |") '(:booktabs t)))))
+    "\\toprule" (orgtbl-to-latex (org-table-to-lisp "| a |") '(:booktabs t))))
+  ;; Test pseudo objects and :raw parameter.
+  (should
+   (org-string-match-p
+    "\\$x\\$" (orgtbl-to-latex (org-table-to-lisp "| $x$ |") '(:raw t)))))
 
 (ert-deftest test-org-table/to-html ()
   "Test `orgtbl-to-html' specifications."