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 theVec<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
impl Delimiter
Sourcepub fn classify_flanking(&mut self, tokens: &[Token])
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:
- Not followed by punctuation
- 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§
Auto Trait Implementations§
impl Freeze for Delimiter
impl RefUnwindSafe for Delimiter
impl Send for Delimiter
impl Sync for Delimiter
impl Unpin for Delimiter
impl UnwindSafe for Delimiter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more