-
-
Notifications
You must be signed in to change notification settings - Fork 197
Description
According to the YAML spec, an indentation indicator can be used when there are leading spaces in a multiline string.
These don't work correctly in this YAML implementation.
For example, the value of s
in the following YAML:
s: >1
1s
unmarshals to "1s"
not the expected " 1s\n"
(markdown limitation: there should be 7 leading spaces in that string; note also the newline at the end, which should be present).
This code demonstrates the issue: https://go.dev/play/p/qQio_0imVkY
There are some other issues with multiline strings too. This code demonstrates some of them (AIUI gopkg.in/yaml.v3
is generally getting the correct answers here): https://go.dev/play/p/xaIS1P5WenY
One other upshot of this, is that you'll need to be careful to provide the correct data to custom unmarshalers. Currently the actual raw string is passed to the UnmarshalYAML
method, but the interpretation of that depends on the surrounding indentation context.
Here's an example: https://go.dev/play/p/oN6fV4v75SR. Observe that exactly the same content is passed in both cases, but that the decoded strings should be different in each case, as demonstrated here: https://go.dev/play/p/IC8i9j1qsyM. This could have performance implications due to the need to strip indentation before passing the content to UnmarshalYAML
.