pub fn strip_markup(s: &str) -> StringExpand description
Strip markup tags from a string for plain output.
Removes [tag]...[/] patterns commonly used in rich markup syntax.
Handles nested tags and preserves literal bracket characters when
they’re not part of markup patterns.
A tag is considered markup if:
- It starts with
/(closing tags:[/],[/bold]) - It contains a space (compound styles:
[red on white]) - It has 2+ alphabetic characters (style names:
[bold],[red])
This preserves array indices like [0], [i], [idx] which are typically
short identifiers without spaces.
§Example
use sqlmodel_console::console::strip_markup;
assert_eq!(strip_markup("[bold]text[/]"), "text");
assert_eq!(strip_markup("[red on white]hello[/]"), "hello");
assert_eq!(strip_markup("no markup"), "no markup");
assert_eq!(strip_markup("array[0]"), "array[0]");