chyh1990 / yaml-rust

A pure rust YAML implementation.
Apache License 2.0
600 stars 139 forks source link

Support indentation w/ 2 spaces #101

Open rofinn opened 6 years ago

rofinn commented 6 years ago

It appears that yaml-rust only supports 4 spaces for indentation.

iamed2 commented 6 years ago

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

The YAML 1.2 spec says that any number of spaces can be used to represent an indentation level.

kbknapp commented 6 years ago

This has come up a few times in clap with an open issue being kbknapp/clap-rs#965

iamed2 commented 6 years ago

clap was indeed how Rory discovered this

hoodie commented 6 years ago

I don't think this is true, as I commented on kbknapp/clap-rs#965 already. I also have some tests that should demonstrate this. Or do I not understand correctly?

kbknapp commented 6 years ago

@hoodie I agree the specific test referenced in clap#965 doesn't quite line up with this issue, however just today I ran into an issue where the only change made was indents from 4 to 2 and it works with 4 but fails with 2.

Once I get to a computer I can post the actual test for reference.

berwyn commented 5 years ago

Just ran into this today via Clap. Having a background with Rails and Jekyll, I wrote my Clap yaml with two spaces for indentation and then was beat over the head with weird issues where the yaml would fail to parse. Took some digging and found out that indentation by two spaces is what killed me. Given that every other yaml parser I've used hasn't cared about the number of spaces present, but rather the number of spaces relative to the parent, I'd love to see this functionality added!

Especially of note here, most editors default to two spaces for indentation in yaml, since that's become the de-facto standard for yaml writers/consumers, which could really exacerbate the issue in Rust projects.