Skip to content

Read color keywords and function names regardless of case - #541

Merged
deeplook merged 1 commit into
deeplook:mainfrom
RavSinghChandan:color-keywords-ignore-case
Nov 9, 2026
Merged

deeplook merged 1 commit into
deeplook:mainfrom
RavSinghChandan:color-keywords-ignore-case

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

fill="White" or stroke="RED" leaves the shape with no fill or stroke, with a Can't handle color warning:

<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10">
  <rect width="10" height="10" fill="White"/>
</svg>

CSS keywords and function names are ASCII case-insensitive, and browsers draw this rect white. convertColor() looked the name up with getattr(colors, text), and ReportLab's cssParse() only accepts lowercase function names, so RGB(255, 0, 0) failed the same way. The same goes for currentcolor and None.

The keyword and function lookups now use the lowercased value. Hex colors were already case-insensitive, and url(...) references are handled before this, so ids keep their case.

Added test_color_keywords_ignore_case next to the other color tests; it fails on main. Added a ### Fixed entry in CHANGELOG.md (I used #541 for the number, I'll fix it if the PR gets another one). pytest, ruff format --check, ruff check and mypy src tests pass.

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

@deeplook
deeplook merged commit 1b4ec39 into deeplook:main Nov 9, 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