diff --git a/great_tables/_tab_create_modify.py b/great_tables/_tab_create_modify.py index 542ce6fb8..1153832b7 100644 --- a/great_tables/_tab_create_modify.py +++ b/great_tables/_tab_create_modify.py @@ -82,7 +82,7 @@ def tab_style( new_data = self for loc in locations: - new_data = set_style(loc, self, style) + new_data = set_style(loc, new_data, style) return new_data diff --git a/great_tables/_utils_render_html.py b/great_tables/_utils_render_html.py index dc1be0f0d..110f34eed 100644 --- a/great_tables/_utils_render_html.py +++ b/great_tables/_utils_render_html.py @@ -409,8 +409,6 @@ def create_columns_component_h(data: GTData) -> str: def create_body_component_h(data: GTData) -> str: - import pandas as pd - # for now, just coerce everything in the original data to a string # so we can fill in the body data with it _str_orig_data = cast_frame_to_string(data._tbl_data) @@ -482,13 +480,10 @@ def create_body_component_h(data: GTData) -> str: # Develop the `style` attribute for the current cell if len(styles_i) > 0: - style_entries = [x.styles for x in styles_i] - cell_styles_list: List[str] = [] - for style in style_entries: - style_element = style[0] - rendered_style = style_element._to_html_style() - cell_styles_list.append(rendered_style) - cell_styles = f'style="{" ".join(cell_styles_list)}"' + " " + # flatten all StyleInfo.styles lists + style_entries = list(chain(*[x.styles for x in styles_i])) + rendered_styles = [el._to_html_style() for el in style_entries] + cell_styles = f'style="{" ".join(rendered_styles)}"' + " " else: cell_styles = "" diff --git a/tests/__snapshots__/test_utils_render_html.ambr b/tests/__snapshots__/test_utils_render_html.ambr index 7de77b5ed..d0eba6311 100644 --- a/tests/__snapshots__/test_utils_render_html.ambr +++ b/tests/__snapshots__/test_utils_render_html.ambr @@ -1,4 +1,40 @@ # serializer version: 1 +# name: test_body_multiple_locations + ''' +
+