Skip to content

Empty Multiline Array Is Having an Empty Line and Whitespace Added Before It #590

Closed
@pjkaufman

Description

@pjkaufman

Describe the bug
Thanks for creating this YAML parser. I have been working on using it in one of my projects and I have hit a weird scenario. It seems that in some cases, empty multi-line arrays are having their empty entry moved down a line and having its indentation space added on the line it was on. I am not sure if this YAML is considered correct under the YAML spec in use, so please let me know if the YAML is incorrect/out of spec.

To Reproduce

parseDocument then toString the following YAML:

FFF:
  - 

It seems to result in:

---
FFF:
  
  - 
---

This seems wrong to me, but maybe that is what the spec dictates should happen.

Expected behaviour

I expect the output to be as close to, if not the same as, the input as is possible:

FFF:
  - 

Versions (please complete the following information):

  • Environment: Node v18.0.0
  • yaml: 2.6.0

Additional context
I am not 100% sure on how nesting levels would affect this or if it would be fine to try to investigate the root cause of the issue. But I would be happy to take a stab at it if you are fine with that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions