Nice cards templates
This commit is contained in:
+18
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from genshin_tcg.markup import clean_markup, inline_symbols, sanitize, strip_markup
|
||||
from genshin_tcg.markup import clean_markup, inline_symbols, panel_ink, sanitize, strip_markup
|
||||
|
||||
|
||||
def test_clean_markup_converts_color_tags() -> None:
|
||||
@@ -19,6 +19,23 @@ def test_clean_markup_keeps_colour_and_underline_spans() -> None:
|
||||
assert clean_markup(raw) == expected
|
||||
|
||||
|
||||
def test_clean_markup_applies_colour_map() -> None:
|
||||
raw = '<span style="color: #FFFFFFFF">DGT</span>'
|
||||
assert clean_markup(raw, color_map=panel_ink) == '<span style="color: #3a332a">DGT</span>'
|
||||
|
||||
|
||||
def test_panel_ink_neutralises_achromatic_and_darkens_hues() -> None:
|
||||
# White would be invisible on the frosted panel, so it collapses to ink.
|
||||
# The dataset writes colours as #RRGGBBAA, so the trailing byte is alpha.
|
||||
assert panel_ink("#FFFFFFFF") == "#3a332a"
|
||||
assert panel_ink("#FFFFFF") == "#3a332a"
|
||||
# Chromatic keyword colours keep their hue but gain contrast.
|
||||
assert panel_ink("#FFD780FF") == "#986F16" # gold
|
||||
assert panel_ink("#7EC236FF") == "#588826" # Dendro green
|
||||
# Anything that is not a hex colour is passed through untouched.
|
||||
assert panel_ink("red") == "red"
|
||||
|
||||
|
||||
def test_sanitize_removes_script_and_event_handlers() -> None:
|
||||
dirty = '<script>alert(1)</script><span onclick="x()" style="color: red;">ok</span>'
|
||||
cleaned = sanitize(dirty)
|
||||
|
||||
Reference in New Issue
Block a user