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

Prevent snakeYAML add backslash when dump multiple line string #642

Open
yvesll opened this issue Jul 25, 2023 · 1 comment
Open

Prevent snakeYAML add backslash when dump multiple line string #642

yvesll opened this issue Jul 25, 2023 · 1 comment

Comments

@yvesll
Copy link

yvesll commented Jul 25, 2023

Given the following input

key:
  "/Psych is a YAML parser and emitter. Psych leverages libyaml 
  for its YAML parsing and emitting capabilities. In addition to wrapping 
  libyaml, Psych also knows how to serialize and de-serialize most Ruby 
  objects to and from the YAML format./"
empty_key:

Then load and dump it:
Within MRI ruby, the output is:

---
key: "/Psych is a YAML parser and emitter. Psych leverages libyaml for its YAML parsing
  and emitting capabilities. In addition to wrapping libyaml, Psych also knows how
  to serialize and de-serialize most Ruby objects to and from the YAML format./"
empty_key: #An empty space was added here.

But in jruby, the result is a little different:

---
key: "/Psych is a YAML parser and emitter. Psych leverages libyaml for its YAML parsing\
  \ and emitting capabilities. In addition to wrapping libyaml, Psych also knows how\
  \ to serialize and de-serialize most Ruby objects to and from the YAML format./"
empty_key:

There are two differences:

  1. Jruby added backslashes for new line
  2. MRI ruby added a space after empty_key:
@headius
Copy link
Contributor

headius commented Sep 10, 2023

Could this be something that changed in YAML 1.2? The Psych extension for JRuby moved to a newer version of SnakeYAML (SnakeYAML Engine) that is now YAML 1.2 compliant.

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

No branches or pull requests

2 participants