Skip to main content

InlineParser

Struct InlineParser 

Source
pub struct InlineParser {
    pub subject: String,
    pub pos: usize,
    pub refmap: RefMap,
    pub options: Options,
    pub keep_references: bool,
    /* private fields */
}
Expand description

The inline scanner: the subject, the scan position, and the two auxiliary stacks.

Fields§

§subject: String§pos: usize§refmap: RefMap§options: Options§keep_references: bool

Read a bracketed label as a reference whether or not the document defines it, keeping it unresolved (link_reference, image_reference) rather than looking it up in refmap: the parse the AST is projected from. The inline parse of a block then depends on nothing outside the block, which is what lets the engine path finish a block’s inlines when the block closes. Off, the parse resolves references as CommonMark does, which the HTML renderer needs.

Implementations§

Source§

impl InlineParser

Source

pub fn new(refmap: RefMap, options: Options) -> Self

Source

pub fn keeping_references(options: Options) -> Self

A parser that keeps references unresolved (see keep_references).

Source

pub fn parse_backticks(&mut self, tree: &mut Tree, block: NodeId) -> bool

A code span runs from a backtick string to the next backtick string of exactly the same length. Unmatched opening backticks are literal text.

Source

pub fn parse_backslash(&mut self, tree: &mut Tree, block: NodeId) -> bool

Source

pub fn parse_html_tag(&mut self, tree: &mut Tree, block: NodeId) -> bool

Source

pub fn scan_delims(&self, cc: u8) -> Option<DelimScan>

Classify the run of cc starting at pos without consuming it.

Source

pub fn handle_delim(&mut self, cc: u8, tree: &mut Tree, block: NodeId) -> bool

Emit a delimiter run as text and push it on the delimiter stack.

Source

pub fn process_emphasis(&mut self, tree: &mut Tree, stack_bottom: Option<usize>)

The spec’s “process emphasis” procedure. stack_bottom is the floor: for the whole-block call it is None, and for the inlines of a link it is the delimiter that was on top when the link’s [ opened.

The link title without its delimiters, unescaped; None when there is no title here.

A destination that is backslash-unescaped and entity-decoded, but not percent-encoded; see scan_link_destination.

The byte length of the link label at pos, brackets included, advancing past it; 0 if there is no label here or it is over the section 4.7 999-character limit.

Source

pub fn parse_open_bracket(&mut self, tree: &mut Tree, block: NodeId) -> bool

Source

pub fn parse_bang(&mut self, tree: &mut Tree, block: NodeId) -> bool

! only matters when it introduces an image.

Source

pub fn parse_close_bracket(&mut self, tree: &mut Tree, block: NodeId) -> bool

The spec’s “look for link or image” procedure. On a ], walk back to the newest bracket opener and try, in order: an inline (dest "title"), a full [label], a collapsed [] or a shortcut reference. Anything that fails backtracks to just after the ] and leaves a literal ].

Source

pub fn parse_entity(&mut self, tree: &mut Tree, block: NodeId) -> bool

Source

pub fn parse_string(&mut self, tree: &mut Tree, block: NodeId) -> bool

A chunk of ordinary text: everything up to the next character that could start an inline construct. A byte scan is exact, because the terminators are all ASCII.

Source

pub fn parse_newline(&mut self, tree: &mut Tree, block: NodeId) -> bool

Sections 6.7 and 6.8: two or more spaces before the line ending make a hard break, anything else a soft one. Trailing spaces are dropped either way, as is the indentation of the next line.

Source

pub fn parse_inline(&mut self, tree: &mut Tree, block: NodeId) -> bool

One inline construct at pos; false only at the end of the subject.

Source

pub fn parse_literal_char(&mut self, tree: &mut Tree, block: NodeId) -> bool

A character nothing claimed: consume it as literal text. Only < and & reach here from the dispatch, so the byte at pos is a whole character; the engine driver’s literal fallback may reach it with any character, so the whole character is taken either way.

Source

pub fn begin_block(&mut self, tree: &Tree, block: NodeId) -> bool

Reset for one block’s raw content; false when the trimmed subject is empty. Trimming is what stops trailing spaces at the end of a block from making a hard break, and drops the leading indentation of the first line. The trim must remove exactly what String.prototype.trim removes, which is js_trim.

Source

pub fn finish_block(&mut self, tree: &mut Tree, block: NodeId)

The tail of a block’s inline parse: clear the raw content, resolve emphasis over the whole delimiter stack.

Source

pub fn parse(&mut self, tree: &mut Tree, block: NodeId)

Parse one paragraph’s or heading’s raw content into inline children.

Source

pub fn parse_reference(&mut self, s: &str, refmap: &mut RefMap) -> usize

Section 4.7: consume one link reference definition at the start of s, adding it to refmap. Returns the number of BYTES consumed. The block phase goes through parse_definitions, which reads every leading definition of a paragraph over one copy of it.

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.