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

"%c" for style-outputting suggested #40057

Closed
SEWeiTung opened this issue Sep 10, 2021 · 6 comments
Closed

"%c" for style-outputting suggested #40057

SEWeiTung opened this issue Sep 10, 2021 · 6 comments
Labels
console Issues and PRs related to the console subsystem. feature request Issues that request new features to be added to Node.js.

Comments

@SEWeiTung
Copy link

SEWeiTung commented Sep 10, 2021

Generally speaking, Node.js can now support colorful output through ASCII colors table. However it's not so easy to read and remember. In the Google's chrome, we can use something like "%c" to output styles, Take this as an example:

console.log("%cHello There!","color:pink");

The result is:
image

Now let's see a more complicated example:
image

I know Node.js is for backend programming, however it should be sync with Chrome's functions in style settings, what's more: This function is better than using something like '\x1B[32m' (PS: Do you know what is for "color:pink" without looking for ASCII Color Table?)

Hope "Style-Outputting" will be supported later in Node.js :)

@SEWeiTung SEWeiTung changed the title "%c" for color style suggested "%c" for style-outputting suggested Sep 10, 2021
@Ayase-252 Ayase-252 added console Issues and PRs related to the console subsystem. feature request Issues that request new features to be added to Node.js. labels Sep 10, 2021
@VoltrexKeyva
Copy link
Member

Not a bad idea but not sure if we should implement this on a different method in the console object or just on the console.log() and override it's functionality to be consistent with the Google Chrome's behavior, as there might be users out there unaware of this styling behavior that might be using the %c format flag/specifier intentionally for different purposes than color-styled outputs.

We should document this behavior change somewhere if we ever decide to implement this.

@devsnek
Copy link
Member

devsnek commented Sep 10, 2021

Duplicate of #40057

@devsnek devsnek marked this as a duplicate of #40057 Sep 10, 2021
@devsnek devsnek closed this as completed Sep 10, 2021
@VoltrexKeyva
Copy link
Member

@devsnek I think you marked it as a duplicate of the wrong issue 👀

@devsnek
Copy link
Member

devsnek commented Sep 10, 2021

oops

@devsnek devsnek reopened this Sep 10, 2021
@devsnek
Copy link
Member

devsnek commented Sep 10, 2021

Duplicate of #29605

@devsnek devsnek marked this as a duplicate of #29605 Sep 10, 2021
@devsnek devsnek closed this as completed Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
console Issues and PRs related to the console subsystem. feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

No branches or pull requests

5 participants
@devsnek @Ayase-252 @SEWeiTung @VoltrexKeyva and others