mirror of https://github.com/status-im/NimYAML.git
Handle more indented lines in folded block scalars
This commit is contained in:
parent
491c5f5e3a
commit
3a8781ba6e
|
@ -853,6 +853,7 @@ template blockScalar(lexer: BaseLexer, content: var string,
|
||||||
blockIndent = 0
|
blockIndent = 0
|
||||||
chomp: ChompType = ctClip
|
chomp: ChompType = ctClip
|
||||||
detectedIndent = false
|
detectedIndent = false
|
||||||
|
recentLineMoreIndented = false
|
||||||
|
|
||||||
case lexer.buf[lexer.bufpos]
|
case lexer.buf[lexer.bufpos]
|
||||||
of '|': literal = true
|
of '|': literal = true
|
||||||
|
@ -973,7 +974,16 @@ template blockScalar(lexer: BaseLexer, content: var string,
|
||||||
of EndOfFile:
|
of EndOfFile:
|
||||||
stateAfter = fpBlockLineStart
|
stateAfter = fpBlockLineStart
|
||||||
break outer
|
break outer
|
||||||
else: discard
|
of ' ':
|
||||||
|
if not literal:
|
||||||
|
if not recentLineMoreIndented:
|
||||||
|
recentLineMoreIndented = true
|
||||||
|
newlines.inc()
|
||||||
|
else:
|
||||||
|
if not literal:
|
||||||
|
if recentLineMoreIndented:
|
||||||
|
recentLineMoreIndented = false
|
||||||
|
newlines.inc()
|
||||||
if newlines > 0:
|
if newlines > 0:
|
||||||
if literal: content.add(repeat('\l', newlines))
|
if literal: content.add(repeat('\l', newlines))
|
||||||
elif newlines == 1: content.add(' ')
|
elif newlines == 1: content.add(' ')
|
||||||
|
|
Loading…
Reference in New Issue