ansi2html icon indicating copy to clipboard operation
ansi2html copied to clipboard

Custom bg fg colors and css

Open CommanderPho opened this issue 2 years ago • 1 comments

I added custom_bg, custom_fg, and custom_content_css_dict parameters to Ansi2HTMLConverter to enable specifying custom background/foreground colors and css properties because I needed this functionality in my own project.

I believe this also satisfies the feature request mentioned here: #153

I've never used the CLI interface, so hopefully these properties don't interfere with that functionality (which I haven't tested or looked in to).

# Example with Custom CSS Overrides:
custom_css_content_dict = {'font-family':'"Lucida Console", "Courier New", monospace', 'font-size':'8px'} # produces css like: 'font-family: "Lucida Console", "Courier New", monospace; font-size: 8px;'
conv = Ansi2HTMLConverter(custom_bg='#FFFFFF', custom_fg='#220000', custom_content_css_dict=custom_css_content_dict)
ansi = " ".join(sys.stdin.readlines())
html = conv.convert(ansi)

Hope it's helpful to someone.

CommanderPho avatar Jan 14 '23 22:01 CommanderPho

@CommanderPho Can you please rebase?

ssbarnea avatar Dec 11 '23 14:12 ssbarnea