Skip to main content

excerpt

Function excerpt 

Source
pub fn excerpt(body: &str, max_chars: usize) -> String
Expand description

A one-line, bounded, control-character-free excerpt of untrusted text.

Bounded because a reasoning model can return kilobytes, and a URL in a markdown file can be a multi-kilobyte data: URI; both end up in a terminal and in --format json. Control characters are replaced rather than passed through: the text is not drep’s, and an escape sequence in it would otherwise be interpreted by the terminal reading the report.

Shared rather than per-caller. The second copy, added for bare_url messages, truncated but did not strip control characters - the one thing this function exists for.