forked from mirrors/org-mode
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:
parent
20044297a4
commit
b055f0d372
19
lisp/ob.el
19
lisp/ob.el
|
@ -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 ; '
|
||||
|
|
Loading…
Reference in a new issue