[backend/libmfm] Fix code block serialization
This commit is contained in:
parent
50cfc6df92
commit
5599805196
2 changed files with 24 additions and 1 deletions
|
@ -17,7 +17,7 @@ public static class MfmSerializer
|
|||
{
|
||||
result.Append($"```{mfmCodeBlockNode.Language?.Value ?? ""}\n");
|
||||
result.Append(mfmCodeBlockNode.Code);
|
||||
result.Append("```");
|
||||
result.Append("\n```");
|
||||
break;
|
||||
}
|
||||
case MfmMathBlockNode mfmMathBlockNode:
|
||||
|
|
|
@ -93,6 +93,29 @@ public class MfmTests
|
|||
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCodeBlock()
|
||||
{
|
||||
const string input = """
|
||||
test 123
|
||||
```
|
||||
this is a code block
|
||||
```
|
||||
test 123
|
||||
""";
|
||||
List<MfmNode> expected =
|
||||
[
|
||||
new MfmTextNode("test 123\n"),
|
||||
new MfmCodeBlockNode("this is a code block", null),
|
||||
new MfmTextNode("\ntest 123")
|
||||
];
|
||||
var res = Mfm.parse(input);
|
||||
|
||||
AssertionOptions.FormattingOptions.MaxDepth = 100;
|
||||
res.ToList().Should().Equal(expected, MfmNodeEqual);
|
||||
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Benchmark()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue