Skip to main content

highlight

Function highlight 

Source
pub fn highlight(text: &str) -> String
Expand description

Emphasise a fragment inside a message, in the terminal’s own accent.

Sanitises what it is given, because most of what is highlighted came from somewhere else: a declared check’s name, a program it wants to run, a term matched in a staged file. An escape sequence inside would also break this function’s own painting — the reset it emits is no longer the last word — so this is as much about the colouring being correct as about the text being safe.