Skip to content

Newline are not preserved when using > for strings (for both read and write operations) #563

Open
@AntoineGagne

Description

@AntoineGagne

Describe the bug

When a string using > is present in the YAML, the string will be inlined following a read or write.

version of yq: 3.4.0
operating system: Ubuntu 18.04.4 LTS

Input YAML:

test.yml:

---
test: >
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
    veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
    commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
    velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
    cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
    est laborum.

Output YAML:

test: >
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Command
The command you ran:

yq read test.yml

Actual behavior

As seen in the previous snippet, it seems as though the strings are joined on newlines.

Expected behavior

The string should be kept as is. The current output does not seem to be equivalent with the input one.

Additional context

The same behaviour is also true with the write command. If there is a string using > inside the YAML document and the write command is used, it will inlined as in the read command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions