mirror of https://github.com/status-im/NimYAML.git
Fixed bugs with presenting block scalars
* Folded block scalars were presented with "|" instead of ">" * It has not been properly detected that a scalar cannot be outputted as literal block scalar
This commit is contained in:
parent
4d4e3c94e1
commit
5688499650
|
@ -59,7 +59,7 @@ proc inspect(scalar: string, indentation: int,
|
||||||
if not inLine: curLine.start = i
|
if not inLine: curLine.start = i
|
||||||
inLine = false
|
inLine = false
|
||||||
curLine.finish = i - 1
|
curLine.finish = i - 1
|
||||||
if curLine.start - curLine.finish + 1 > 80 - indentation:
|
if curLine.finish - curLine.start + 1 > 80 - indentation:
|
||||||
canUseLiteral = false
|
canUseLiteral = false
|
||||||
lines.add(curLine)
|
lines.add(curLine)
|
||||||
else:
|
else:
|
||||||
|
@ -180,7 +180,9 @@ proc writeFolded(scalar: string, indentation, indentStep: int, s: Stream,
|
||||||
words: seq[tuple[start, finish: int]], newline: string)
|
words: seq[tuple[start, finish: int]], newline: string)
|
||||||
{.raises: [YamlPresenterOutputError].} =
|
{.raises: [YamlPresenterOutputError].} =
|
||||||
try:
|
try:
|
||||||
s.write("|-")
|
s.write(">")
|
||||||
|
if scalar[^1] != '\l': s.write('-')
|
||||||
|
if scalar[0] in [' ', '\t']: s.write($indentStep)
|
||||||
var curPos = 80
|
var curPos = 80
|
||||||
for word in words:
|
for word in words:
|
||||||
if word.start > 0 and scalar[word.start - 1] == '\l':
|
if word.start > 0 and scalar[word.start - 1] == '\l':
|
||||||
|
@ -579,7 +581,7 @@ proc present*(s: var YamlStream, target: Stream, tagLib: TagLibrary,
|
||||||
indentation -= options.indentationStep
|
indentation -= options.indentationStep
|
||||||
safeWrite('}')
|
safeWrite('}')
|
||||||
of dBlockMapValue, dBlockInlineMap: discard
|
of dBlockMapValue, dBlockInlineMap: discard
|
||||||
else: assert false
|
else: assert(false)
|
||||||
indentation -= options.indentationStep
|
indentation -= options.indentationStep
|
||||||
of yamlEndDoc:
|
of yamlEndDoc:
|
||||||
if finished(s): break
|
if finished(s): break
|
||||||
|
|
Loading…
Reference in New Issue