Open ramiromagno opened 2 years ago
Okay, I just realised there are some special values in YAML. n
stands for "not", is it? It seems that quoting it works as I expected. Is that the way to escape its special meaning?
I'd prefer to not force the user to quote the data in the YAML file. I can I somehow tell yaml.load_file()
to treat n
literally?
This is a quirk of yaml 1.1. It's removed for yaml 1.2, but efforts to get that up and going aren't going so fast.
It might be possible to write a custom boolean handler. I've not tried that.
The parser returns a "bool#yes" and "bool#no" for these tag types. It might be possible to modify this behavior.
Try writing a custom handler and post your code here. If that works, I'll see if it can become an option to ignore in the parser output.
This seems to work:
yaml.load("'n': false\ntrue: 200",
handlers=list(boolean=
function(x) if(x %in% c('n','y')) x else tolower(x)=='true'))
Thanks for your answers. But it seems that only works because the input has n
quoted, i.e. 'n'
.
That slipped through in my example. I just tried it and upstream it's emitted a T/F for this, so I don't see an easy way. It'll require compiler modification.
Okay, thanks for trying. I'll leave this issue open, but feel free to close it if you think this functionality is unlikely to be supported.
It is the plurality of issues opened. The other being requests for yaml 1.2 (which doesn't have the n/y issue). I've started an experiment to use the libfyaml library and see if it solves both problems.
Related on SO, for the record (if it helps): https://stackoverflow.com/questions/75595253/rmarkdownyaml-front-matter-converts-some-parameter-names-to-true
{yaml}
package version is 2.3.6.