diff --git a/jupyter-org-client.el b/jupyter-org-client.el index 3df2912..5397a79 100644 --- a/jupyter-org-client.el +++ b/jupyter-org-client.el @@ -850,8 +850,12 @@ new \"scalar\" result with the result of calling ;; gives bad results on the following ;; ;; [1] Foo bar - (memq (aref result 0) '(?\[ ?\{ ?\()) - (eq (aref result 0) (aref result (1- (length result))))) + (when-let* ((beg (car (memq (aref result 0) '(?\[ ?\{ ?\()))) + (end (and beg (pcase beg + (?\[ ?\]) + (?\{ ?\}) + (?\( ?\)))))) + (eq end (aref result (1- (length result)))))) (org-babel-script-escape result)) (t result))))) diff --git a/test/jupyter-test.el b/test/jupyter-test.el index cad5456..59e3cda 100644 --- a/test/jupyter-test.el +++ b/test/jupyter-test.el @@ -1242,7 +1242,9 @@ Image(filename='%s', width=300)" file) '(export-block (:type "html" :value "foo\n")))) ;; Calls `org-babel-script-escape' for scalar data (should (equal (jupyter-org-result req (list :text/plain "[1, 2, 3]")) - "| 1 | 2 | 3 |\n")))) + "| 1 | 2 | 3 |\n")) + (should (equal (jupyter-org-result req (list :text/plain "[1, 2, 3] Foo")) + '(fixed-width (:value "[1, 2, 3] Foo")))))) (ert-deftest jupyter-org-result-python () :tags '(org)