Code Monkey home page Code Monkey logo

colorize-template's Introduction

colorize-template's People

Contributors

usmanyunusov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

h2atecnologia

colorize-template's Issues

Theme with color and modifier

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`)

Keep ChangeLog

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.

Improve docs

  • Add short description about what project does
  • Uses this description in package.json and GitHub repo description
  • Add link to Nano Colors
  • Add more syntax description. For instance, how to escape {
  • Add keywords to package.json
  • Use Nano Colors logo in README.md

picocolors version

Since nanocolors was closed in flavor for picocolors, maybe you want to create picocolors-template?

Bug (?): Newlines after template substitution.

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:

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.

Failing Unit Tests

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('\\'))

Send PR to Nano Colors

Add nanocolors-template to Replacing chalk section as 4th step like “If you used template tag …”

Add TS support

We need index.d.ts for TS support since Nano Colors has it

Add simple browser version

There are universal Node.js/browser packages.

It will be good to prove a simplified browser version which will just remove tags.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.