SharpYaml icon indicating copy to clipboard operation
SharpYaml copied to clipboard

[Question] Is there a way to output a string property using the multi-line block scalar styles (>, |)

Open dfkeenan opened this issue 9 years ago • 2 comments
trafficstars

Hi,

Subject pretty much covers it. I am trying to serialize a class with string properties and want to out put them in the block style without quotes and "\r" or "\n".

I have been trying to do it with the SerializerSettings like:

            var ocrTemplateType = typeof(OcrTemplate);
            settings.RegisterTagMapping("!OcrTemplate", ocrTemplateType);
            settings.Attributes.Register(ocrTemplateType.GetProperty(nameof(OcrTemplate.Text)), new YamlMemberAttribute(0));
            settings.Attributes.Register(ocrTemplateType.GetProperty(nameof(OcrTemplate.Text)), new YamlStyleAttribute(SharpYaml.YamlStyle.Block));

Cheers, dfkeenan

dfkeenan avatar May 09 '16 01:05 dfkeenan

Any news on this?

I experience the same when trying to save a stream to a file. I have a multi-line block scalar in my input file, and would like to keep the formatting on the output file.

jakob-nielsen-dfds avatar Dec 13 '18 14:12 jakob-nielsen-dfds

I don't have any spare time dedicated to this project, so digging into the problem and PR are welcome

xoofx avatar Dec 13 '18 16:12 xoofx