Skip to content

Read a light-dark() color as its light color - #546

Merged
deeplook merged 3 commits into
deeplook:mainfrom
RavSinghChandan:light-dark-color
Nov 12, 2026
Merged

deeplook merged 3 commits into
deeplook:mainfrom
RavSinghChandan:light-dark-color

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

A light-dark() color is not read, so the shape loses its fill or stroke and svglib logs "Can't handle color". draw.io writes light-dark() in its SVG exports, usually in a style that overrides a plain color attribute, for example stroke="#63de17" style="stroke: light-dark(rgb(99, 222, 23), rgb(237, 237, 237))" in the icons of the Zensical theme used by Python-Markdown's documentation (.zensical/theme/assets/images/pyMd_icon.svg): the icon's outline disappears.

In CSS Color 5, light-dark() uses its first color unless a color-scheme asks for dark, and SVG documents rarely set one, so convertColor() now converts the first argument. A new _first_css_argument() finds it, skipping the commas inside rgb(...) or hsl(...). With this change the outline of that icon is green, as in a browser.

Added test_light_dark_color (rgb, a different case, hsl, a single argument, and currentColor); it fails on main. Updated tests/public_api.json with --update for the new private name, and added a ### Fixed entry in CHANGELOG.md (I used #547, I'll fix it if the PR gets another number). pytest (without the network-dependent sample downloads), ruff format --check, ruff check and mypy src tests pass.

AI-assisted (Claude Code); I reviewed and tested the change

@deeplook
deeplook merged commit a4d5788 into deeplook:main Nov 12, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants