From 95ba69fd5ae696450e766633e73b7afd7f1c4754 Mon Sep 17 00:00:00 2001 From: wangzhuc Date: Wed, 1 Apr 2026 01:56:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20learn=5Ftheme=20=E2=80=94=20add=20analy?= =?UTF-8?q?ze=5Fstyles,=20DEFAULTS,=20most=5Fcommon=5Fvalue,=20derive=5Fda?= =?UTF-8?q?rkmode=20integration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Excludes dominant text color from accent candidates; blockquote-first quote_bg heuristic avoids picking up decorative divider colors. Co-Authored-By: Claude Sonnet 4.6 --- scripts/learn_theme.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/learn_theme.py b/scripts/learn_theme.py index 93bc77a..40df14a 100644 --- a/scripts/learn_theme.py +++ b/scripts/learn_theme.py @@ -290,6 +290,7 @@ def analyze_styles(grouped: dict) -> dict: # --- primary (accent color) ------------------------------------------------ # Collect non-gray colors from strong/section/h1-h3/span; boost colors from # elements whose font-size is ≥ 20 px (weight × 5). + # Exclude the dominant text color so near-black body text never wins. accent_tags = {"strong", "section", "h1", "h2", "h3", "span"} accent_counter: Counter = Counter() for tag in accent_tags: @@ -300,6 +301,8 @@ def analyze_styles(grouped: dict) -> dict: hex_c = rgb_to_hex(color_val) if is_gray(hex_c): continue + if hex_c == result["text"]: + continue # Check font-size for boost fs = d.get("font-size") fs_px = _parse_px(fs) if fs else None