flyx / NimYAML

YAML implementation for Nim
https://nimyaml.org
Other
186 stars 36 forks source link

Need some help for cusomizing output of yaml file #94

Closed dmknght closed 3 years ago

dmknght commented 3 years ago

Hi! I installed this lib using nimble install yaml@#head. My nim version is 1.4.2 debian. My yaml file is setting of other python project so format needs to be kept for compatible so i'm having some issues:

  1. I am having a bool object, which should be true or false but the dump saved output as n (maybe y, n?). How can i set the value to true and false? I don't think it was mentioned in example at https://nimyaml.org/index.html.
  2. Present style auto add %TAG and ---- unless i choose psJson but i want to save it as YAML file with no extra data was added by this lib. Is there anyway can do it? My dump for now: dump(config, fileStream, tagStyle = tsNone, options = defineOptions(style = psBlockOnly, outputVersion = ovNone))
dmknght commented 3 years ago

P/s: for now the output works for me. I think the ovNone made it work.

flyx commented 3 years ago

This is a genuine bug. While YAML 1.1 promoted y / n as standard bool representations, YAML 1.2 doesn't allow them anymore for good reason and instead promotes true / false. Since this is primarily a YAML 1.2 implementation, I changed it to true / false in commit 03ecab0075eccd94f78d347d9c68ccd6f6999d1f

flyx commented 3 years ago

Regarding the handles: Please open a separate issue and show your code. The %TAG is independent of outputVersion and shouldn't be emitted unless required. tagStyle can be relevant, but without seeing what you're doing, it's hard to say what's the cause.

dmknght commented 3 years ago

@flyx thank you! The commit fixed the y, n issue. I'm checking the %TAG again