Closed dmknght closed 3 years ago
The problem is here, where representing anything as a document adds the !n!
shortcut to the document start.
It baffles me a bit that no-one complained about this until now. For all I can remember, this was an early hack to ensure that if the serialization generates NimYAML-specific tags, I will have the prefix available, and I never reworked it to do something more intelligent. The most obvious problem is that tsNone
doesn't lead to exclusion of this prefix. But more generally, the tag shouldn't be included if it isn't used anywhere, for example if you use tsRootOnly
and have a custom tag defined for your root type (via setTagUri
).
I will go and review the tag handling a bit more since I wrote that stuff five years ago, then decide on how to fix this.
You can give handles = @[]
now if you don't want any %TAG
directive in the output. Sadly, tsNone
is not sufficient for dropping the directive since {. implicit .}
types may still require a tag. Inspecting every element beforehand to see if one requires the handle is possible but I decided against implementing it since it would impact performance and it's better to just have the calling code being responsible for the used tag handles since that code should know what kind of tags will be produced by dumping the given value.
@flyx Thank you for the commit. All unexpected data was removed but this ---
My function dump(config, fileStream, tagStyle = tsNone, handles = @[], options = defineOptions(outputVersion = ovNone))
. Is there any option that allow me remove this as well?
And just suggestion: Do you think add \n
to end of file is a good idea?
Nim version: 1.4.2 Debian Yaml data I'm trying read the data from config file then write data to understand how the code work
The saved yaml file has
With
tagStyle tsNone
, i have saved file withFunction call:
dump(config, fileStream, tagStyle = tsNone, options = defineOptions(outputVersion = ovNone))
From https://github.com/flyx/NimYAML/blob/03ecab0075eccd94f78d347d9c68ccd6f6999d1f/yaml/presenter.nim#L480, I can see the code add dataif psStyle != psJson
. I can't see any option from comments or variables that can disable this.