From a52615848737e2b834d47820677ce8573dd81081 Mon Sep 17 00:00:00 2001 From: Marc Wouts Date: Sun, 10 Dec 2023 12:06:36 +0000 Subject: [PATCH] Allow html in columns --- docs/changelog.md | 7 +++++++ itables/javascript.py | 2 +- itables/version.py | 2 +- tests/test_html_in_table_header.py | 9 +++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 tests/test_html_in_table_header.py diff --git a/docs/changelog.md b/docs/changelog.md index 1bec8a1e..96145cfc 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,13 @@ ITables ChangeLog ================= +1.6.3 (2023-12-10) +------------------ + +**Changed** +- HTML in table columns is supported ([#213](https://github.com/mwouts/itables/issues/213)) + + 1.6.2 (2023-10-07) ------------------ diff --git a/itables/javascript.py b/itables/javascript.py index e601972b..761783d1 100644 --- a/itables/javascript.py +++ b/itables/javascript.py @@ -144,7 +144,7 @@ def _table_header( # Generate table head using pandas.to_html(), see issue 63 pattern = re.compile(r".*(.*)", flags=re.MULTILINE | re.DOTALL) try: - html_header = df.head(0).to_html() + html_header = df.head(0).to_html(escape=False) except AttributeError: # Polars DataFrames html_header = pd.DataFrame(data=[], columns=df.columns).to_html() diff --git a/itables/version.py b/itables/version.py index 211dd9d4..6557b260 100644 --- a/itables/version.py +++ b/itables/version.py @@ -1,3 +1,3 @@ """ITables' version number""" -__version__ = "1.6.2" +__version__ = "1.6.3" diff --git a/tests/test_html_in_table_header.py b/tests/test_html_in_table_header.py new file mode 100644 index 00000000..eb09d853 --- /dev/null +++ b/tests/test_html_in_table_header.py @@ -0,0 +1,9 @@ +import pandas as pd + +from itables import to_html_datatable + + +def test_html_in_table_header(df=pd.DataFrame({"B": [1]})): + html = to_html_datatable(df) + print(html) + assert "B" in html