👨💻 Последние статьи из моего блога:
Обновлено 2024-05-18 09:01
🍭 Tagged template literal for ANSI colors.
Home Page: https://npm.im/colorize-template
License: MIT License
👨💻 Последние статьи из моего блога:
Обновлено 2024-05-18 09:01
Hello. How can i declare color & modifier (eg Bold) together for theme?
Something like this:
let colorize = createColorize({
error: picocolors.red.bold
})
console.log(colorize`Error {error color} text`)
I can do only this:
let colorize = createColorize({
error: picocolors.red
})
console.log(colorize`Error {error.bold color} text`)
ChangeLog has only version 0.0.1, but you already released 0.0.2 and 0.0.3 without notes in ChangeLog. It is bad.
Also, according to SemVer you should start from 0.1.0, not 0.0.1.
package.json
and GitHub repo description{
package.json
README.md
Since nanocolors
was closed in flavor for picocolors
, maybe you want to create picocolors-template
?
Nano Colors uses clean-publish
to clean package.json
from development configs
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.
Actual behavior: Output strips newlines and whitespace after template replacement, so OneTwo
with color chars.
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('\\'))
Add nanocolors-template
to Replacing chalk
section as 4th step like “If you used template tag …”
We need index.d.ts
for TS support since Nano Colors has it
There are universal Node.js/browser packages.
It will be good to prove a simplified browser version which will just remove tags.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.