From 39eb7796e8560f172ba6d69ff1f943b62b3fefd2 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 11 Oct 2014 17:01:59 +0200 Subject: [PATCH] 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 --- lisp/org-table.el | 15 +++++++++++++-- testing/lisp/test-org-table.el | 6 +++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 7607ead2b..d8b9235b4 100644 --- a/lisp/org-table.el +++ b/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 diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index e08368302..7d1ce14bd 100644 --- a/testing/lisp/test-org-table.el +++ b/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." -- 2.11.4.GIT