Crate bbx

Source
Expand description

Robust and performant BBCode pull parser.

§Examples

§Simple parsing

let mut parser = BBParser::new(/* &str */ input);

for token in parser {
    println!("{:?}", token);
}

§Built-in sanitized HTML output

// Simple serializer default with all of the v1.0.0 tags considered "core" to the library.
let mut serializer: HtmlSerializer<SimpleHtmlWriter> =
    HtmlSerializer::with_tags(all_core_v1_tags());
let mut parser = BBParser::new(input);
println!("Document:");
println!("{}", serializer.serialize(parser));

§no_std

This feature set is std (hosted) only, due to the following features:

  • track_open_tags
  • parser_rules
  • html_gen (required std!)

Modules§

html
Simple HTML serialization from a BBParser’s output. While not comprehensive of more exotic usecases, likely sufficient for most and includes many pre-made tags.
rules
Parser rules, which can be pushed into a BBParser mid-iteration to change how parsing behaves.

Structs§

BBParser
Provides a BBCode parser over the given input, in the form of an iterator. BBParser is a pull parser, parsing the input on an on-demand basis as the user calls BBParser::next.
BBTag
Simple struct representing the tag and (possibly empty) arguments of a bbcode tag.
ParserConfig
Provides configuration information for BBParser, including enabled feature flags.
ParserFeature
Represents a set of flags.
Token
A parsed token, as returned by BBParser::next.

Enums§

TokenKind
Represents the type of a token in the parsed data.