Skip to main content

BlockParser

Struct BlockParser 

Source
pub struct BlockParser {
    pub options: Options,
    pub refmap: RefMap,
    pub tree: Tree,
    pub events: Option<Vec<BlockEvent>>,
    pub dropped: Vec<NodeId>,
    /* private fields */
}
Expand description

The block-phase parser: the open spine, the current line, and the tree being built.

Fields§

§options: Options§refmap: RefMap§tree: Tree§events: Option<Vec<BlockEvent>>

The events of the lines incorporated since the driver last took them, or None, the default, when no driver asks: the batch parse records nothing.

§dropped: Vec<NodeId>

Blocks the block phase took out of the tree with no Close of their own, while a driver asks for events: a paragraph a table’s header row or a setext underline replaced. A driver that keeps no tree gives them back with BlockParser::release_block.

Implementations§

Source§

impl BlockParser

Source

pub fn release_block(&mut self, block: NodeId)

Give back the arena slots of block and everything below it, for a driver that writes blocks as they finish and keeps no tree: a block at the top of the document once its Close is written, a block the phase took out of the tree. Nothing reads such a block again: the phase’s continuation and laziness rules read only the open blocks on the spine, and the blank-line flags and a list’s looseness are settled before its Close. What the phase still holds of it is let go too, so that a slot taken by a new block is never mistaken for it (tabnas/markdown#100).

Source

pub fn is_top_level(&self, block: NodeId) -> bool

Whether block sits at the top of the document.

Source

pub fn new(options: Options) -> Self

Source

pub fn incorporate_line(&mut self, ln: &str)

Incorporate one line into the tree: the three steps of Appendix A.

Source

pub fn parse(self, input: &str) -> (Tree, RefMap)

Feed every line of input and finish. An empty document still incorporates one empty line, exactly as the historical split-based loop did: line count and sourcepos depend on it. Line cutting and section 2.3 NUL replacement both live in segment_next_line.

Source

pub fn close_all(&mut self)

Close every still-open block and stamp the parse-time gfm flag. line_number is the count of incorporated lines, so an incremental driver (one that feeds incorporate_line itself instead of calling parse) finishes with exactly the same finalization the batch loop gets.

Source

pub fn finish(self) -> (Tree, RefMap)

BlockParser::close_all, then the tree and the link reference map.

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.