google / yamlfmt

An extensible command line tool or library to format yaml files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

emoji_support contains bad content where there is a literal string

longkai opened this issue Β· comments

So when you set emoji_support to true, adding a test case to the unicode_test.go:

		{
			name: "literal string",
			yamlStr: `a: |
  hello πŸ˜„\n`,
			expectedStr: `a: |
  hello πŸ˜„\n`,
		},

Which results:

parsed string does not match:
        expected: a: |
          hello πŸ˜„\n
        got: a: "hello πŸ˜„n"

I suppose the literal string turns one line due to the go-yaml library. However, the tail n is unacceptable.

Sorry, I should not use \n in literal string qaq

I notice you've closed it now, but here's what I've got about the issues with the output just to keep track.

Of the 3 issues with the output:

  • Double quotes around the result
    • This is from the yaml library. I haven't yet thought of a context free way to get rid of these due to the way they are added into the formatted output, but I'm experimenting with solutions.
  • Outputting to a single line
    • This is also from the library, and this one I'm not sure why it does that. It's possible the yaml.Node serialization doesn't retain the | multiline literal syntax information.
  • The trailing n
    • This was a bug with emoji_support in 0.5.0 that I fixed in #55 and will be in version 0.6.0

Haha I also found the issue and it should advance one byte to check 'U'.

Besides I figure it out why it always formats to a single line since it considers emoji is not printable, so the text contains special characters and always output to escaped one line instead of multi-line literal string or simple string.