From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brad Knotwell Subject: a small bug in ob-lua.el Date: Sat, 29 Dec 2018 17:48:34 +0000 (UTC) Message-ID: <437921843.11633137.1546105714093@mail.yahoo.com> References: <437921843.11633137.1546105714093.ref@mail.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_11633136_215737107.1546105714091" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:43140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gdIvC-00075G-3d for emacs-orgmode@gnu.org; Sat, 29 Dec 2018 13:01:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gdIj3-0000y1-3T for emacs-orgmode@gnu.org; Sat, 29 Dec 2018 12:48:44 -0500 Received: from sonic305-20.consmr.mail.gq1.yahoo.com ([98.137.64.83]:43310) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gdIj1-0000tV-5J for emacs-orgmode@gnu.org; Sat, 29 Dec 2018 12:48:40 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Org-mode ------=_Part_11633136_215737107.1546105714091 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello all-- I've been using the babel integration with Lua and it has a bug worth notin= g--multi-line header argument variables that are tangled to a file will be = tangled in a way lua doesn't interpret correctly. =C2=A0To use a specific e= xample: #+NAME: csvdata#+BEGIN_EXAMPLEx,y,z,zz1,2,3,"hi"4,5,6,"hi,hi"7,8,9,"hi,hi,h= i"#+END_EXAMPLE #+BEGIN_SRC lua :var csv=3Dcsvdata :tangle test.lua print(csv)#+END_SRC tangles to the (python default?) following: csv=3D"""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. =C2=A0It would parse the following however: csv=3D[=3D[x,y,z,zz 1,2,3,\"hi\" 4,5,6,\"hi,hi\" 7,8,9,\"hi,hi,hi\" ]=3D] print(csv) Furthermore, it will also remove the need to escape the internal double quo= te characters so you could have even cleaner output: csv=3D[=3D[x,y,z,zz 1,2,3,"hi" 4,5,6,"hi,hi" 7,8,9,"hi,hi,hi" ]=3D] The following trivial patch resolves it and tangles to a file that Lua can = evaluate: csv=3D[=3D[x,y,z,zz 1,2,3,"hi" 4,5,6,"hi,hig" 7,8,9,"hi,hi,hi" ]=3D] print(csv) diff --git a/lisp/ob-lua.el b/lisp/ob-lua.elindex 442ea568b..4625b3202 1006= 44--- a/lisp/ob-lua.el+++ b/lisp/ob-lua.el@@ -148,7 +148,7 @@ specifying a = variable of the same value."=C2=A0 =C2=A0 =C2=A0(if (eq var 'hline)=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0org-babel-lua-hline-to=C2=A0 =C2=A0 =C2=A0 =C2= =A0(format- =C2=A0 =C2=A0 =C2=A0 (if (and (stringp var) (string-match "[\n\= r]" var)) "\"\"%S\"\"" "%S")+ =C2=A0 =C2=A0 =C2=A0 (if (and (stringp var) (= string-match "[\n\r]" var)) "[=3D[%s]=3D]" "%S")=C2=A0 =C2=A0 =C2=A0 =C2=A0= (if (stringp var) (substring-no-properties var) var)))))=C2=A0=C2=A0(defun= org-babel-lua-table-or-string (results) Thx. --Brad ------=_Part_11633136_215737107.1546105714091 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello all--

I've bee= n 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:<= /div>

#+NAME: csvdata
#+BEGIN_EXAMP= LE
x,y,z,zz
1,2,3,"hi"
4,5,6,"hi,hi"
7,8,9,"hi,hi,hi"
#+END_EXAMPLE

#+BEGIN= _SRC lua :var csv=3Dcsvdata :tangle test.lua

print= (csv)
#+END_SRC

tangles to the (python d= efault?) following:

csv=3D"""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 wo= uld parse the following however:

csv=3D[=3D[x,y,z,zz

1,2,3,\"hi\"

4,5,6,\"hi,hi\"

7,8,9,\"hi,hi,hi\"

]=3D]


print(csv)

Furthermore, it will also remove t= he need to escape the internal double quote characters so you could have ev= en cleaner output:

csv=3D[=3D[x,y,z,zz

1,2,3,"hi"

<= p style=3D"margin: 0px; font-stretch: normal; font-size: 11px; line-height:= normal; font-family: Menlo;">4,5,6,"hi,hi"

7,8,9,"hi,hi,hi"

]=3D]


The following trivial patch resolves it and tangles to a file that = Lua can evaluate:

csv=3D[=3D[x,y,z,zz

1,2,3,"hi"

4,5,6,"hi,hig"

7,8,9,"hi,hi,hi"

]=3D]


print(csv)



diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el
index 442ea568b..4625b3202 100644
--- a/lisp/ob-lua.el
+++ b/lisp/ob-lua.el
@@ -148,7 +148,7 @@ specifying a va= riable of the same value."
     (if (eq var 'hline= )
         org-babel-lua-hline-to
<= div>       (format
-       (if= (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
+       (if (and (stringp var) (string-match "[\n\r]" var= )) "[=3D[%s]=3D]" "%S")
        (if (stringp = var) (substring-no-properties var) var)))))
 
&nbs= p;(defun org-babel-lua-table-or-string (results)

Thx.

--Brad
<= /div>
------=_Part_11633136_215737107.1546105714091--