Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newline prevents double-styled string from being re-styled as literal #2044

Open
chrycheng opened this issue May 17, 2024 · 0 comments
Open
Labels

Comments

@chrycheng
Copy link

chrycheng commented May 17, 2024

Describe the bug

❯ cat good.yaml
test: "{\n  a: () => {\n    a.a(\"a\");\n    a();\n  },\n  a: () => {\n     }\n}"
❯ yq '.test style="literal"' good.yaml
test: |-
  {
    a: () => {
      a.a("a");
      a();
    },
    a: () => {
       }
  }

❯ cat bad.yaml
test: "{\n  a: () => {\n    a.a(\"a\");\n    a();\n  },\n  a: () => {\n    \n  }\n}"
❯ yq '.test style="literal"' bad.yaml
test: "{\n  a: () => {\n    a.a(\"a\");\n    a();\n  },\n  a: () => {\n    \n  }\n}"

bad.yaml differs from good.yaml only in the \n added before the last \n.

Version of yq: 4.43.1
Operating system: Linux
Installed via: Homebrew

Input Yaml
good.yml:

test: "{\n  a: () => {\n    a.a(\"a\");\n    a();\n  },\n  a: () => {\n     }\n}"

bad.yml:

test: "{\n  a: () => {\n    a.a(\"a\");\n    a();\n  },\n  a: () => {\n    \n  }\n}"

Command

yq '.test style="literal"' {good,bad}.yaml

Actual behavior

test: |-
  {
    a: () => {
      a.a("a");
      a();
    },
    a: () => {
       }
  }

---
test: "{\n  a: () => {\n    a.a(\"a\");\n    a();\n  },\n  a: () => {\n    \n  }\n}"

Expected behavior

test: |-
  {
    a: () => {
      a.a("a");
      a();
    },
    a: () => {
       }
  }

---
test: |-
  {
    a: () => {
      a.a("a");
      a();
    },
    a: () => {
      
    }
  }

Additional context
I ran both commands in verbose mode and compared the output. No important difference was found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant