Skip to content

Block scalar texts are parsed incorrectly: The final line break should be part of the scalar. #4

@mmueller2012

Description

@mmueller2012

The YAML spec states that the final line break is part of a block scalar unless strip - is used as a chomping mode. The parser however treats the final line break as whitespace and assigns it to a different node.

Here is an example to reproduce the issue:

a: |
  hello
  world
b: |
  hello
  world

The parser generates the following output:

The incorrectly parsed line breaks are marked with <-----. They should be part of the BLOCK_SCALAR_TEXT instead.

I tried to fix it myself, but it turned out to be quite challenging. Parsing the line break as part of BLOCK_SCALAR_TEXT breaks the parent rules which expect the line break as a separator, e.g. the block_map parsing function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions