From 8993f928d4c6dd1be723bc531be07ff1ef0fddee Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Sat, 4 Jun 2022 23:14:28 +0200 Subject: [PATCH] properly handle comment after block scalars. fixes #106 --- yaml/private/lex.nim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/yaml/private/lex.nim b/yaml/private/lex.nim index 2261224..d58f61b 100644 --- a/yaml/private/lex.nim +++ b/yaml/private/lex.nim @@ -572,11 +572,10 @@ proc readBlockScalar(lex: var Lexer) = let markerFollows = lex.currentIndentation() == 0 and (lex.dirEndFollows() or lex.docEndFollows()) - if lex.currentIndentation() > lex.indentation and not markerFollows: - if lex.c == '#': - lex.state = expectLineEnd - else: - raise lex.generateError("This line #" & $lex.curStartPos.line & " at " & escape("" & lex.c) & " is less indented than necessary") + if lex.c == '#': + lex.state = expectLineEnd + elif lex.currentIndentation() > lex.indentation and not markerFollows: + raise lex.generateError("This line #" & $lex.curStartPos.line & " at " & escape("" & lex.c) & " is less indented than necessary") elif lex.currentIndentation() == 0: lex.state = lineStart else: