ruby/psych

Prevent snakeYAML add backslash when dump multiple line string

yvesll opened this issue · 1 comments

yvesll commented

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:

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.