Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid output with strings that are only a newline. #157

Closed
lud-wj opened this issue Oct 16, 2023 · 3 comments · Fixed by #159
Closed

Invalid output with strings that are only a newline. #157

lud-wj opened this issue Oct 16, 2023 · 3 comments · Fixed by #159

Comments

@lud-wj
Copy link

lud-wj commented Oct 16, 2023

A string that is "\n" will be encoded as |\n but it should be |+\n at least or rather simply "\n"

This code:

Mix.install([{:ymlr, "~> 4.2"}, {:yamerl, "~> 0.10.0"}])
data = %{top: "\n", nested: %{key: "\n"}, correct: "aaa\nbbb"}
yaml = data |> Ymlr.document!()
IO.puts(yaml)
data = :yamerl_constr.string(yaml, str_node_as_binary: true)
IO.inspect(data, label: ~S/loadeddata/)

Produces this:

---
top: |
  
nested:
  key: |
    
correct: |-
  aaa
  bbb

loadeddata: [[{"top", ""}, {"nested", [{"key", ""}]}, {"correct", "aaa\nbbb"}]]
@mruoss
Copy link
Collaborator

mruoss commented Oct 17, 2023

Hey @lud-wj

Yes I see the problem. Let me add a few tests here.

@lud-wj
Copy link
Author

lud-wj commented Oct 17, 2023

Thank you :)

@jlgeering
Copy link
Collaborator

follow up: #160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants