5

Is there a way for me to include empty lines into the parsed YAML file using YamlDotNet? What I have currently when I parse a file like this:

node1: "1.0"

node2: "some text"

node3: "string"

I end up with this as the result:

node1: "1.0"
node2: "some text"
node3: "string"

Is there a way for me to configure the parser to not ignore blank lines?

Briefly, I'm using the YamlDotNet Parser class like so:

var input = File.OpenText(file);
var parser = new Parser(_input);

public bool Read()
{
    Value = null;
    Path = null;

    var hasMore = _parser.MoveNext();

    if (!hasMore)
    {
        return false;
    }

    parser.Current.Accept(this);

    LineNumber = _parser.Current.Start.Line;

    return true;
}

And in a separate class:

while (reader.Read())
{

}

EDIT:

This doesn't only happen with blank lines, it also happens when I have a line break after a dash:

Before:

-
  name: Mark McGwire
  hr:   65
  avg:  0.278

After:

- name: Mark McGwire
  hr:   65
  avg:  0.278

0 Answers0