wrong indentation in arrays with unquoted values containing a colon
Closed this issue · 1 comments
Which version(s) is affected: definitely v4.2.4
, maybe older ones as well
Description
There is an issue with array item indentation. When an item is not quoted and contains a colon (:
), it will have 3 spaces after a dash, even though it is not a nested array (might be caused by #27).
See Travis build of shopsys/demoshop
for a real life example: https://travis-ci.org/shopsys/demoshop/builds/569339341#L4564-L4575
How to reproduce
Usual arrays (1 space after dash) ✔️
array_name:
- value
- other value
Nested arrays (3 spaces after a dash) ✔️
array name:
- key: value
other key: value
Arrays with unquoted colons (3 spaces after a dash only when colon is present) ❌
array_name:
- value
- http://google.com
- 'http://google.com'
Possible Solution
- fix the edge case to only force 3 spaces when the line is a proper key-value pair
- force 3 spaces (or more correctly n-1 where n is the indent count) on every array item line
Additional information
YAML apparently doesn't considers the line a key-value pair only if it is not in quoted string (eg. "key: value"
will not be considered a key-value pair) and there is a space after the colon (eg. key: value
or key : value
but not key:value
or key :value
).
Hello @PetrHeinz,
thanks for the reported issue. I hope I will have time this weekend to fix this issue, if not then I will fix it in next week.