r-yaml icon indicating copy to clipboard operation
r-yaml copied to clipboard

Support for document boundary markers

Open nuest opened this issue 4 years ago • 3 comments

YAML supports "multiple documents in one file" with boundary markers (---), see https://yaml.org/spec/1.1/#id897596

From searching the source code, it seems like the underlying library does communicate document beginnings and ends from within the same stream: https://github.com/viking/r-yaml/search?q=document+stream&unscoped_q=document+stream

Probably related to your thoughts about switching the underlying library for #76 and might also require considerable changes in the API.

Looking forward to hear your thoughts on that!

nuest avatar Apr 06 '20 15:04 nuest

I'm not sure how to best go about supporting that. I'd probably need to add a parameter to yaml.load that turns on the functionality in order to keep backward compatibility. If a hypothetical multiple parameter was set to true, for example, yaml.load could return a list of documents.

viking avatar May 14 '20 15:05 viking

I agree backwards compatibility is first goal.

If the user has to decide if to use the parameter, maybe a different function yaml.load.multiple is an option?

nuest avatar May 14 '20 17:05 nuest

I think output should also be supported by a similar parameter. I.e., the provided object must be a list that will become documents. I think I can do this first and learn the document interface in libyaml.

spgarbet avatar Feb 22 '22 19:02 spgarbet