yaml-rust icon indicating copy to clipboard operation
yaml-rust copied to clipboard

Support indentation w/ 2 spaces

Open rofinn opened this issue 7 years ago • 6 comments
trafficstars

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

rofinn avatar Jun 04 '18 02:06 rofinn

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.

iamed2 avatar Jun 15 '18 19:06 iamed2

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

kbknapp avatar Jun 22 '18 11:06 kbknapp

clap was indeed how Rory discovered this

iamed2 avatar Jun 22 '18 12:06 iamed2

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?

hoodie avatar Jun 22 '18 19:06 hoodie

@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.

kbknapp avatar Jun 22 '18 22:06 kbknapp

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.

berwyn avatar Nov 12 '18 16:11 berwyn