ecolab.highlight_html

Contents

ecolab.highlight_html#

etils.ecolab.highlight_html(code: str) str[source]#

Add Python syntax highlighting to a Python code string.

Usage:

Example:

@dataclasses.dataclass
class A:
  x: int

  def _repr_html_(self) -> str:
    from etils import ecolab  # Lazy-import ecolab

    return ecolab.highlight_html(repr(self))
Parameters:

code – The string to wrap

Returns:

The HTML string representation