mirror of https://github.com/status-im/NimYAML.git
Root block scalars may have indentation of 0
This commit is contained in:
parent
415acdb19a
commit
22b8de876d
|
@ -165,7 +165,7 @@ template closeMoreIndentedLevels(atSequenceItem: bool = false) {.dirty.} =
|
||||||
template closeEverything() {.dirty.} =
|
template closeEverything() {.dirty.} =
|
||||||
indentation = 0
|
indentation = 0
|
||||||
closeMoreIndentedLevels()
|
closeMoreIndentedLevels()
|
||||||
yieldLevelEnd()
|
if level.kind != fplUnknown: yieldLevelEnd()
|
||||||
yield endDocEvent()
|
yield endDocEvent()
|
||||||
|
|
||||||
template handleBlockSequenceIndicator() {.dirty.} =
|
template handleBlockSequenceIndicator() {.dirty.} =
|
||||||
|
@ -834,7 +834,7 @@ template blockScalar(lexer: BaseLexer, content: var string,
|
||||||
detectedIndent = false
|
detectedIndent = false
|
||||||
recentLineMoreIndented = false
|
recentLineMoreIndented = false
|
||||||
let parentIndent = if ancestry.len > 0:
|
let parentIndent = if ancestry.len > 0:
|
||||||
ancestry[ancestry.high].indentation else: 0
|
ancestry[ancestry.high].indentation else: -1
|
||||||
|
|
||||||
case lexer.buf[lexer.bufpos]
|
case lexer.buf[lexer.bufpos]
|
||||||
of '|': literal = true
|
of '|': literal = true
|
||||||
|
@ -912,7 +912,7 @@ template blockScalar(lexer: BaseLexer, content: var string,
|
||||||
break outer
|
break outer
|
||||||
else:
|
else:
|
||||||
if i == 1:
|
if i == 1:
|
||||||
stateAfter = if parentIndent == 0: fpBlockLineStart else:
|
stateAfter = if parentIndent <= 0: fpBlockLineStart else:
|
||||||
fpBlockObjectStart
|
fpBlockObjectStart
|
||||||
break outer
|
break outer
|
||||||
else:
|
else:
|
||||||
|
@ -935,9 +935,10 @@ template blockScalar(lexer: BaseLexer, content: var string,
|
||||||
stateAfter = fpBlockLineStart
|
stateAfter = fpBlockLineStart
|
||||||
break outer
|
break outer
|
||||||
else:
|
else:
|
||||||
blockIndent = lexer.getColNumber(lexer.bufpos) - parentIndent
|
blockIndent =
|
||||||
|
lexer.getColNumber(lexer.bufpos) - max(0, parentIndent)
|
||||||
if blockIndent == 0:
|
if blockIndent == 0:
|
||||||
stateAfter = if blockIndent + parentIndent > 0:
|
stateAfter = if blockIndent + max(0, parentIndent) > 0:
|
||||||
fpBlockObjectStart else: fpBlockLineStart
|
fpBlockObjectStart else: fpBlockLineStart
|
||||||
break outer
|
break outer
|
||||||
detectedIndent = true
|
detectedIndent = true
|
||||||
|
|
Loading…
Reference in New Issue