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: boolRead 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
impl InlineParser
pub fn new(refmap: RefMap, options: Options) -> Self
Sourcepub fn keeping_references(options: Options) -> Self
pub fn keeping_references(options: Options) -> Self
A parser that keeps references unresolved (see keep_references).
Sourcepub fn parse_backticks(&mut self, tree: &mut Tree, block: NodeId) -> bool
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.
pub fn parse_backslash(&mut self, tree: &mut Tree, block: NodeId) -> bool
pub fn parse_autolink(&mut self, tree: &mut Tree, block: NodeId) -> bool
pub fn parse_html_tag(&mut self, tree: &mut Tree, block: NodeId) -> bool
Sourcepub fn scan_delims(&self, cc: u8) -> Option<DelimScan>
pub fn scan_delims(&self, cc: u8) -> Option<DelimScan>
Classify the run of cc starting at pos without consuming it.
Sourcepub fn handle_delim(&mut self, cc: u8, tree: &mut Tree, block: NodeId) -> bool
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.
Sourcepub fn process_emphasis(&mut self, tree: &mut Tree, stack_bottom: Option<usize>)
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.
Sourcepub fn parse_link_title(&mut self) -> Option<String>
pub fn parse_link_title(&mut self) -> Option<String>
The link title without its delimiters, unescaped; None when there
is no title here.
Sourcepub fn parse_link_destination(&mut self) -> Option<String>
pub fn parse_link_destination(&mut self) -> Option<String>
A destination that is backslash-unescaped and entity-decoded, but
not percent-encoded; see scan_link_destination.
Sourcepub fn parse_link_label(&mut self) -> usize
pub fn parse_link_label(&mut self) -> usize
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.
pub fn parse_open_bracket(&mut self, tree: &mut Tree, block: NodeId) -> bool
Sourcepub fn parse_bang(&mut self, tree: &mut Tree, block: NodeId) -> bool
pub fn parse_bang(&mut self, tree: &mut Tree, block: NodeId) -> bool
! only matters when it introduces an image.
Sourcepub fn parse_close_bracket(&mut self, tree: &mut Tree, block: NodeId) -> bool
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 ].
pub fn parse_entity(&mut self, tree: &mut Tree, block: NodeId) -> bool
Sourcepub fn parse_string(&mut self, tree: &mut Tree, block: NodeId) -> bool
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.
Sourcepub fn parse_newline(&mut self, tree: &mut Tree, block: NodeId) -> bool
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.
Sourcepub fn parse_inline(&mut self, tree: &mut Tree, block: NodeId) -> bool
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.
Sourcepub fn parse_literal_char(&mut self, tree: &mut Tree, block: NodeId) -> bool
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.
Sourcepub fn begin_block(&mut self, tree: &Tree, block: NodeId) -> bool
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.
Sourcepub fn finish_block(&mut self, tree: &mut Tree, block: NodeId)
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.
Sourcepub fn parse(&mut self, tree: &mut Tree, block: NodeId)
pub fn parse(&mut self, tree: &mut Tree, block: NodeId)
Parse one paragraph’s or heading’s raw content into inline children.
Sourcepub fn parse_reference(&mut self, s: &str, refmap: &mut RefMap) -> usize
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.