emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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

* Re: a small bug in ob-lua.el
  2018-12-29 17:48 ` a small bug in ob-lua.el Brad Knotwell
@ 2019-01-12 20:39   ` Kyle Meyer
  0 siblings, 0 replies; 2+ messages in thread
From: Kyle Meyer @ 2019-01-12 20:39 UTC (permalink / raw)
  To: Brad Knotwell, Org-mode

Hello,

Brad Knotwell <bknotwell@yahoo.com> writes:

> 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:
> [...]
> The following trivial patch resolves it and tangles to a file that Lua
> can evaluate:

Thanks for the report and suggested fix.  Could you add a commit message
(and perhaps a test to test-ob-lua.el) and send a patch generated with
'git format-patch'?  More guidelines on contributing are here:
https://orgmode.org/worg/org-contribute.html#org31412be


-- 
Kyle

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-12 20:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <437921843.11633137.1546105714093.ref@mail.yahoo.com>
2018-12-29 17:48 ` a small bug in ob-lua.el Brad Knotwell
2019-01-12 20:39   ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).