Skip to content

Commit

Permalink
python: remove css line for vscode (#4117)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jul 22, 2022
1 parent d394f83 commit ecc197f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion py-polars/polars/_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,14 @@ def write_style(self) -> None:
("tbody tr th", "vertical-align", "top"),
("thead th", "text-align", "right"),
("td", "white-space", "pre"),
("td", "line-height", "95%"),
("td", "padding-top", "0"),
("td", "padding-bottom", "0"),
]
# vs code cannot deal with that css line
# see #4102
if not in_vscode_notebook():
element_props.append(("td", "line-height", "95%"))

template_mid = "\n\n".join(map(lambda t: template_select % t, element_props))
template = dedent("\n".join((template_first, template_mid, template_last)))
self.write(template)
Expand All @@ -169,3 +173,15 @@ def render(self) -> list[str]:
self.write_style()
super().render()
return self.elements


def in_vscode_notebook() -> bool:
try:
# autoimported by notebooks
get_ipython() # type: ignore[name-defined]
os.environ["VSCODE_CWD"]
except NameError:
return False # not in notebook
except KeyError:
return False # not in VSCode
return True

0 comments on commit ecc197f

Please sign in to comment.