strictyaml icon indicating copy to clipboard operation
strictyaml copied to clipboard

Forbid implicit multiline scalars

Open RazrFalcon opened this issue 4 years ago • 2 comments

list:
  - value1
  - value2

will be parsed as:

{
    "list": [
        "value1",
        "value2"
    ]
}

But this:

list:
  - value1
   - value2

will be parsed as:

{
    "list": [
        "value1 - value2"
    ]
}

This is very confusing and error-prone. Maybe multiline scalars should be available only inside a Block Scalar?

RazrFalcon avatar May 02 '20 06:05 RazrFalcon

Definitely up for this in the hardened spec.

On Sat, 2 May 2020, 07:52 Evgeniy Reizner, [email protected] wrote:

list:

  • value1
  • value2

will be parsed as:

{ "list": [ "value1", "value2" ] }

But this:

list:

  • value1
  • value2

will be parsed as:

{ "list": [ "value1 - value2" ] }

This is very confusing and error-prone. Maybe multiline scalars should be available only inside a Block Scalar https://yaml.org/spec/1.2/spec.html#Block?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/100, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNITAF6UBOB6DKETYVDRPO7K7ANCNFSM4MXR5CBA .

crdoconnor avatar May 02 '20 11:05 crdoconnor

I think that

list:
  - value1
   - value2

should be a parse error. Value1 should be the first element of the list and then fail with an indentation error.

I guess I am saying that restricting multiline scalars to only work in block starting on a new line would be a reasonable restriction. From the zen of Python "There should be one-- and preferably only one --obvious way to do it."

Getting rid of inline formats also agrees with this.

julie777 avatar Mar 05 '22 00:03 julie777