Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: CSS strings truncated at ":" #59720

Merged
merged 12 commits into from
Oct 4, 2024

Conversation

invalidarg
Copy link
Contributor

Fixes issue #59623

Changes maybe_convert_css_to_tuples called by style.map() so that it no longer truncates the CSS-value at the ":".

e.g. background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" id="flag-icons-dk" viewBox="0 0 640 480"><path fill="%23c8102e" d="M0 0h640.1v480H0z"/><path fill="%23fff" d="M205.7 0h68.6v480h-68.6z"/><path fill="%23fff" d="M0 205.7h640.1v68.6H0z"/></svg>'); will no longer be truncated to the tuple ("background-image" , "url('data:")

@mroeschke mroeschke added the Styler conditional formatting using DataFrame.style label Sep 5, 2024
@attack68
Copy link
Contributor

attack68 commented Sep 5, 2024

needs a unit test to demonstrate it solves the test

@invalidarg
Copy link
Contributor Author

@attack68 the failing test seems unralated to my change? I'm not sure how to proceed.

The pre-commit.ci is failing but I'm not sure how to fix. I think it fails due to this string.

msg = (
	"Styles supplied as string must follow CSS rule formats, "
	"for example 'attr: val;'. 'err' was given."
)

@attack68
Copy link
Contributor

ruff format failed. This means you need to install ruff and run ruff format in terminal on your file. It will edit it according to specifications, i.e. it might remove some whitespace or dangling commas etc.

* black test_style

* Update style_render.py
@invalidarg
Copy link
Contributor Author

ruff format failed. This means you need to install ruff and run ruff format in terminal on your file. It will edit it according to specifications, i.e. it might remove some whitespace or dangling commas etc.

Thanks. It looks good now I think :)

@attack68
Copy link
Contributor

attack68 commented Oct 4, 2024

Thanks. LGTM.
This is a nice fix for the issue, although we acknowledge we can't go further without a proper CSS parser.

@mroeschke mroeschke added this to the 3.0 milestone Oct 4, 2024
@mroeschke mroeschke merged commit aea1643 into pandas-dev:main Oct 4, 2024
51 checks passed
@mroeschke
Copy link
Member

Thanks @invalidarg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Styler conditional formatting using DataFrame.style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants