Repository navigation
SVG: read a light-dark() color as its light color - #2156
Open
RavSinghChandan wants to merge 2 commits into
Open
RavSinghChandan wants to merge 2 commits into
RavSinghChandan wants to merge 2 commits into
Conversation
andersonhc
reviewed
Nov 10, 2026
| # CSS Color 5: without a color-scheme, which SVG documents rarely set, | ||
| # light-dark() is its first, light color. | ||
| light_color = _split_top_level_commas(colorstr[len("light-dark(") : -1])[0] | ||
| return svgcolor(light_color) |
Collaborator
There was a problem hiding this comment.
Calling svgcolor() directly bypasses the handling of transparent in svg_paint() and currentColor in inheritable(). Could the selected light color go through the appropriate paint/inheritance handling?
RavSinghChandan
force-pushed
the
svg-light-dark-color
branch
from
November 10, 2026 13:01
19ffd2d to
7d74721
Compare
…t color can be transparent or currentColor
RavSinghChandan
force-pushed
the
svg-light-dark-color
branch
from
November 10, 2026 14:10
7d74721 to
6463a36
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fill="light-dark(rgb(99, 222, 23), rgb(237, 237, 237))"fails withValueError: unsupported color specification. draw.io writeslight-dark()colors in its SVG exports, for example the icons of the Zensical theme used by Python-Markdown's documentation (.zensical/theme/assets/images/pyMd_icon.svg).In CSS Color 5,
light-dark()uses its first color unless acolor-schemeasks for dark, and SVG documents rarely set one, sosvgcolor()now reads the first argument, which can itself contain commas (rgb(...)).Added three cases to
test_svg_attribute_conversion(fill, stroke writtenLight-Dark, and an invalid first color, which still raises); the first two fail on master.pytest test/svg test/drawing test/image, black, pylint, mypy and pyright pass