From bfe0fa3d78cc13b84dec33c230755c9f4693a685 Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date: Fri, 26 Apr 2024 16:39:07 +0300 Subject: [PATCH] ob-lua: Fix edge case when output is {string} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/ob-lua.el (org-babel-lua-wrapper-method): Make sure that string result is enclosed in "...", so that Org mode does not try to guess the output type heuristically. * testing/lisp/test-ob-lua.el (test-ob-lua/types): New test. Co-authored-by: Rudolf Adamkovič --- lisp/ob-lua.el | 2 ++ testing/lisp/test-ob-lua.el | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el index 041abfabc..afe88065d 100644 --- a/lisp/ob-lua.el +++ b/lisp/ob-lua.el @@ -282,6 +282,8 @@ (defvar org-babel-lua-wrapper-method end end return result + elseif type(it) == 'string' then + return '\"' .. it .. '\"' else return tostring(it) end diff --git a/testing/lisp/test-ob-lua.el b/testing/lisp/test-ob-lua.el index 0a60c68ca..398ab761d 100644 --- a/testing/lisp/test-ob-lua.el +++ b/testing/lisp/test-ob-lua.el @@ -158,6 +158,12 @@ (ert-deftest test-ob-lua/types () (equal "hello world" (org-test-with-temp-text "src_lua{return 'hello world'}" (org-babel-execute-src-block)))) + ;; Edge case: string matching list syntax. + (should + (equal "{B}" + (org-test-with-temp-text + "src_lua{return string.match('A {B} C', '%b{}')}" + (org-babel-execute-src-block)))) (should (equal 0 (string-match "table: 0x[0-9A-F]+" -- 2.44.0