jsonschema_diff.color.base

Classes

HighlighterPipeline

Chain of LineHighlighter() stages.

Module Contents

class HighlighterPipeline(
stages: Iterable[LineHighlighter],
)[source]

Chain of LineHighlighter() stages.

Parameters:

stages – Iterable of LineHighlighter instances. The iterable is immediately materialised into a list so the pipeline can be reused.

Note

  • Each input line is passed through every stage in order.

  • If a stage exposes a bulk colorize_lines() method it is preferred over per-line iteration for performance.

stages: list[LineHighlighter][source]
colorize(text: str) Text[source]

Return a rich Text object with all styles applied.

Parameters:

text – Multi-line string to be colourised.

Returns:

  • One composite Text built by joining all styled lines with

  • \n separators.

colorize_and_render(text: str) str[source]

Colourise and immediately render to ANSI.

Parameters:

text – Multi-line input string.

Return type:

ANSI-encoded string ready for terminal output.