diff --git a/ansimarkup/markup.py b/ansimarkup/markup.py index d30b391..6ecf516 100644 --- a/ansimarkup/markup.py +++ b/ansimarkup/markup.py @@ -143,7 +143,8 @@ def sub_tag(self, match: Match, tag_list: List[str], res_list: List[str]) -> str elif re.match(r"#(?:[a-fA-F0-9]{3}){1,2}$", color): hex_color = color[1:] if len(hex_color) == 3: - hex_color *= 2 + r, g, b = hex_color + hex_color = r * 2 + g * 2 + b * 2 res = "\033[%s;2;%s;%s;%sm" % ((code,) + hex_to_rgb(hex_color)) elif color.count(",") == 2: colors = tuple(color.split(",")) diff --git a/tests/test_markup.py b/tests/test_markup.py index ac1caed..11fe90e 100644 --- a/tests/test_markup.py +++ b/tests/test_markup.py @@ -67,7 +67,7 @@ def test_xterm_color(): def test_xterm_hex(): assert p("1") == p("1") == "\x1b[38;2;255;0;0m" "1" assert p("1") == "\x1b[48;2;0;160;0m" "\x1b[38;2;255;0;0m" "1" - assert p("1") == p("1") == "\x1b[38;2;241;47;18m" + "1" + S.RESET_ALL + assert p("1") == p("1") == "\x1b[38;2;255;17;34m" + "1" + S.RESET_ALL assert p("1") == "1" assert p("1") == "1"