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
impl BlockParser
Sourcepub fn release_block(&mut self, block: NodeId)
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).
Sourcepub fn is_top_level(&self, block: NodeId) -> bool
pub fn is_top_level(&self, block: NodeId) -> bool
Whether block sits at the top of the document.
pub fn new(options: Options) -> Self
Sourcepub fn incorporate_line(&mut self, ln: &str)
pub fn incorporate_line(&mut self, ln: &str)
Incorporate one line into the tree: the three steps of Appendix A.
Sourcepub fn parse(self, input: &str) -> (Tree, RefMap)
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.
Sourcepub fn close_all(&mut self)
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.
Sourcepub fn finish(self) -> (Tree, RefMap)
pub fn finish(self) -> (Tree, RefMap)
BlockParser::close_all, then the tree and the link reference
map.