Skip to content

write_html: accept six hex digits without # as a color, like browsers - #2003

Merged
andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:html-color-without-hash
Oct 11, 2026
Merged

andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:html-color-without-hash

Conversation

@RavSinghChandan

Copy link
Copy Markdown

e.g. Fixes #0

Checklist:

  • A unit test is covering the code added / modified by this PR

  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder

  • A mention of the change is present in CHANGELOG.md

  • This PR is ready to be merged

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

@RavSinghChandan

Copy link
Copy Markdown
Author

bgcolor="eeeeee" or <font color="ff0000"> raised ValueError: ff0000 does not start with #. Browsers read six hex digits without the leading # as that hex color (HTML's legacy color parsing), and older HTML, such as many email templates, writes colors this way. color_as_decimal() now adds the # for exactly six hex digits. Shorter forms like f00 are not, since browsers read those differently, and still raise as before. Added tests.

@andersonhc
andersonhc merged commit e876292 into py-pdf:master Oct 11, 2026
23 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