From 8a2b026ad0e102ce06b88f731225f5e5dc920f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Mon, 19 Aug 2024 15:51:45 +0900 Subject: [PATCH] Use triple quote when remote cell content contains a quote --- lib/kino/remote_execution_cell.ex | 2 +- test/kino/remote_execution_cell_test.exs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/kino/remote_execution_cell.ex b/lib/kino/remote_execution_cell.ex index 067bc74b..cf71501b 100644 --- a/lib/kino/remote_execution_cell.ex +++ b/lib/kino/remote_execution_cell.ex @@ -139,7 +139,7 @@ defmodule Kino.RemoteExecutionCell do defp quoted_code(code) do {delimiter, code} = - if String.contains?(code, "\n") do + if String.contains?(code, ["\n", ~s/"/]) do {~s["""], code <> "\n"} else {~s["], code} diff --git a/test/kino/remote_execution_cell_test.exs b/test/kino/remote_execution_cell_test.exs index 71b554c3..4d5616a3 100644 --- a/test/kino/remote_execution_cell_test.exs +++ b/test/kino/remote_execution_cell_test.exs @@ -138,7 +138,14 @@ defmodule Kino.RemoteExecutionCellTest do require Kino.RPC node = :name@node Node.set_cookie(node, :"node-cookie") - Kino.RPC.eval_string(node, ~S"\"Number #{1}\"", file: __ENV__.file) + + Kino.RPC.eval_string( + node, + ~S""" + "Number #{1}" + """, + file: __ENV__.file + ) ''' |> String.replace_trailing("\n", "")