Skip to content

Commit

Permalink
Fix deprecation warning in as_raw_html for Python 3.13 (#563)
Browse files Browse the repository at this point in the history
* Fix deprecation warning in `re.sub` for Python 3.13

* chore: reformat for linter

---------

Co-authored-by: Michael Chow <[email protected]>
  • Loading branch information
stinodego and machow authored Dec 16, 2024
1 parent eac1fb4 commit bc64116
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions great_tables/_scss.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,20 @@ def compile_scss(
gt_styles_default = (files("great_tables") / "css/gt_styles_default.scss").read_text()

if compress:
gt_styles_default = re.sub(r"\s+", " ", gt_styles_default, 0, re.MULTILINE)
gt_styles_default = re.sub(r"}", "}\n", gt_styles_default, 0, re.MULTILINE)
gt_styles_default = re.sub(r"\s+", " ", gt_styles_default, count=0, flags=re.MULTILINE)
gt_styles_default = re.sub(r"}", "}\n", gt_styles_default, count=0, flags=re.MULTILINE)

compiled_css = Template(gt_styles_default).substitute(final_params)

if has_id:
compiled_css = re.sub(r"\.gt_", f"#{id} .gt_", compiled_css, 0, re.MULTILINE)
compiled_css = re.sub(r"thead", f"#{id} thead", compiled_css, 0, re.MULTILINE)
compiled_css = re.sub(r"^( p|p) \{", f"#{id} p {{", compiled_css, 0, re.MULTILINE)
compiled_css = re.sub(r"\.gt_", f"#{id} .gt_", compiled_css, count=0, flags=re.MULTILINE)
compiled_css = re.sub(r"thead", f"#{id} thead", compiled_css, count=0, flags=re.MULTILINE)
compiled_css = re.sub(
r"^( p|p) \{", f"#{id} p {{", compiled_css, count=0, flags=re.MULTILINE
)

if all_important:
compiled_css = re.sub(r";", " !important;", compiled_css, 0, re.MULTILINE)
compiled_css = re.sub(r";", " !important;", compiled_css, count=0, flags=re.MULTILINE)

finalized_css = f"{gt_table_class_str}\n\n{compiled_css}"

Expand Down

0 comments on commit bc64116

Please sign in to comment.