Skip to content

console: add support for %c style formatter in console.log() #29605

@humphd

Description

@humphd

Node's console currently supports a number of formatters, s, j, d, o, O, i, f. However, it doesn't support %c:

> console.log('%cHello World', 'color:green; background:yellow;')
%cHello World color:green; background:yellow;

The same code in Safari, Firefox, and Chrome does this:

Screen Shot 2019-09-18 at 3 55 58 PM

The Console spec doesn't give a ton of help on what %c should do, other than to say that it "Applies provided CSS."

Obviously there are aspects of this that don't make sense in the terminal vs. a browser, but perhaps some of it does? It would be nice if node's console could do more than ignore %c.

Apologies if this has come up in the past and been rejected. I wasn't able to find a previous discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    consoleIssues and PRs related to the console subsystem.feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions