As you can see, the line break gets stripped. This is because by default, line breaks are stripped from quoted strings in yaml. Using a multi-line block with > or | doesn't work because we break indentation.
One way that works is to force replace all line breaks in the value with \n (or two line breaks).
This way, my yaml ends up looking like this, and parsing works:
foo: "a\nb"
I guess an even cleaner way would be to completely escape strings before doing the substitution ?
Hi. I'm trying to find a way to handle multi-line env variables. Basically, I have a pkcs certificate that I need to get from env through EnvYaml.
Simple test case:
Then in python:
As you can see, the line break gets stripped. This is because by default, line breaks are stripped from quoted strings in yaml. Using a multi-line block with
>
or|
doesn't work because we break indentation.One way that works is to force replace all line breaks in the value with
\n
(or two line breaks).This way, my yaml ends up looking like this, and parsing works:
I guess an even cleaner way would be to completely escape strings before doing the substitution ?