From cc300fbfe302720d8b62b545ad866de75029b95e Mon Sep 17 00:00:00 2001 From: Jon Sequeira Date: Tue, 18 Oct 2022 18:26:25 -0700 Subject: [PATCH] fix Jupyter metadata --- .../Jupyter/InteractiveDocumentExtensions.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.DotNet.Interactive.Documents/Jupyter/InteractiveDocumentExtensions.cs b/src/Microsoft.DotNet.Interactive.Documents/Jupyter/InteractiveDocumentExtensions.cs index cafaad47a1..60bca16b5b 100644 --- a/src/Microsoft.DotNet.Interactive.Documents/Jupyter/InteractiveDocumentExtensions.cs +++ b/src/Microsoft.DotNet.Interactive.Documents/Jupyter/InteractiveDocumentExtensions.cs @@ -13,20 +13,20 @@ public static InteractiveDocument WithJupyterMetadata( this InteractiveDocument document, string language = "C#") { - var (moniker, langVersion, fileExtension) = - language switch + var (moniker, canonicalLanguageName, langVersion, fileExtension) = + language.ToLowerInvariant() switch { - "C#" or "csharp" => ("csharp", "10.0", ".cs"), - "F#" or "fsharp" => ("fsharp", "6.0", ".fs"), - "PowerShell" or "pwsh" => ("powershell", "7.0", ".ps1"), + "c#" or "csharp" => ("csharp","C#", "10.0", ".cs"), + "f#" or "fsharp" => ("fsharp","F#", "6.0", ".fs"), + "powershell" or "pwsh" => ("powershell", "PowerShell", "7.0", ".ps1"), _ => throw new ArgumentException($"Unrecognized language: {language}") }; document.Metadata.GetOrAdd("kernelspec", _ => new Dictionary()) .MergeWith(new Dictionary { - ["display_name"] = $".NET ({language})", - ["language"] = language, + ["display_name"] = $".NET ({canonicalLanguageName})", + ["language"] = canonicalLanguageName, ["name"] = $".net-{moniker}" }); @@ -35,7 +35,7 @@ public static InteractiveDocument WithJupyterMetadata( { ["file_extension"] = fileExtension, ["mimetype"] = $"text/x-{moniker}", - ["name"] = language, + ["name"] = canonicalLanguageName, ["pygments_lexer"] = moniker, ["version"] = langVersion });