[parsing/mfm] Further improve codeblock newline handling

This commit is contained in:
Laura Hausmann 2024-09-26 00:37:25 +02:00
parent 0fc667527f
commit 5b3dec0a08
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 3 additions and 3 deletions

View file

@ -17,7 +17,7 @@ public static class MfmSerializer
{
result.Append($"\n```{mfmCodeBlockNode.Language?.Value ?? ""}\n");
result.Append(mfmCodeBlockNode.Code);
result.Append("\n```\n");
result.Append("\n```\n\n");
break;
}
case MfmMathBlockNode mfmMathBlockNode:

View file

@ -208,7 +208,7 @@ module private MfmParser =
>>. opt (many1CharsTill asciiLetter (lookAhead newline))
.>>. (skipNewline
>>. manyCharsTill anyChar (attempt (skipNewline >>. skipString "```")))
.>> (opt <| attempt (skipNewline >>. nextCharSatisfies isNewline))
.>> (opt <| attempt (skipNewline >>. skipNewline))
|>> fun (lang: string option, code: string) -> MfmCodeBlockNode(code, lang) :> MfmNode
let mathNode =

View file

@ -153,7 +153,7 @@ public class MfmTests
[
new MfmTextNode("test 123\n"),
new MfmCodeBlockNode("this is a code block", null),
new MfmTextNode("\ntest 123")
new MfmTextNode("test 123")
];
var res = Mfm.parse(input);