ob: escaping scripts now treats {} in the same manner as []

* lisp/ob.el (org-babel-script-escape): Treats {} in the same manner
  as [] and allows for forcing string conversion.
This commit is contained in:
Eric Schulte 2011-06-28 16:38:30 -07:00
parent 20044297a4
commit b055f0d372
1 changed files with 14 additions and 5 deletions

View File

@ -1935,14 +1935,17 @@ block but are passed literally to the \"example-block\"."
"Strip protective commas from bodies of source blocks."
(replace-regexp-in-string "^,#" "#" body))
(defun org-babel-script-escape (str)
(defun org-babel-script-escape (str &optional force)
"Safely convert tables into elisp lists."
(let (in-single in-double out)
((lambda (escaped) (condition-case nil (org-babel-read escaped) (error escaped)))
(if (and (stringp str)
(> (length str) 2)
(string-equal "[" (substring str 0 1))
(string-equal "]" (substring str -1)))
(if (or force
(and (stringp str)
(> (length str) 2)
(or (and (string-equal "[" (substring str 0 1))
(string-equal "]" (substring str -1)))
(and (string-equal "{" (substring str 0 1))
(string-equal "}" (substring str -1))))))
(org-babel-read
(concat
"'"
@ -1958,6 +1961,12 @@ block but are passed literally to the \"example-block\"."
(93 (if (or in-double in-single) ; ]
(cons 93 out)
(cons 41 out)))
(123 (if (or in-double in-single) ; {
(cons 123 out)
(cons 40 out)))
(125 (if (or in-double in-single) ; }
(cons 125 out)
(cons 41 out)))
(44 (if (or in-double in-single) ; ,
(cons 44 out) (cons 32 out)))
(39 (if in-double ; '