Struct bbscope::BBCode

source ·
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

source

pub fn default() -> Result<Self, Error>

Get a default bbcode parser. Should hopefully have reasonable defaults!

source

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

source

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?)

source

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

source

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

source

pub fn plaintext_ids() -> Vec<&'static str>

source

pub fn basics() -> Result<Vec<MatchInfo>, Error>

source

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!

source

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!

source

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

source

pub fn parse_profiled_opt(&mut self, input: &str, _name: String) -> String

This MAY OR MAY NOT profile, depending on your featureset!

Trait Implementations§

source§

impl Clone for BBCode

source§

fn clone(&self) -> BBCode

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for BBCode

§

impl Send for BBCode

§

impl Sync for BBCode

§

impl Unpin for BBCode

§

impl !UnwindSafe for BBCode

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.