diff --git a/private/fastparse.nim b/private/fastparse.nim index f0fba90..9f0ea53 100644 --- a/private/fastparse.nim +++ b/private/fastparse.nim @@ -1174,6 +1174,12 @@ proc parse*(p: YamlParser, s: Stream): YamlStream = else: ensureCorrectIndentation() state = fpBlockObjectStart + of EndOfFile: + closeEverything() + break + of '\t', '\x0A', '\c', '#': + p.lexer.lineEnding() + handleLineEnd(true) else: indentation = 0 closeMoreIndentedLevels() diff --git a/test/parsing.nim b/test/parsing.nim index 123bd6f..b823f18 100644 --- a/test/parsing.nim +++ b/test/parsing.nim @@ -263,4 +263,11 @@ suite "Parsing": test "Parsing: Whitespace before end of flow content": ensure("- [a, b, c ]", startDocEvent(), startSeqEvent(), startSeqEvent(), scalarEvent("a"), scalarEvent("b"), - scalarEvent("c"), endSeqEvent(), endSeqEvent(), endDocEvent()) \ No newline at end of file + scalarEvent("c"), endSeqEvent(), endSeqEvent(), endDocEvent()) + test "Parsing: Empty lines after document": + ensure(":\n\n", startDocEvent(), startMapEvent(), scalarEvent(""), + scalarEvent(""), endMapEvent(), endDocEvent()) + test "Parsing: Empty lines between map elements": + ensure("1: 2\n\n\n3: 4", startDocEvent(), startMapEvent(), + scalarEvent("1"), scalarEvent("2"), scalarEvent("3"), + scalarEvent("4"), endMapEvent(), endDocEvent()) \ No newline at end of file