Struct Delimiter

Source
pub struct Delimiter {
    pub ch: char,
    pub run_length: usize,
    pub token_position: usize,
    pub parsed_position: usize,
    pub active: bool,
    pub can_open: bool,
    pub can_close: bool,
}
Expand description

Manages Delimiter runs in a markdown document. A delimiter run is a sequence of the same character (e.g., *, _, ~) that can be used for bold/italic writing.

§Fields

  • ch - The character that represents the delimiter (e.g., *, _, ~).
  • run_length - The number of times the delimiter character appears in a row.
  • token_position - The position of the first token in this delimiter run.
  • parsed_position - The position in the Vec<MdInlineElement> where the content of this delimiter run will be stored.
  • active - Whether this delimiter run is currently active (i.e., it has not been closed).
  • can_open - Whether this delimiter can open a new emphasis run (e.g., it is left-flanking).
  • can_close - Whether this delimiter can close an existing emphasis run (e.g., it is right-flanking).

Fields§

§ch: char§run_length: usize§token_position: usize§parsed_position: usize§active: bool§can_open: bool§can_close: bool

Implementations§

Source§

impl Delimiter

Source

pub fn classify_flanking(&mut self, tokens: &[Token])

Determines whether a delimiter is “Left”, “Right”, or “Both” flanking For exmample, it is left flanking if it’s not followed by non-whitespace, and either:

  1. Not followed by punctuation
  2. Followed by punctuation and preceded by whitespace or punctuation

Modifies the can_open and can_close fields in-place based on the classification.

See ihttps://spec.commonmark.org/0.31.2/#left-flanking-delimiter-run for more information.

§Arguments
  • tokens - A slice of tokens to classify the delimiter against.

Trait Implementations§

Source§

impl Clone for Delimiter

Source§

fn clone(&self) -> Delimiter

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
Source§

impl Debug for Delimiter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.
§

impl<T> ErasedDestructor for T
where T: 'static,