Skip to content

String "\n" shouldn't be serialized as a block scalar #534

Description

@Thom1729

The string "\n" (containing one character, a newline) is serialized as a block scalar:

|+

This is very awkward to read; it would be much clearer as a double-quoted string.

Also, it breaks my syntax highlighter. While this is undoubtedly a bug with the syntax highlighter, it must be admitted that YAML is very hard to highlight correctly and that js-yaml is not making it any easier in this case. It's also worth noting that the above Markdown code block was wrong the first time I typed it because Markdown ate the significant trailing newline.

This could be fixed in the chooseScalarStyle function. I'm not sure what would be a good general rule to avoid this; I'm open to suggestions.

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