emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Peter Moresi <peter.moresi@gmail.com>
To: Peter Moresi <peter.moresi@gmail.com>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Issue with multiline string variable for JavaScript source code blocks
Date: Fri, 21 Nov 2014 16:12:26 -0800	[thread overview]
Message-ID: <CAK_Lq03fWaq7XXiiT3_bxmHyGDxAGh4C3dhqgwn_f3LoUxL95A@mail.gmail.com> (raw)
In-Reply-To: <87wq6o40fw.fsf@nicolasgoaziou.fr>

[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]

Excellent and thanks for the feedback. I'm glad I was able to give
something back to the community that has given me so much.

I've also had issues with JavaScript source code blocks truncating the
result when the value is a string with a comma. I'm still getting up to
speed with Emacs-lisp but when I figure out how to fix the issue I will
send the patch with proper comments.

Thanks,
Peter

On Friday, November 21, 2014, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Peter Moresi <peter.moresi@gmail.com <javascript:;>> 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
>

[-- Attachment #2: Type: text/html, Size: 2528 bytes --]

      reply	other threads:[~2014-11-22  0:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-17 20:44 Issue with multiline string variable for JavaScript source code blocks Peter Moresi
2014-11-18 21:30 ` Nicolas Goaziou
2014-11-19  0:04   ` Peter Moresi
2014-11-21 23:07     ` Nicolas Goaziou
2014-11-22  0:12       ` Peter Moresi [this message]

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=CAK_Lq03fWaq7XXiiT3_bxmHyGDxAGh4C3dhqgwn_f3LoUxL95A@mail.gmail.com \
    --to=peter.moresi@gmail.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).