[−][src]Crate bbcode
A parsing library for bbcode
Unlike most bbcode "parser"s, this constructs a syntax tree that is easy to transform to a custom representation or analyze for other purposes. Its goal is primarily customizability of the output.
Getting the syntax tree for textual bbcode is as easy as calling
parse
:
use bbcode::{parse, Segment, quote::Quote}; static MESSAGE: &'static str = r#"[quote="Batman"]I'm batman[/quote] Isn't he [b]dreamy[/b]?"#; let ast = parse(MESSAGE); assert_eq!(ast, vec![ Segment::Quote(Quote { attribution: Some("Batman"), body: vec![Segment::Text("I'm batman")], }), Segment::Text("\nIsn't he "), Segment::Bold(vec![Segment::Text("dreamy")]), Segment::Text("?"), ]);
Modules
code | Inline code blocks. |
decoration | Plain text spans with additional decoration. |
list | Lists of items. |
quote | Block quotes. |
Enums
Segment | Any logical segment of data- a tag or plain text. |
Functions
parse | Parse a string into a sequence of |