diff --git a/private/lex.nim b/private/lex.nim index 048e7e1..dc3444f 100644 --- a/private/lex.nim +++ b/private/lex.nim @@ -792,7 +792,7 @@ proc blockScalarHeader[T](lex: YamlLexer): bool = of '1'..'9': if lex.blockScalarIndent != UnknownIndentation: raise generateError[T](lex, "Only one indentation indicator is allowed") - lex.blockScalarIndent = ord(lex.c) - ord('\x30') + lex.blockScalarIndent = ord(lex.c) - ord('\x30') + lex.indentation of spaceOrLineEnd: break else: raise generateError[T](lex, @@ -870,6 +870,7 @@ proc blockScalarLineStart[T](lex: YamlLexer, recentWasMoreIndented: var bool): proc blockScalar[T](lex: YamlLexer): bool = debug("lex: blockScalar") + lex.indentation = 0 block outer: var recentWasMoreIndented = true if lex.blockScalarIndent == UnknownIndentation: @@ -895,8 +896,6 @@ proc blockScalar[T](lex: YamlLexer): bool = break outer lex.indentation = lex.blockScalarIndent break - else: - lex.blockScalarIndent += lex.indentation if lex.c notin {'.', '-'} or lex.indentation == 0: if not blockScalarLineStart[T](lex, recentWasMoreIndented): break outer else: diff --git a/yaml/presenter.nim b/yaml/presenter.nim index 74e51c4..ad59f59 100644 --- a/yaml/presenter.nim +++ b/yaml/presenter.nim @@ -761,8 +761,11 @@ proc doTransform(input: Stream | string, output: PresenterTarget, event.scalarTag = yTagString BufferYamlStream(bys).put(event) else: BufferYamlStream(bys).put(e) - present(bys, output, tagLib, options) - else: present(events, output, tagLib, options) + when output is ptr[string]: output[] = present(bys, tagLib, options) + else: present(bys, output, tagLib, options) + else: + when output is ptr[string]: output[] = present(events, tagLib, options) + else: present(events, output, tagLib, options) except YamlStreamError: var e = getCurrentException() while e.parent of YamlStreamError: e = e.parent