We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Really neat to see this slim library! I think I've encountered a bug in the handling of whitespace/newlines after template replacements...
I have multiline template strings that I'm switching away from chalk to this library of the form:
colorize` {gray One} {cyan Two}
Expected behavior: Output preserves newlines, so One\n\nTwo with color chars.
One\n\nTwo
Actual behavior: Output strips newlines and whitespace after template replacement, so OneTwo with color chars.
OneTwo
I think these unit tests demonstrate the issue:
diff --git a/tests/index.js b/tests/index.js index 8c731ec..5f40410 100644 --- a/tests/index.js +++ b/tests/index.js @@ -80,6 +80,15 @@ test('correctly parse newline escapes', () => { assert.equal(colorize`Hello\nthere!`, 'Hello\nthere!') }) +test('correctly parse newline literals after template', () => { + assert.equal(colorize`Hello {red there} +after`, 'Hello ' + pc.red('there') + '\nafter') +}) + +test('correctly parse newline escapes after template', () => { + assert.equal(colorize`Hello {red there}\nafter`, 'Hello ' + pc.red('there') + '\nafter') +}) + test('correctly parse escape in parameters', () => { const string = '\\' assert.equal(colorize`{red ${string}}`, pc.red('\\'))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Really neat to see this slim library! I think I've encountered a bug in the handling of whitespace/newlines after template replacements...
Situation
I have multiline template strings that I'm switching away from chalk to this library of the form:
Expected behavior: Output preserves newlines, so
One\n\nTwo
with color chars.Actual behavior: Output strips newlines and whitespace after template replacement, so
OneTwo
with color chars.Failing Unit Tests
I think these unit tests demonstrate the issue:
The text was updated successfully, but these errors were encountered: