Browse Source

org-table.el: Escape some special characters when sending radio tables.

* org-table.el (orgtbl-send-table): Escape special characters.
Introduce a new parameter :no-escape to prevent escaping.

* org.texi (Radio tables): Document the :no-escape parameter.

Thanks to Alexander Willand for raising this issue.
Bastien Guerry 8 years ago
parent
commit
e9dec29bb1
2 changed files with 8 additions and 0 deletions
  1. 4 0
      doc/org.texi
  2. 4 0
      lisp/org-table.el

+ 4 - 0
doc/org.texi

@@ -15551,6 +15551,10 @@ calculation marks, that column is automatically discarded as well.
 Please note that the translator function sees the table @emph{after} the
 removal of these columns, the function never knows that there have been
 additional columns.
+
+@item :no-escape t
+When non-nil, do not escape special characters @code{&%#_^} when exporting
+the table.  The default value is nil.
 @end table
 
 @noindent

+ 4 - 0
lisp/org-table.el

@@ -4296,11 +4296,15 @@ this table."
 	       (params (plist-get dest :params))
 	       (skip (plist-get params :skip))
 	       (skipcols (plist-get params :skipcols))
+	       (no-escape (plist-get params :no-escape))
 	       beg
 	       (lines (org-table-clean-before-export
 		       (nthcdr (or skip 0)
 			       (org-split-string txt "[ \t]*\n[ \t]*"))))
 	       (i0 (if org-table-clean-did-remove-column 2 1))
+	       (lines (if no-escape lines
+			(mapcar (lambda(l) (replace-regexp-in-string
+					    "\\([&%#_^]\\)" "\\\\\\1{}" l)) lines)))
 	       (table (mapcar
 		       (lambda (x)
 			 (if (string-match org-table-hline-regexp x)