From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Issue with multiline string variable for JavaScript source code blocks Date: Sat, 22 Nov 2014 00:07:47 +0100 Message-ID: <87wq6o40fw.fsf@nicolasgoaziou.fr> References: <87bno4fb8j.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrxIC-0005mE-Au for emacs-orgmode@gnu.org; Fri, 21 Nov 2014 18:07:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrxHz-00051I-Rf for emacs-orgmode@gnu.org; Fri, 21 Nov 2014 18:07:08 -0500 Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]:49212) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrxHz-00050f-Md for emacs-orgmode@gnu.org; Fri, 21 Nov 2014 18:06:55 -0500 In-Reply-To: (Peter Moresi's message of "Tue, 18 Nov 2014 16:04:25 -0800") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Peter Moresi Cc: emacs-orgmode@gnu.org Hello, Peter Moresi writes: > Sure, the patch is attached.=E2=80=8B Applied. Thank you. However I had to fill your commit message, which was incomplete. For reference, here is what I used, from your initial report: --8<---------------cut here---------------start------------->8--- ob-js: Fix passing multiline variables * lisp/ob-js.el (org-babel-js-var-to-js): Replace newline characters with "\n" in strings. Let's say I have a multi-line string stored in an example block. I want to store my CSV in an example block. #+NAME: my-csv-data #+BEGIN_EXAMPLE ColA,ColB,ColC 1,2,3 4,5,6 #+END_EXAMPLE I have a JavaScript function that accepts a string named 'csv' and passing = in 'my-csv-data'. #+BEGIN_SRC js :var csv=3Dmy-csv-data :results output console.log(csv); #+END_SRC When I expand the source block I end up with: #+BEGIN_SRC js var csv=3D"ColA,ColB,ColC 1,2,3 4,5,6"; console.log(csv); #+END_SRC This will not execute correctly because JavaScript does not support newline= s in strings. What I want instead is: #+BEGIN_SRC js var csv=3D"ColA,ColB,ColC\n 1,2,3\n 4,5,6"; console.log(csv); #+END_SRC TINYCHANGE --8<---------------cut here---------------end--------------->8--- Regards, --=20 Nicolas Goaziou