Skip to content

comfit.highlight

Python
highlight(source: str, language: str, config: HighlightConfig | None = None) -> list[Line]

Highlight source into owned lines and tokens, releasing the GIL during parsing.

Results remain usable after later calls. Empty sources produce one line. A trailing newline produces a final empty line.

Raises:

  • ValueError – The language is unknown or a source range is invalid.
  • RuntimeError – The backend fails or injection nesting exceeds 32 layers.