Skip to content

Commit

Permalink
add a JavaScript kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsequitur committed Aug 24, 2022
1 parent 6dc4f45 commit 11f3e3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
23 changes: 0 additions & 23 deletions src/dotnet-repl.Tests/Automation/NotebookRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,29 +93,6 @@ public async Task Notebook_runner_produces_expected_output()
this.Assent(resultContent, _assentConfiguration);
}

[Fact]
public async Task ASCII_escape_sequences_do_not_cause_XML_parse_problems()
{
using var kernel = new CSharpKernel();

var runner = new NotebookRunner(kernel);

var inputDoc = new InteractiveDocument
{
new InteractiveDocumentElement("123.Display(\"unknown/MIMEtype\");", "csharp")
};
var outputDoc = await runner.RunNotebookAsync(inputDoc);

var xml = outputDoc.ToTestOutputDocumentXml();

TestOutputDocumentParser.Parse(xml);



// TODO (ASCII_escape_sequences_do_not_cause_XML_parse_problems) write test
throw new NotImplementedException();
}

private void NormalizeMetadata(InteractiveDocument document)
{
foreach (var element in document.Elements)
Expand Down
5 changes: 4 additions & 1 deletion src/dotnet-repl/KernelBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive;
using Microsoft.DotNet.Interactive.Browser;
using Microsoft.DotNet.Interactive.Commands;
using Microsoft.DotNet.Interactive.CSharp;
using Microsoft.DotNet.Interactive.FSharp;
Expand Down Expand Up @@ -74,8 +76,9 @@ public static CompositeKernel CreateKernel(StartupOptions? options = null)
new KeyValueStoreKernel()
.UseWho());

var playwrightKernel = Task.Run(() => new PlaywrightKernelConnector().CreateKernelAsync("javascript")).Result;
compositeKernel.Add(playwrightKernel, new[] { "js" });
compositeKernel.Add(new MarkdownKernel());

compositeKernel.Add(new SqlDiscoverabilityKernel());
compositeKernel.Add(new KqlDiscoverabilityKernel());

Expand Down
10 changes: 10 additions & 0 deletions src/dotnet-repl/KernelSpecificTheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public abstract class KernelSpecificTheme : Theme
"csharp" => new CSharpTheme(),
"fsharp" => new FSharpTheme(),
"pwsh" => new PowerShellTheme(),
"javascript" => new JavaScriptTheme(),
"sql" => new SqlTheme(),
_ => null
};
Expand Down Expand Up @@ -63,6 +64,15 @@ public class PowerShellTheme : KernelSpecificTheme
public override string PromptText => "PS";
}

public class JavaScriptTheme : KernelSpecificTheme
{
public override Style AccentStyle => new(Color.Yellow);

public override string KernelDisplayName => "JavaScript";

public override string PromptText => "JS";
}

public class SqlTheme : KernelSpecificTheme
{
public override Style AccentStyle => new(Color.Yellow3);
Expand Down

0 comments on commit 11f3e3b

Please sign in to comment.