Skip to content

Incorrect dump of block scalar with leading newlines and spaces #403

@trevorr

Description

@trevorr

The following code dumps invalid YAML:

console.log(yaml.safeDump({ str: '\n    a\nb' }))

Invalid output due to indentation:

str: |-

      a
  b

Leading spaces are handled in general by an indentation indicator (below), but leading newlines seem to thwart this (above):

console.log(yaml.safeDump({ str: '    a\nb' }))

Valid output:

str: |2-
      a
  b

The results above are from version 3.11.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions