Closed minikomi closed 9 years ago
Another strange edge case:
key:value
multi-line-value
[singleword]
newkey:yeah
[]
another multi line value
:end
Result:
{
"key": "value",
"singleword": [
{
"newkey": "yeah"
}
],
"newkey": "undefinedanother multi line value"
}
Also seems to be related:
{scope}
key:value
{}
value2
:end
result:
{
"scope": {
"key": "value"
},
"key": "undefinedvalue2"
}
Hey @minikomi - thanks for all of the examples, these were all bugs in the way archieml-js was handling multi-line values. We can continue the discussion here if there are any questions / concerns about the behavior in any specific circumstances, but the way we intended it to work was:
Start any value with either a key: value
, or with an asterisk in the case of a simple array * value
). The value as defined on that line is always included as the value. Sequential lines are added to the value only if those lines 1) do not contain any lines that would be interpreted as commands (i.e., {}
), and are followed with an :end
line.
All of the examples above broke because the javascript parser was trying to add the lines immediately preceding :end
to the last key that was defined, even though there was a command line in the middle of the value that should have prevented it from being interpreted as a multi-line value.
I'm uploading a patch now that will cause key
in most of your examples to wind up as a single-line value, value
.
I'm not sure what the expected result is but this seems a little odd:
Output:
multi-line-value
has disappeared, and there's also no newlines in the output.When there is a multi-word value within the square brackets, it is treated as a comment and we get:
Which seems more consistent with the other rules.