Skip to content

[Yaml] YAMLDumper does not support writing using folded/literal style #16236

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

Closed
deanc opened this issue Oct 14, 2015 · 2 comments
Closed

[Yaml] YAMLDumper does not support writing using folded/literal style #16236

deanc opened this issue Oct 14, 2015 · 2 comments

Comments

@deanc
Copy link

deanc commented Oct 14, 2015

http://yaml.org/spec/1.2/spec.html#id2760844

Specifically, there is no way to output this:

>
 Sammy Sosa completed another
 fine season with great stats.

   63 Home Runs
   0.288 Batting Average

 What a year!

The main reason I find that this is odd, is if you use the YamlLoader and do zero processing on the data, and then immediately dump it back out again - it changes the file. I would expect the API's to be compatible (even if it requires configuration).

@stof
Copy link
Member

stof commented Oct 14, 2015

indeed it does not. this is because there is several Yaml representations of the same datastructure in Yaml, and the dumper chooses one of them (the easiest one to implement btw).

How would you imagine an API allowing to choose the representation used for each value when dumping ? I don't see any easy to use interface for that.

@deanc
Copy link
Author

deanc commented Oct 14, 2015

What it outputs is perfectly valid but it would be nice to have a choice on that output. The API right now for dump is:

public string dump(mixed $input, int $inline, int $indent, bool $exceptionOnInvalidType = false, bool $objectSupport = false)

An extra option could be added preserveLiterals which would expand strings with new lines using the literal style.

http://yaml.org/ states:

What It Is: YAML is a human friendly data serialization
standard for all programming languages.

The output right now, without somehow supporting literal style and folder style, is not human-readable when dealing with long strings.

@xabbuh xabbuh added the Yaml label Oct 18, 2015
@xabbuh xabbuh added this to the 3.1 milestone Feb 8, 2016
fabpot added a commit that referenced this issue Mar 1, 2016
…cks (xabbuh)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[Yaml] option to dump multi line strings as scalar blocks

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16236, #16604, #17912, #17391
| License       | MIT
| Doc PR        | TODO

Commits
-------

eff6902 option to dump multi line strings as scalar blocks
@fabpot fabpot closed this as completed Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants