From 7d8a9324f8e9f3fdf82d88943e1709c2571f8c69 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Mon, 17 Apr 2023 13:10:10 +0200 Subject: [PATCH] org-babel-js-function-wrapper: Fix when the last line is a comment * lisp/ob-js.el (org-babel-js-function-wrapper): Ensure that last line of the body being comment does not shadow the closing parenthesis. Reported-by: sgherdao@tuta.io Link: https://orgmode.org/list/NT8rSmu--F-9@tutanota.com --- lisp/ob-js.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/ob-js.el b/lisp/ob-js.el index 910c11686..de7ea9131 100644 --- a/lisp/ob-js.el +++ b/lisp/ob-js.el @@ -69,7 +69,10 @@ :safe #'stringp) (defvar org-babel-js-function-wrapper - "require('process').stdout.write(require('util').inspect(function(){%s}()));" + ;; Note that newline after %s - it makes sure that closing + ;; parenthesis are not shadowed if the last line of the body is a + ;; line comment. + "require('process').stdout.write(require('util').inspect(function(){%s\n}()));" "Javascript code to print value of body.") (defun org-babel-execute:js (body params)