parse_simple_color_and_pattern_spec

parse_simple_color_and_pattern_spec#

treescope.formatting_util.parse_simple_color_and_pattern_spec(requested_color: str | tuple[str, str], typename_for_warning: str | None = None) tuple[str | None, str | None][source]#

Parses a background color and pattern from a user-provided color request.

Parameters:
  • requested_color – A color request, which is either a single CSS color or a tuple of outline and background colors.

  • typename_for_warning – If provided, and the color is invalid, a warning will be issued with this typename as context.

Returns:

A tuple (background_color, background_pattern) that can be passed to the Treescope low-level representation construction functions (such as build_foldable_tree_node_from_children) that will configure it with the given background color and outline.