Hello,

Peter Moresi <peter.mor...@gmail.com> writes:

> Sure, the patch is attached.​

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=my-csv-data :results output
  console.log(csv);
#+END_SRC

When I expand the source block I end up with:

#+BEGIN_SRC js
var csv="ColA,ColB,ColC
  1,2,3
  4,5,6";
console.log(csv);
#+END_SRC

This will not execute correctly because JavaScript does not support newlines in 
strings.

What I want instead is:

#+BEGIN_SRC js
  var csv="ColA,ColB,ColC\n  1,2,3\n  4,5,6";
  console.log(csv);
#+END_SRC

TINYCHANGE
--8<---------------cut here---------------end--------------->8---


Regards,

-- 
Nicolas Goaziou

Reply via email to