Skip to content

SVG: read rgb() with channels that are not integers - #2207

Open
RavSinghChandan wants to merge 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-rgb-float-channels
Open

RavSinghChandan wants to merge 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-rgb-float-channels

Conversation

@RavSinghChandan

Copy link
Copy Markdown

Mermaid computes its theme colors and writes them as fill:rgb(45,179.9999999999,184.5) in its stylesheets, as in the LegalQA diagrams. An rgb() with commas and a channel that isn't an integer fails with ValueError: invalid literal for int() with base 10. These rules aren't applied today, but they would be once descendant selectors are (#2201).

Such a color is now read as in CSS Color 4, like the space-separated syntax already is. Integers and percentages still go through fpdf2's own parser, and an integer 4th value still sets an alpha from 0 to 255. The comma handling moved into _comma_rgb_color() to keep svgcolor() readable.

Two new cases in parameters.py cover rgb(0, 127.5, 1e2) and rgb(255, 127.5, 0, 51); both fail without the change.

This branch has not been deployed

No deployments
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.

1 participant