[parsing] Fix multi line code blocks
This commit is contained in:
parent
5599805196
commit
8ec6607548
2 changed files with 22 additions and 1 deletions
|
@ -200,7 +200,7 @@ module private MfmParser =
|
|||
previousCharSatisfiesNot isNotWhitespace
|
||||
>>. skipString "```"
|
||||
>>. opt (many1CharsTill asciiLetter (lookAhead newline))
|
||||
.>>. (skipNewline >>. manyCharsTill anyChar (skipNewline >>. skipString "```"))
|
||||
.>>. (skipNewline >>. manyCharsTill anyChar (attempt <| skipNewline >>. skipString "```"))
|
||||
|>> fun (lang: string option, code: string) -> MfmCodeBlockNode(code, lang) :> MfmNode
|
||||
|
||||
let mathNode =
|
||||
|
|
|
@ -115,6 +115,27 @@ public class MfmTests
|
|||
res.ToList().Should().Equal(expected, MfmNodeEqual);
|
||||
MfmSerializer.Serialize(res).Should().BeEquivalentTo(input);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCodeBlockMultiLine()
|
||||
{
|
||||
const string input = """
|
||||
```cs
|
||||
asd
|
||||
sdf
|
||||
```
|
||||
""";
|
||||
|
||||
List<MfmNode> expected =
|
||||
[
|
||||
new MfmCodeBlockNode("asd\nsdf", "cs")
|
||||
];
|
||||
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