Skip to main content

Crate standout_bbparser

Crate standout_bbparser 

Source
Expand description

BBCode-style tag parser for terminal styling: [tag]content[/tag] markup with nested tags and multiple output modes (see TagTransform). Tag names follow CSS identifier rules ([a-z_][a-z0-9_-]*); a literal [/] is written \[/\].

use standout_bbparser::{BBParser, TagTransform};
use console::Style;
use std::collections::HashMap;

let mut styles = HashMap::new();
styles.insert("bold".to_string(), Style::new().bold());

let parser = BBParser::new(styles, TagTransform::Remove);
assert_eq!(parser.parse("[bold]hello[/bold]"), "hello");

Modules§

ansi
Reading text in ANSI units, and closing the state a cut leaves open.

Structs§

BBParser
StyledText
UnknownTagError
UnknownTagErrors

Enums§

TagTransform
UnknownTagBehavior
UnknownTagKind

Functions§

is_valid_tag_name
strip_tags