Ver Fonte

ob-python: can now handle variable strings with newlines

* lisp/ob-python.el (org-babel-python-var-to-python): python can now
  handle input strings with newlines
Eric Schulte há 14 anos atrás
pai
commit
f904376df4
1 ficheiros alterados com 5 adições e 1 exclusões
  1. 5 1
      lisp/ob-python.el

+ 5 - 1
lisp/ob-python.el

@@ -110,7 +110,11 @@ Convert an elisp value, VAR, into a string of python source code
 specifying a variable of the same value."
   (if (listp var)
       (concat "[" (mapconcat #'org-babel-python-var-to-python var ", ") "]")
-    (if (equal var 'hline) "None" (format "%S" var))))
+    (if (equal var 'hline)
+	"None"
+      (format
+       (if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
+       var))))
 
 (defun org-babel-python-table-or-string (results)
   "Convert RESULTS into an appropriate elisp value.