2015-12-28 21:24:05 +00:00
|
|
|
# NimYAML - YAML implementation in Nim
|
|
|
|
# (c) Copyright 2015 Felix Krause
|
|
|
|
#
|
|
|
|
# See the file "copying.txt", included in this
|
|
|
|
# distribution, for details about the copyright.
|
|
|
|
|
2015-12-27 15:36:32 +00:00
|
|
|
type
|
|
|
|
DumperState = enum
|
|
|
|
dBlockExplicitMapKey, dBlockExplicitMapValue, dBlockImplicitMapKey,
|
|
|
|
dBlockImplicitMapValue, dBlockSequenceItem, dFlowImplicitMapKey,
|
|
|
|
dFlowImplicitMapValue, dFlowExplicitMapKey, dFlowExplicitMapValue,
|
|
|
|
dFlowSequenceItem, dFlowImplicitMapStart, dFlowExplicitMapStart,
|
|
|
|
dFlowSequenceStart
|
|
|
|
|
|
|
|
proc needsEscaping(scalar: string): bool =
|
2015-12-29 17:22:55 +00:00
|
|
|
scalar.len == 0 or
|
|
|
|
scalar.find({'{', '}', '[', ']', ',', '#', '-', ':', '?', '%',
|
|
|
|
'\x0A', '\c'}) != -1
|
2015-12-27 15:36:32 +00:00
|
|
|
|
|
|
|
proc writeDoubleQuoted(scalar: string, s: Stream) =
|
|
|
|
s.write('"')
|
|
|
|
for c in scalar:
|
|
|
|
if c == '"':
|
|
|
|
s.write('\\')
|
|
|
|
s.write(c)
|
|
|
|
s.write('"')
|
|
|
|
|
2016-01-04 20:46:33 +00:00
|
|
|
proc startItem(target: Stream, style: YamlPresentationStyle, indentation: int,
|
2015-12-27 15:36:32 +00:00
|
|
|
state: var DumperState) =
|
|
|
|
case state
|
|
|
|
of dBlockExplicitMapValue:
|
|
|
|
target.write('\x0A')
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
target.write("? ")
|
|
|
|
state = dBlockExplicitMapKey
|
|
|
|
of dBlockExplicitMapKey:
|
|
|
|
target.write('\x0A')
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
target.write(": ")
|
|
|
|
state = dBlockExplicitMapValue
|
|
|
|
of dBlockImplicitMapValue:
|
|
|
|
target.write('\x0A')
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
state = dBlockImplicitMapKey
|
|
|
|
of dBlockImplicitMapKey:
|
|
|
|
target.write(": ")
|
|
|
|
state = dBlockImplicitMapValue
|
|
|
|
of dFlowExplicitMapKey:
|
|
|
|
target.write('\x0A')
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
target.write(": ")
|
|
|
|
state = dFlowExplicitMapValue
|
|
|
|
of dFlowExplicitMapValue:
|
|
|
|
target.write(",\x0A")
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
target.write("? ")
|
|
|
|
state = dFlowExplicitMapKey
|
|
|
|
of dFlowImplicitMapStart:
|
2016-01-04 20:46:33 +00:00
|
|
|
if style == ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write("\x0A")
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
state = dFlowImplicitMapKey
|
|
|
|
of dFlowExplicitMapStart:
|
|
|
|
target.write('\x0A')
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
target.write("? ")
|
|
|
|
state = dFlowExplicitMapKey
|
|
|
|
of dFlowImplicitMapKey:
|
|
|
|
target.write(": ")
|
|
|
|
state = dFlowImplicitMapValue
|
|
|
|
of dFlowImplicitMapValue:
|
2016-01-04 20:46:33 +00:00
|
|
|
if style == ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write(",\x0A")
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
else:
|
|
|
|
target.write(", ")
|
|
|
|
state = dFlowImplicitMapKey
|
|
|
|
of dBlockSequenceItem:
|
|
|
|
target.write('\x0A')
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
target.write("- ")
|
|
|
|
of dFlowSequenceStart:
|
|
|
|
case style
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsMinimal, ypsDefault:
|
2015-12-27 15:36:32 +00:00
|
|
|
discard
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsCanonical, ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write('\x0A')
|
|
|
|
target.write(repeat(' ', indentation))
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsBlockOnly:
|
2015-12-27 15:36:32 +00:00
|
|
|
discard # can never happen
|
|
|
|
state = dFlowSequenceItem
|
|
|
|
of dFlowSequenceItem:
|
|
|
|
case style
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsMinimal, ypsDefault:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write(", ")
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsCanonical, ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write(",\x0A")
|
|
|
|
target.write(repeat(' ', indentation))
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsBlockOnly:
|
2015-12-27 15:36:32 +00:00
|
|
|
discard # can never happen
|
|
|
|
|
|
|
|
proc writeTagAndAnchor(target: Stream, tag: TagId, tagLib: YamlTagLibrary,
|
|
|
|
anchor: AnchorId) =
|
2015-12-27 22:40:27 +00:00
|
|
|
if tag notin [yTagQuestionMark, yTagExclamationMark]:
|
2015-12-27 15:36:32 +00:00
|
|
|
let tagUri = tagLib.uri(tag)
|
2016-01-04 20:46:33 +00:00
|
|
|
if tagUri.startsWith(tagLib.secondaryPrefix):
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write("!!")
|
|
|
|
target.write(tagUri[18..^1])
|
|
|
|
target.write(' ')
|
2016-01-04 20:46:33 +00:00
|
|
|
elif tagUri.startsWith("!"):
|
|
|
|
target.write(tagUri)
|
|
|
|
target.write(' ')
|
2015-12-27 15:36:32 +00:00
|
|
|
else:
|
|
|
|
target.write("!<")
|
|
|
|
target.write(tagUri)
|
|
|
|
target.write("> ")
|
2015-12-27 22:40:27 +00:00
|
|
|
if anchor != yAnchorNone:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write("&")
|
|
|
|
# TODO: properly select an anchor
|
|
|
|
target.write(cast[byte]('a') + cast[byte](anchor))
|
|
|
|
target.write(' ')
|
|
|
|
|
2015-12-29 17:22:55 +00:00
|
|
|
proc present*(s: YamlStream, target: Stream, tagLib: YamlTagLibrary,
|
2016-01-04 20:46:33 +00:00
|
|
|
style: YamlPresentationStyle = ypsDefault,
|
|
|
|
indentationStep: int = 2) =
|
2015-12-27 15:36:32 +00:00
|
|
|
var
|
|
|
|
cached = initQueue[YamlStreamEvent]()
|
|
|
|
cacheIterator = iterator(): YamlStreamEvent =
|
|
|
|
while true:
|
|
|
|
while cached.len > 0:
|
|
|
|
yield cached.dequeue()
|
|
|
|
let item = s()
|
|
|
|
if finished(s):
|
|
|
|
break
|
|
|
|
cached.enqueue(item)
|
|
|
|
indentation = 0
|
|
|
|
levels = newSeq[DumperState]()
|
|
|
|
|
|
|
|
for item in cacheIterator():
|
|
|
|
case item.kind
|
|
|
|
of yamlStartDocument:
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
# TODO: tag directives
|
2016-01-04 20:46:33 +00:00
|
|
|
target.write("%YAML 1.2\x0A")
|
|
|
|
if tagLib.secondaryPrefix != yamlTagRepositoryPrefix:
|
|
|
|
target.write("%TAG !! " & tagLib.secondaryPrefix & '\x0A')
|
|
|
|
target.write("--- ")
|
2015-12-27 15:36:32 +00:00
|
|
|
of yamlScalar:
|
|
|
|
if levels.len == 0:
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write('\x0A')
|
|
|
|
else:
|
|
|
|
startItem(target, style, indentation, levels[levels.high])
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
writeTagAndAnchor(target,
|
|
|
|
item.scalarTag, tagLib, item.scalarAnchor)
|
|
|
|
|
2016-01-05 18:06:55 +00:00
|
|
|
if style == ypsJson:
|
|
|
|
if item.scalarTag in [yTagQuestionMark, yTagBoolean] and
|
|
|
|
item.scalarType in [yTypeBoolTrue, yTypeBoolFalse]:
|
|
|
|
if item.scalarType == yTypeBoolTrue:
|
|
|
|
target.write("true")
|
|
|
|
else:
|
|
|
|
target.write("false")
|
|
|
|
elif item.scalarTag in [yTagQuestionMark, yTagNull] and
|
|
|
|
item.scalarType == yTypeNull:
|
|
|
|
target.write("null")
|
|
|
|
elif item.scalarTag in [yTagQuestionMark, yTagFloat] and
|
|
|
|
item.scalarType in [yTypeFloatInf, yTypeFloatNaN]:
|
|
|
|
raise newException(YamlPresenterError,
|
|
|
|
"Infinity and not-a-number values cannot be presented as JSON!")
|
2015-12-29 17:22:55 +00:00
|
|
|
else:
|
2016-01-05 18:06:55 +00:00
|
|
|
target.write(item.scalarContent)
|
2016-01-04 20:46:33 +00:00
|
|
|
elif style == ypsCanonical or item.scalarContent.needsEscaping or
|
|
|
|
(style == ypsJson and
|
2015-12-29 17:22:55 +00:00
|
|
|
(item.scalarTag notin [yTagQuestionMark, yTagInteger, yTagFloat,
|
|
|
|
yTagBoolean, yTagNull] or
|
|
|
|
(item.scalarTag == yTagQuestionMark and item.scalarType notin
|
|
|
|
[yTypeBoolFalse, yTypeBoolTrue, yTypeInteger, yTypeFloat,
|
|
|
|
yTypeNull]))):
|
2015-12-27 15:36:32 +00:00
|
|
|
writeDoubleQuoted(item.scalarContent, target)
|
|
|
|
else:
|
|
|
|
target.write(item.scalarContent)
|
|
|
|
of yamlAlias:
|
2016-01-05 18:06:55 +00:00
|
|
|
assert levels.len > 0
|
|
|
|
startItem(target, style, indentation, levels[levels.high])
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write('*')
|
|
|
|
target.write(cast[byte]('a') + cast[byte](item.aliasTarget))
|
|
|
|
of yamlStartSequence:
|
|
|
|
var nextState: DumperState
|
|
|
|
case style
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsDefault:
|
2015-12-27 15:36:32 +00:00
|
|
|
var length = 0
|
|
|
|
while true:
|
|
|
|
let next = s()
|
2016-01-05 18:06:55 +00:00
|
|
|
assert (not finished(s))
|
2015-12-27 15:36:32 +00:00
|
|
|
cached.enqueue(next)
|
|
|
|
case next.kind
|
|
|
|
of yamlScalar:
|
|
|
|
length += 2 + next.scalarContent.len
|
|
|
|
of yamlAlias:
|
|
|
|
length += 6
|
|
|
|
of yamlEndSequence:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
length = int.high
|
|
|
|
break
|
|
|
|
nextState = if length <= 60: dFlowSequenceStart else:
|
|
|
|
dBlockSequenceItem
|
2016-01-05 18:06:55 +00:00
|
|
|
of ypsJson:
|
|
|
|
if levels[levels.high] in
|
|
|
|
[dFlowImplicitMapStart, dFlowImplicitMapValue]:
|
|
|
|
raise newException(YamlPresenterError,
|
|
|
|
"Cannot have sequence as map key in JSON output!")
|
|
|
|
nextState = dFlowSequenceStart
|
|
|
|
of ypsMinimal, ypsCanonical:
|
2015-12-27 15:36:32 +00:00
|
|
|
nextState = dFlowSequenceStart
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsBlockOnly:
|
2015-12-27 15:36:32 +00:00
|
|
|
nextState = dBlockSequenceItem
|
|
|
|
|
|
|
|
if levels.len == 0:
|
|
|
|
if nextState == dBlockSequenceItem:
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
writeTagAndAnchor(target,
|
|
|
|
item.seqTag, tagLib, item.seqAnchor)
|
|
|
|
else:
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
writeTagAndAnchor(target,
|
|
|
|
item.seqTag, tagLib, item.seqAnchor)
|
2015-12-29 17:22:55 +00:00
|
|
|
target.write('\x0A')
|
2015-12-27 15:36:32 +00:00
|
|
|
indentation += indentationStep
|
|
|
|
else:
|
2015-12-29 17:22:55 +00:00
|
|
|
startItem(target, style, indentation, levels[levels.high])
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-29 17:22:55 +00:00
|
|
|
writeTagAndAnchor(target,
|
|
|
|
item.seqTag, tagLib, item.seqAnchor)
|
2015-12-27 15:36:32 +00:00
|
|
|
indentation += indentationStep
|
|
|
|
|
|
|
|
if nextState == dFlowSequenceStart:
|
|
|
|
target.write('[')
|
2016-01-04 20:46:33 +00:00
|
|
|
if levels.len > 0 and style in [ypsJson, ypsCanonical] and
|
2015-12-27 15:36:32 +00:00
|
|
|
levels[levels.high] in
|
|
|
|
[dBlockExplicitMapKey, dBlockExplicitMapValue,
|
|
|
|
dBlockImplicitMapKey, dBlockImplicitMapValue,
|
|
|
|
dBlockSequenceItem]:
|
|
|
|
indentation += indentationStep
|
|
|
|
levels.add(nextState)
|
|
|
|
of yamlStartMap:
|
|
|
|
var nextState: DumperState
|
|
|
|
case style
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsDefault:
|
2015-12-27 15:36:32 +00:00
|
|
|
var length = 0
|
|
|
|
while true:
|
|
|
|
let next = s()
|
2016-01-05 18:06:55 +00:00
|
|
|
assert (not finished(s))
|
2015-12-27 15:36:32 +00:00
|
|
|
cached.enqueue(next)
|
|
|
|
case next.kind
|
|
|
|
of yamlScalar:
|
|
|
|
length += 2 + next.scalarContent.len
|
|
|
|
of yamlAlias:
|
|
|
|
length += 6
|
|
|
|
of yamlEndMap:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
length = int.high
|
|
|
|
break
|
|
|
|
nextState = if length <= 60: dFlowImplicitMapStart else:
|
|
|
|
if item.mapMayHaveKeyObjects:
|
|
|
|
dBlockExplicitMapValue else: dBlockImplicitMapValue
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsMinimal:
|
2015-12-27 15:36:32 +00:00
|
|
|
nextState = if item.mapMayHaveKeyObjects:
|
|
|
|
dFlowExplicitMapStart else: dFlowImplicitMapStart
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsCanonical:
|
2015-12-27 15:36:32 +00:00
|
|
|
nextState = dFlowExplicitMapStart
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsJson:
|
2016-01-05 18:06:55 +00:00
|
|
|
if levels[levels.high] in
|
|
|
|
[dFlowImplicitMapStart, dFlowImplicitMapValue]:
|
|
|
|
raise newException(YamlPresenterError,
|
|
|
|
"Cannot have map as map key in JSON output!")
|
2015-12-27 15:36:32 +00:00
|
|
|
nextState = dFlowImplicitMapStart
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsBlockOnly:
|
2015-12-27 15:36:32 +00:00
|
|
|
nextState = if item.mapMayHaveKeyObjects:
|
|
|
|
dBlockExplicitMapValue else: dBlockImplicitMapValue
|
|
|
|
|
|
|
|
if levels.len == 0:
|
|
|
|
if nextState in
|
|
|
|
[dBlockExplicitMapValue, dBlockImplicitMapValue]:
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
writeTagAndAnchor(target,
|
|
|
|
item.mapTag, tagLib, item.mapAnchor)
|
|
|
|
else:
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write('\x0A')
|
|
|
|
writeTagAndAnchor(target,
|
|
|
|
item.mapTag, tagLib, item.mapAnchor)
|
|
|
|
indentation += indentationStep
|
|
|
|
else:
|
|
|
|
if nextState in
|
2015-12-29 17:22:55 +00:00
|
|
|
[dBlockExplicitMapValue, dBlockImplicitMapValue,
|
|
|
|
dBlockImplicitMapKey]:
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
writeTagAndAnchor(target,
|
|
|
|
item.mapTag, tagLib, item.mapAnchor)
|
|
|
|
startItem(target, style, indentation, levels[levels.high])
|
|
|
|
else:
|
|
|
|
startItem(target, style, indentation, levels[levels.high])
|
2016-01-04 20:46:33 +00:00
|
|
|
if style != ypsJson:
|
2015-12-27 15:36:32 +00:00
|
|
|
writeTagAndAnchor(target,
|
|
|
|
item.mapTag, tagLib, item.mapAnchor)
|
|
|
|
indentation += indentationStep
|
|
|
|
|
|
|
|
if nextState in [dFlowImplicitMapStart, dFlowExplicitMapStart]:
|
|
|
|
target.write('{')
|
2016-01-04 20:46:33 +00:00
|
|
|
if levels.len > 0 and style in [ypsJson, ypsCanonical] and
|
2015-12-27 15:36:32 +00:00
|
|
|
levels[levels.high] in
|
|
|
|
[dBlockExplicitMapKey, dBlockExplicitMapValue,
|
|
|
|
dBlockImplicitMapKey, dBlockImplicitMapValue,
|
|
|
|
dBlockSequenceItem]:
|
|
|
|
indentation += indentationStep
|
|
|
|
levels.add(nextState)
|
|
|
|
|
|
|
|
of yamlEndSequence:
|
2016-01-05 18:06:55 +00:00
|
|
|
assert levels.len > 0
|
2015-12-27 15:36:32 +00:00
|
|
|
case levels.pop()
|
|
|
|
of dFlowSequenceItem:
|
|
|
|
case style
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsDefault, ypsMinimal, ypsBlockOnly:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write(']')
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsJson, ypsCanonical:
|
2015-12-27 15:36:32 +00:00
|
|
|
indentation -= indentationStep
|
|
|
|
target.write('\x0A')
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
target.write(']')
|
|
|
|
if levels.len == 0 or levels[levels.high] notin
|
|
|
|
[dBlockExplicitMapKey, dBlockExplicitMapValue,
|
|
|
|
dBlockImplicitMapKey, dBlockImplicitMapValue,
|
|
|
|
dBlockSequenceItem]:
|
|
|
|
continue
|
|
|
|
of dFlowSequenceStart:
|
2016-01-04 20:46:33 +00:00
|
|
|
if levels.len > 0 and style in [ypsJson, ypsCanonical] and
|
2015-12-27 15:36:32 +00:00
|
|
|
levels[levels.high] in
|
|
|
|
[dBlockExplicitMapKey, dBlockExplicitMapValue,
|
|
|
|
dBlockImplicitMapKey, dBlockImplicitMapValue,
|
|
|
|
dBlockSequenceItem]:
|
|
|
|
indentation -= indentationStep
|
|
|
|
target.write(']')
|
|
|
|
of dBlockSequenceItem:
|
|
|
|
discard
|
|
|
|
else:
|
2016-01-05 18:06:55 +00:00
|
|
|
assert false
|
2015-12-27 15:36:32 +00:00
|
|
|
indentation -= indentationStep
|
|
|
|
of yamlEndMap:
|
2016-01-05 18:06:55 +00:00
|
|
|
assert levels.len > 0
|
2015-12-27 15:36:32 +00:00
|
|
|
case levels.pop()
|
|
|
|
of dFlowImplicitMapValue, dFlowExplicitMapValue:
|
|
|
|
case style
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsDefault, ypsMinimal, ypsBlockOnly:
|
2015-12-27 15:36:32 +00:00
|
|
|
target.write('}')
|
2016-01-04 20:46:33 +00:00
|
|
|
of ypsJson, ypsCanonical:
|
2015-12-27 15:36:32 +00:00
|
|
|
indentation -= indentationStep
|
|
|
|
target.write('\x0A')
|
|
|
|
target.write(repeat(' ', indentation))
|
|
|
|
target.write('}')
|
|
|
|
if levels.len == 0 or levels[levels.high] notin
|
|
|
|
[dBlockExplicitMapKey, dBlockExplicitMapValue,
|
|
|
|
dBlockImplicitMapKey, dBlockImplicitMapValue,
|
|
|
|
dBlockSequenceItem]:
|
|
|
|
continue
|
|
|
|
of dFlowImplicitMapStart, dFlowExplicitMapStart:
|
2016-01-04 20:46:33 +00:00
|
|
|
if levels.len > 0 and style in [ypsJson, ypsCanonical] and
|
2015-12-27 15:36:32 +00:00
|
|
|
levels[levels.high] in
|
|
|
|
[dBlockExplicitMapKey, dBlockExplicitMapValue,
|
|
|
|
dBlockImplicitMapKey, dBlockImplicitMapValue,
|
|
|
|
dBlockSequenceItem]:
|
|
|
|
indentation -= indentationStep
|
|
|
|
target.write('}')
|
|
|
|
of dBlockImplicitMapValue, dBlockExplicitMapValue:
|
|
|
|
discard
|
|
|
|
else:
|
2016-01-05 18:06:55 +00:00
|
|
|
assert false
|
2015-12-27 15:36:32 +00:00
|
|
|
indentation -= indentationStep
|
|
|
|
of yamlEndDocument:
|
|
|
|
let next = s()
|
|
|
|
if finished(s):
|
|
|
|
break
|
|
|
|
target.write("...\x0A")
|
|
|
|
cached.enqueue(next)
|
|
|
|
|
2016-01-04 20:46:33 +00:00
|
|
|
proc transform*(input: Stream, output: Stream, style: YamlPresentationStyle,
|
2015-12-27 15:36:32 +00:00
|
|
|
indentationStep: int = 2) =
|
|
|
|
var
|
|
|
|
tagLib = extendedTagLibrary()
|
|
|
|
parser = newParser(tagLib)
|
2015-12-29 17:22:55 +00:00
|
|
|
present(parser.parse(input), output, tagLib, style,
|
|
|
|
indentationStep)
|