Skip to content

Unreadable colors with light backgrounds #254

@rayosborn

Description

@rayosborn

This has been a valuable and widely used package for many years, although I gather that it is minimally maintained even after requests for additional support. My issue is related to #225, but I am not requesting changes to the package itself, but tips from the user community about how to make it usable, in particular with a light background.

I am using ansi2html in a Python package that outputs the colored text to a PyQt QTextEdit widget, or in the examples I provide here, a QMessageBox. I use the following code:

def convertHTML(text, dark_bg=None):
    """Replace ANSI color codes with HTML"""
    if dark_bg is None:
        dark_bg = in_dark_mode()
    conv = Ansi2HTMLConverter(dark_bg=dark_bg, inline=True)
    return conv.convert(text)

In dark mode, this works fine:
Image
However, in light mode, the text is nearly unreadable.
Image
Although there is evidence of ansi2html switching some white text to black, other off-white text used for much of the code is unreadable and the whole color palette is washed out. As far as I can tell, none of the supported color schemes improve the situation.

So my question is how people get around this. Surely I am not the only one who has confronted this issue. I have seen comments about changing a gray background to white, using text.replace(), but that makes things worse. What is needed is a revised default color palette that works for light backgrounds. Do they exist?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions