Skip to content

Commit

Permalink
always split dib cells on markdown language
Browse files Browse the repository at this point in the history
  • Loading branch information
brettfo committed Sep 9, 2021
1 parent b0a1602 commit 0512fe0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CodeSubmissionFormatTests : DocumentFormatTestsBase
{
public InteractiveDocument ParseDib(string content)
{
return CodeSubmission.Parse( content,"csharp", KernelLanguageAliases);
return CodeSubmission.Parse(content, "csharp", KernelLanguageAliases);
}

public string SerializeDib(InteractiveDocument interactive, string newLine)
Expand Down Expand Up @@ -193,11 +193,13 @@ public void empty_lines_are_removed_between_cells()
});
}

[Fact]
public void markdown_cells_can_be_parsed_even_though_its_not_a_kernel_language()
[Theory]
[InlineData("markdown")]
[InlineData("md")]
public void markdown_cells_can_be_parsed_even_though_its_not_a_kernel_language(string cellLanguage)
{
var notebook = ParseDib(@"
#!markdown
var notebook = ParseDib($@"
#!{cellLanguage}
This is `markdown`.
");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ protected DocumentFormatTestsBase()
new("csharp", new[] { "cs", "C#", "c#" }),
new("fsharp", new[] { "fs", "F#", "f#" }),
new("pwsh", new[] { "powershell" }),
new("markdown", new[] { "md" }),
};
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Microsoft.DotNet.Interactive.Documents/CodeSubmission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ void AddElement()
}
}

var mapOfKernelNamesByAlias = kernelNames.ToMapOfKernelNamesByAlias();
var splittingKernelNames = kernelNames.ToList();
splittingKernelNames.Add(new KernelName("markdown", new[] { "md" })); // not a kernel language, but still a valid cell splitter
var mapOfKernelNamesByAlias = splittingKernelNames.ToMapOfKernelNamesByAlias();

foreach (var line in lines)
{
Expand Down

0 comments on commit 0512fe0

Please sign in to comment.