Handle more indented lines in folded block scalars

This commit is contained in:
Felix Krause 2016-03-10 21:20:14 +01:00
parent 491c5f5e3a
commit 3a8781ba6e
1 changed files with 11 additions and 1 deletions

View File

@ -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(' ')