Generate correct html from xterm colors.

This commit is contained in:
Andrew Hamilton 2021-11-15 22:18:07 +10:00
parent 28b2c9bae9
commit 9ecc65bd12
2 changed files with 3 additions and 4 deletions

View file

@ -147,9 +147,9 @@ class CharStyle:
underline_code = ("text-decoration:underline; "
if self.is_underlined else "")
fg_color = (self.fg_color if type(self.fg_color) == tuple
else xterm_colors[self.fg_color])
else XTERM_COLORS[self.fg_color])
bg_color = (self.bg_color if type(self.bg_color) == tuple
else xterm_colors[self.bg_color])
else XTERM_COLORS[self.bg_color])
return (f"<style>.S{id(self)} {{font-size:80%%; color:rgb{fg_color!r};"
f" background-color:rgb{bg_color!r}; "
f"{bold_code}{italic_code}{underline_code}}}</style>")
@ -212,7 +212,7 @@ class TermStr(collections.UserString):
is_italic = True
elif code in ["04", "4"]: # underline
is_underlined = True
elif code_int and 30 <= code_int <= 37 : # dim fg color
elif code_int and 30 <= code_int <= 37: # dim fg color
fg_color = int(code[1])
elif code_int and 40 <= code_int <= 47: # dim bg color
bg_color = int(code[1])

View file

@ -1,7 +1,6 @@
#!/usr/bin/env python3.9
import os
import pickle
import unittest