From: Brad Knotwell <bknotwell@yahoo.com>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: a small bug in ob-lua.el
Date: Sat, 29 Dec 2018 17:48:34 +0000 (UTC) [thread overview]
Message-ID: <437921843.11633137.1546105714093@mail.yahoo.com> (raw)
In-Reply-To: 437921843.11633137.1546105714093.ref@mail.yahoo.com
[-- 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 --]
next parent reply other threads:[~2018-12-29 18:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <437921843.11633137.1546105714093.ref@mail.yahoo.com>
2018-12-29 17:48 ` Brad Knotwell [this message]
2019-01-12 20:39 ` a small bug in ob-lua.el Kyle Meyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=437921843.11633137.1546105714093@mail.yahoo.com \
--to=bknotwell@yahoo.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).