mustangostang / spyc

A simple YAML loader/dumper class for PHP
MIT License
701 stars 207 forks source link

{ } block split over several lines #30

Open interlab opened 10 years ago

interlab commented 10 years ago

sorry my english :ghost:

  1. there shall be an error

example:

text: {
    test1: 123
    test2: 456
    test3: 789
}

out: array ( 'text' => array ( 'test1' => 123, 'test2' => 456, 'test3' => 789, ), 0 => '}', )

it was expected: error


  1. error

example:

text: {
    test1: 123,
    test2: 456,
    test3: 789
}

out: array ( 'text' => array ( 'test1' => '123,', 'test2' => '456,', 'test3' => 789, ), 0 => '}', )

it was expected: array ( 'text' => array ( 'test1' => 123, 'test3' => 789, 'test2' => 456, ), )

ryanuber commented 10 years ago

This is probably because currently Spyc is mostly line-driven. If you load the inline block as a single line, seems to work fine, accounting for the { and } characters as well as the , delimiter between elements. The problem comes in when a block using { and } is split across multiple lines. It seems like Spyc then uses its traditional YAML format parser, hence the mistakes. I started working on a fix but quickly realized that the problem is larger than I initially thought.

The YAML syntax in question has been supported by the spec since YAML 1.0, so we really should fix this. I'll take another stab at it at some point if no one else jumps on it.

interlab commented 10 years ago

in the symphony I noted a similar problem

ossobuffo commented 8 years ago

@ryanuber: Any progress on this? Just got bitten by this today.

ryanuber commented 8 years ago

@ossobuffo I honestly have not done anything related to this project in some years now, sorry! Maybe @mustangostang has some ideas?