ruby / ruby/psych

Prevent snakeYAML add backslash when dump multiple line string

Open
#642 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

JRuby
Dominant language
Ruby
Stars
597
Forks
223
Avg merge
11h 23m
Merged PRs (30d)
3

Description

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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided YAML load-and-dump example under MRI Ruby and JRuby, then compare the emitted multiline string and empty_key output. The work is done when the relevant output differences are resolved consistently and the same example verifies the result in both runtimes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, ruby
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.