diff --git a/MLS.Agent.Tests/MLS.Agent.Tests.csproj b/MLS.Agent.Tests/MLS.Agent.Tests.csproj
index b0b1e5e43..d906773d7 100644
--- a/MLS.Agent.Tests/MLS.Agent.Tests.csproj
+++ b/MLS.Agent.Tests/MLS.Agent.Tests.csproj
@@ -12,7 +12,7 @@
-
+
all
diff --git a/MLS.Repositories.Tests/MLS.Repositories.Tests.csproj b/MLS.Repositories.Tests/MLS.Repositories.Tests.csproj
index 2885c58cd..b8842bd56 100644
--- a/MLS.Repositories.Tests/MLS.Repositories.Tests.csproj
+++ b/MLS.Repositories.Tests/MLS.Repositories.Tests.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/Microsoft.DotNet.Interactive.Jupyter.Tests/Microsoft.DotNet.Interactive.Jupyter.Tests.csproj b/Microsoft.DotNet.Interactive.Jupyter.Tests/Microsoft.DotNet.Interactive.Jupyter.Tests.csproj
index 27f3a3be0..6e3a89d75 100644
--- a/Microsoft.DotNet.Interactive.Jupyter.Tests/Microsoft.DotNet.Interactive.Jupyter.Tests.csproj
+++ b/Microsoft.DotNet.Interactive.Jupyter.Tests/Microsoft.DotNet.Interactive.Jupyter.Tests.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/Microsoft.DotNet.Interactive.Rendering.Tests/Microsoft.DotNet.Interactive.Rendering.Tests.csproj b/Microsoft.DotNet.Interactive.Rendering.Tests/Microsoft.DotNet.Interactive.Rendering.Tests.csproj
index 09c70983e..44e6977ce 100644
--- a/Microsoft.DotNet.Interactive.Rendering.Tests/Microsoft.DotNet.Interactive.Rendering.Tests.csproj
+++ b/Microsoft.DotNet.Interactive.Rendering.Tests/Microsoft.DotNet.Interactive.Rendering.Tests.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/Microsoft.DotNet.Interactive/Kernel.cs b/Microsoft.DotNet.Interactive/Kernel.cs
index 5332c064c..027b05d2a 100644
--- a/Microsoft.DotNet.Interactive/Kernel.cs
+++ b/Microsoft.DotNet.Interactive/Kernel.cs
@@ -4,13 +4,14 @@
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive.Commands;
using Microsoft.DotNet.Interactive.Rendering;
+using static Microsoft.DotNet.Interactive.Rendering.PocketViewTags;
namespace Microsoft.DotNet.Interactive
{
public static class Kernel
{
public static void display(
- object value,
+ object value,
string mimeType = HtmlFormatter.MimeType)
{
var formatted = new FormattedValue(
@@ -23,5 +24,24 @@ public static void display(
kernel.SendAsync(new DisplayValue(formatted)))
.Wait();
}
+
+ public static void Javascript(
+ string scriptContent)
+ {
+ PocketView value =
+ script[type: "text/javascript"](
+ HTML(
+ scriptContent));
+
+ var formatted = new FormattedValue(
+ HtmlFormatter.MimeType,
+ value.ToString());
+
+ var kernel = KernelInvocationContext.Current.Kernel;
+
+ Task.Run(() =>
+ kernel.SendAsync(new DisplayValue(formatted)))
+ .Wait();
+ }
}
}
\ No newline at end of file
diff --git a/Microsoft.DotNet.Try.Markdown.Tests/Microsoft.DotNet.Try.Markdown.Tests.csproj b/Microsoft.DotNet.Try.Markdown.Tests/Microsoft.DotNet.Try.Markdown.Tests.csproj
index 3f344541d..8c4af97a6 100644
--- a/Microsoft.DotNet.Try.Markdown.Tests/Microsoft.DotNet.Try.Markdown.Tests.csproj
+++ b/Microsoft.DotNet.Try.Markdown.Tests/Microsoft.DotNet.Try.Markdown.Tests.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/Microsoft.DotNet.Try.Project.Tests/Microsoft.DotNet.Try.Project.Tests.csproj b/Microsoft.DotNet.Try.Project.Tests/Microsoft.DotNet.Try.Project.Tests.csproj
index 27497a196..f1ae0dcd6 100644
--- a/Microsoft.DotNet.Try.Project.Tests/Microsoft.DotNet.Try.Project.Tests.csproj
+++ b/Microsoft.DotNet.Try.Project.Tests/Microsoft.DotNet.Try.Project.Tests.csproj
@@ -12,7 +12,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/Microsoft.DotNet.Try.ProjectTemplate.Tests/Microsoft.DotNet.Try.ProjectTemplate.Tests.csproj b/Microsoft.DotNet.Try.ProjectTemplate.Tests/Microsoft.DotNet.Try.ProjectTemplate.Tests.csproj
index 387984272..262784178 100644
--- a/Microsoft.DotNet.Try.ProjectTemplate.Tests/Microsoft.DotNet.Try.ProjectTemplate.Tests.csproj
+++ b/Microsoft.DotNet.Try.ProjectTemplate.Tests/Microsoft.DotNet.Try.ProjectTemplate.Tests.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/Microsoft.DotNet.Try.Protocol.Tests/Microsoft.DotNet.Try.Protocol.Tests.csproj b/Microsoft.DotNet.Try.Protocol.Tests/Microsoft.DotNet.Try.Protocol.Tests.csproj
index 29025d972..a036eeaa7 100644
--- a/Microsoft.DotNet.Try.Protocol.Tests/Microsoft.DotNet.Try.Protocol.Tests.csproj
+++ b/Microsoft.DotNet.Try.Protocol.Tests/Microsoft.DotNet.Try.Protocol.Tests.csproj
@@ -13,7 +13,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/NotIntegrationTests/NotIntegrationTests.csproj b/NotIntegrationTests/NotIntegrationTests.csproj
index 366529ccf..1264152c8 100644
--- a/NotIntegrationTests/NotIntegrationTests.csproj
+++ b/NotIntegrationTests/NotIntegrationTests.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/PackageTool.Tests/PackageTool.Tests.csproj b/PackageTool.Tests/PackageTool.Tests.csproj
index a6a975b9e..0b49a9b92 100644
--- a/PackageTool.Tests/PackageTool.Tests.csproj
+++ b/PackageTool.Tests/PackageTool.Tests.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/WasmCodeRunner.Tests/MLS.WasmCodeRunner.Tests.csproj b/WasmCodeRunner.Tests/MLS.WasmCodeRunner.Tests.csproj
index ab046baec..95719b221 100644
--- a/WasmCodeRunner.Tests/MLS.WasmCodeRunner.Tests.csproj
+++ b/WasmCodeRunner.Tests/MLS.WasmCodeRunner.Tests.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/WorkspaceServer.Tests/Kernel/CSharpKernelRenderingTests.cs b/WorkspaceServer.Tests/Kernel/CSharpKernelRenderingTests.cs
index 2618ba31d..67e8d70c4 100644
--- a/WorkspaceServer.Tests/Kernel/CSharpKernelRenderingTests.cs
+++ b/WorkspaceServer.Tests/Kernel/CSharpKernelRenderingTests.cs
@@ -98,5 +98,28 @@ public async Task Display_helper_can_be_called_without_specifying_class_name()
v.MimeType == "text/html" &&
v.Value.ToString().Contains("hi!"));
}
+
+ [Fact]
+ public async Task Javascript_helper_emits_string_as_content_within_a_script_element()
+ {
+ var kernel = CreateKernel();
+
+ var scriptContent = "alert('Hello World!');";
+
+ await kernel.SendAsync(new SubmitCode($@"Javascript(""{scriptContent}"");"));
+
+ var formatted =
+ KernelEvents
+ .ValuesOnly()
+ .OfType()
+ .SelectMany(v => v.FormattedValues)
+ .ToArray();
+
+ formatted
+ .Should()
+ .ContainSingle(v =>
+ v.MimeType == "text/html" &&
+ v.Value.ToString().Contains($@""));
+ }
}
}
\ No newline at end of file
diff --git a/WorkspaceServer.Tests/WorkspaceServer.Tests.csproj b/WorkspaceServer.Tests/WorkspaceServer.Tests.csproj
index a4b18cc1f..b0599abe4 100644
--- a/WorkspaceServer.Tests/WorkspaceServer.Tests.csproj
+++ b/WorkspaceServer.Tests/WorkspaceServer.Tests.csproj
@@ -27,7 +27,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers