* a small bug in ob-lua.el
[not found] <437921843.11633137.1546105714093.ref@mail.yahoo.com>
@ 2018-12-29 17:48 ` Brad Knotwell
2019-01-12 20:39 ` Kyle Meyer
0 siblings, 1 reply; 2+ messages in thread
From: Brad Knotwell @ 2018-12-29 17:48 UTC (permalink / raw)
To: Org-mode
[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]
Hello all--
I've been using the babel integration with Lua and it has a bug worth noting--multi-line header argument variables that are tangled to a file will be tangled in a way lua doesn't interpret correctly. To use a specific example:
#+NAME: csvdata#+BEGIN_EXAMPLEx,y,z,zz1,2,3,"hi"4,5,6,"hi,hi"7,8,9,"hi,hi,hi"#+END_EXAMPLE
#+BEGIN_SRC lua :var csv=csvdata :tangle test.lua
print(csv)#+END_SRC
tangles to the (python default?) following:
csv="""x,y,z,zz
1,2,3,\"hi\"
4,5,6,\"hi,hi\"
7,8,9,\"hi,hi,hi\"
"""
print(csv)
which Lua won't parse. It would parse the following however:
csv=[=[x,y,z,zz
1,2,3,\"hi\"
4,5,6,\"hi,hi\"
7,8,9,\"hi,hi,hi\"
]=]
print(csv)
Furthermore, it will also remove the need to escape the internal double quote characters so you could have even cleaner output:
csv=[=[x,y,z,zz
1,2,3,"hi"
4,5,6,"hi,hi"
7,8,9,"hi,hi,hi"
]=]
The following trivial patch resolves it and tangles to a file that Lua can evaluate:
csv=[=[x,y,z,zz
1,2,3,"hi"
4,5,6,"hi,hig"
7,8,9,"hi,hi,hi"
]=]
print(csv)
diff --git a/lisp/ob-lua.el b/lisp/ob-lua.elindex 442ea568b..4625b3202 100644--- a/lisp/ob-lua.el+++ b/lisp/ob-lua.el@@ -148,7 +148,7 @@ specifying a variable of the same value." (if (eq var 'hline) org-babel-lua-hline-to (format- (if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")+ (if (and (stringp var) (string-match "[\n\r]" var)) "[=[%s]=]" "%S") (if (stringp var) (substring-no-properties var) var))))) (defun org-babel-lua-table-or-string (results)
Thx.
--Brad
[-- Attachment #2: Type: text/html, Size: 5243 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread