Skip to content

Commit a8ea92e

Browse files
committed
style string can have a final semicolon
1 parent 6da378b commit a8ea92e

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ITables ChangeLog
1313

1414
**Fixed**
1515
- We have added type hints to `itable.options` even for the options that don't have a default value ([#224](https://github.com/mwouts/itables/issues/224))
16+
- The optional final semicolon in `style` argument is now supported again ([#386](https://github.com/mwouts/itables/issues/386))
1617

1718

1819
2.4.0 (2025-05-17)

src/itables/javascript.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def get_expanded_style(style: Union[str, Mapping[str, str]]) -> dict[str, str]:
117117
elif isinstance(style, str):
118118
return {
119119
k.strip(): v.strip()
120-
for k, v in (item.split(":") for item in style.split(";"))
120+
for k, v in (item.split(":") for item in style.split(";") if item.strip())
121121
}
122122
else:
123123
raise TypeError(f"style must be a string or a dict, not {type(style)}")

tests/test_javascript.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
check_table_id,
1313
get_compact_classes,
1414
get_compact_style,
15+
get_expanded_style,
1516
get_itable_arguments,
1617
replace_value,
1718
to_html_datatable,
@@ -153,3 +154,16 @@ def test_unpkg_urls_are_up_to_date():
153154
UNPKG_DT_BUNDLE_CSS
154155
== f"https://www.unpkg.com/dt_for_itables@{bundle_version}/dt_bundle.css"
155156
)
157+
158+
159+
@pytest.mark.parametrize(
160+
"style",
161+
[
162+
"width: fit-content; float: left;",
163+
"width: fit-content; float: left; overflow: auto; max-height: 500px",
164+
],
165+
)
166+
def test_get_expanded_style(style: str):
167+
exp_style = get_expanded_style(style)
168+
compact_style = get_compact_style(exp_style)
169+
assert compact_style == style.replace(" ", "").removesuffix(";")

0 commit comments

Comments
 (0)