25 stable releases (6 major)

new 7.3.0 Apr 16, 2026
7.0.0 Feb 17, 2026
6.2.0 Feb 15, 2026
5.0.0 Feb 3, 2026
1.1.0 Jan 18, 2026

#2 in #bbcode


Used in 6 crates (2 directly)

MIT license

56KB
1K SLoC

BBCode-style tag parser for terminal styling.

This crate provides a parser for [tag]content[/tag] style markup, designed for terminal output styling. It handles nested tags correctly and supports multiple output modes.

Example

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());
styles.insert("red".to_string(), Style::new().red());

// Apply ANSI codes
let parser = BBParser::new(styles.clone(), TagTransform::Apply);
let output = parser.parse("[bold]hello[/bold]");
// output contains ANSI escape codes for bold

// Strip tags (plain text)
let parser = BBParser::new(styles.clone(), TagTransform::Remove);
let output = parser.parse("[bold]hello[/bold]");
assert_eq!(output, "hello");

// Keep tags visible (debug mode)
let parser = BBParser::new(styles, TagTransform::Keep);
let output = parser.parse("[bold]hello[/bold]");
assert_eq!(output, "[bold]hello[/bold]");

Unknown Tag Handling

Tags not found in the styles map can be handled in two ways:

For validation, use BBParser::validate to check for unknown tags before parsing.

Tag Name Syntax

Tag names follow CSS identifier rules:

  • Start with a letter (a-z) or underscore (_)
  • Followed by letters, digits (0-9), underscores, or hyphens (-)
  • Cannot start with a digit or hyphen followed by digit
  • Case-sensitive (lowercase recommended)

Pattern: [a-z_][a-z0-9_-]*

Dependencies

~1.5–3.5MB
~56K SLoC