pub struct BBCode {
pub matchers: Arc<Vec<MatchInfo>>,
}Expand description
The main bbcode system. You create this to parse bbcode! Inexpensive clones, since fields are all reference counted.
Fields§
§matchers: Arc<Vec<MatchInfo>>Supply this!
Implementations§
source§impl BBCode
impl BBCode
sourcepub fn default() -> Result<Self, Error>
pub fn default() -> Result<Self, Error>
Get a default bbcode parser. Should hopefully have reasonable defaults!
sourcepub fn from_matchers(matchers: Vec<MatchInfo>) -> Self
pub fn from_matchers(matchers: Vec<MatchInfo>) -> Self
Create a BBCode parser from the given list of matchers. If you’re building a custom set of tags,
or merging [BBCode::basic()] with BBCode::extras() (and maybe more), use this endpoint
sourcepub fn to_consumer(&mut self)
pub fn to_consumer(&mut self)
Convert the current bbcode instance to one which consumes all tags it used to parse. The raw text SHOULD be left untouched (I think?)
sourcepub fn get_tagregex(
tag: &'static str,
open_consume: Option<(i32, i32)>,
close_consume: Option<(i32, i32)>
) -> (String, String)
pub fn get_tagregex( tag: &'static str, open_consume: Option<(i32, i32)>, close_consume: Option<(i32, i32)> ) -> (String, String)
Produce the two basic regexes (open and close) for bbcode tags
sourcepub fn add_tagmatcher(
matchers: &mut Vec<MatchInfo>,
tag: &'static str,
info: ScopeInfo,
open_consume: Option<(i32, i32)>,
close_consume: Option<(i32, i32)>
) -> Result<(), Error>
pub fn add_tagmatcher( matchers: &mut Vec<MatchInfo>, tag: &'static str, info: ScopeInfo, open_consume: Option<(i32, i32)>, close_consume: Option<(i32, i32)> ) -> Result<(), Error>
Add the open and close matches to the given vector for the given tag (you must construct ScopeInfo yourself). open_consume and close_consume are the amount of newlines to take before and after the open and close tag
pub fn plaintext_ids() -> Vec<&'static str>
pub fn basics() -> Result<Vec<MatchInfo>, Error>
sourcepub fn basics_config(config: BBCodeTagConfig) -> Result<Vec<MatchInfo>, Error>
pub fn basics_config(config: BBCodeTagConfig) -> Result<Vec<MatchInfo>, Error>
Get a vector of ALL basic matchers! This is the function you want to call to get a vector for the bbcode generator!
sourcepub fn extras() -> Result<Vec<MatchInfo>, Error>
pub fn extras() -> Result<Vec<MatchInfo>, Error>
Some fancy extra bbcode. Does not include basics! These are nonstandard, you don’t have to use them!
sourcepub fn parse(&self, input: &str) -> String
pub fn parse(&self, input: &str) -> String
Main function! You call this to parse your raw bbcode! It also escapes html stuff so it can be used raw! Current version keeps newlines as-is and it’s expected you use pre-wrap, later there may be modes for more standard implementations
sourcepub fn parse_profiled_opt(&mut self, input: &str, _name: String) -> String
pub fn parse_profiled_opt(&mut self, input: &str, _name: String) -> String
This MAY OR MAY NOT profile, depending on your featureset!