Skip to main content

render_guide_human

Function render_guide_human 

Source
pub fn render_guide_human(content: &str, width: usize, color: bool) -> String
Expand description

Renders guide markdown into a terminal-friendly string.

Each source line is individually wrapped to width columns, breaking between words rather than mid-word. (A single token longer than width — a long URL, say — can still overflow, since it has no interior break point.) The underlying parser is line-oriented and preserves every source newline: it does not join soft-wrapped lines into flowing paragraphs. Author guide markdown with each paragraph on a single physical line so it reflows to the terminal width; a paragraph that is hard-wrapped in the source stays wrapped at its authored breaks. See docs/concepts.md (“Guides”) for authoring guidance.

color selects a styled skin (true, for an interactive terminal) or a plain, unstyled skin (false) whose output contains no ANSI escapes and is therefore deterministic for pipes and tests. Fenced code blocks and tables are laid out by the renderer rather than reflowed as prose, so their structure is preserved.