BBCode

Struct 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 fully custom set of tags, use this endpoint

Source

pub fn from_config( config: BBCodeTagConfig, additional_matchers: Option<Vec<MatchInfo>>, ) -> Result<Self, Error>

Create a BBCode parser from a config, using standard tags (plus any extras specified in the config). If you want a tweaked BBCode parser but based off reasonable defaults, use this. BBCode::default() is the same as calling this with BBCodeTagConfig::default(). You can also optionally pass in more tags you wish to support (this is done because the order of tag matchers is important, and the “standard” configuration requires some internal matchers to come after yours)

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 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 duplicate 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 Freeze for BBCode

§

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.