Skip to content

Color sequences incorrectly terminate in Chrome #53

@mindplay-dk

Description

@mindplay-dk

After some initial testing, I picked ansi-colors from the wealth of color-packages, as it appeared to be the only package that would load and work in the browser.

But it looks like I've run into a problem - take this simple example:

import colors from "ansi-colors";

console.log(`this is ${colors.bgRed.white("white")}\nthis is ${colors.bgGreen.white("green")}\nall good?`);

When run in a terminal, as expected:

image

However, when run in the Chrome or Edge DevTools console:

image

Also, when running in Firefox, it doesn't correctly detect color support:

image

It happens with just background and no text color too:

console.log(`this is ${colors.bgRed("white")}\nthis is ${colors.bgGreen("green")}\nall good?`);

However, it only happens with background colors and not with text colors - so this:

console.log(`this is ${colors.red("red")}\nthis is ${colors.green("green")}\nall good?`);

Looks fine in Chrome:

image

Here's a running example.

It could be a bug in Chrome and Edge, I suppose?

Is browser support officially supported by the library?

I mean, the README doesn't say it is, and the only reason I assumed it did, was because I noticed there's a ansi-colors-es6 fork with the description "Easily add ANSI colors to your node terminal or browser console". (and yes, this fork has the same problem.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions