[parsing/mfm] Further improve codeblock newline handling
This commit is contained in:
parent
0fc667527f
commit
5b3dec0a08
3 changed files with 3 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue