Skip to content

ENH Avoid redundant CSS in Styler.render #30876

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

Merged
merged 5 commits into from
Jan 20, 2020

Conversation

jnothman
Copy link
Contributor

@jnothman jnothman commented Jan 10, 2020

Where multiple styled cells have the same CSS, only make one CSS declaration. This can reduce the output size substantially.

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Where multiple cells have the same CSS, only make one CSS declaration.
@jnothman jnothman changed the title Avoid redundant CSS in Styler.render ENH Avoid redundant CSS in Styler.render Jan 10, 2020
@@ -14,7 +14,7 @@
{% block before_cellstyle %}{% endblock before_cellstyle %}
{% block cellstyle %}
{%- for s in cellstyle %}
#T_{{uuid}}{{s.selector}} {
{%- for selector in s.selectors -%}{%- if not loop.first -%},{%- endif -%}#T_{{uuid}}{{selector}}{%- endfor -%} {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while since I've looked at this, but I'm a bit confused. What is this section doing? Is it writing the css styles? Does it matter what order the selector vs the id #T_uuid goes in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a comma-separated list of id selectors. Comma is "or", the order doesn't matter.

@jnothman
Copy link
Contributor Author

Any interest in this?

@jreback jreback added the IO HTML read_html, to_html, Styler.apply, Styler.applymap label Jan 20, 2020
@jreback
Copy link
Contributor

jreback commented Jan 20, 2020

this seems ok to me, basically writing the 'same' style, but de-duplicated so its much smaller? @TomAugspurger

@TomAugspurger TomAugspurger added this to the 1.1 milestone Jan 20, 2020
@jnothman
Copy link
Contributor Author

jnothman commented Jan 20, 2020 via email

@jreback jreback merged commit e0bd394 into pandas-dev:master Jan 20, 2020
@jreback
Copy link
Contributor

jreback commented Jan 20, 2020

thanks @jnothman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO HTML read_html, to_html, Styler.apply, Styler.applymap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants