Trait linemd::Parser [−][src]
pub trait Parser {}Show methods
fn get_range_str<S: SliceIndex<str>>(&self, range: S) -> &S::Output; fn next_char(&self, at: usize) -> Result<char, ParserError>; fn parse_md(&self) -> Vec<Token<'_>> { ... } fn parse_md_with_buf<'a>(&'a self, buf: &mut Vec<Token<'a>>) { ... } fn parse_token(&self, at: usize) -> Option<AtToken<'_>> { ... } fn parse_texty(&self, at: usize) -> Option<AtToken<'_>> { ... } fn parse_code(&self, at: usize) -> Option<AtToken<'_>> { ... } fn parse_inline_code(&self, at: usize) -> Option<AtToken<'_>> { ... } fn parse_list_item(&self, at: usize) -> Option<AtToken<'_>> { ... } fn parse_code_fence(&self, at: usize) -> Option<AtToken<'_>> { ... } fn parse_header(&self, at: usize) -> Option<AtToken<'_>> { ... } fn parse_inline_url(&self, at: usize) -> Option<AtToken<'_>> { ... } fn parse_text(&self, at: usize) -> Option<AtText<'_>> { ... } fn parse_line_break(&self, at: usize) -> Option<AtToken<'_>> { ... } fn consume_whitespace(&self, at: usize) -> Option<AtStr<'_>> { ... } fn consume_char_if<F: Fn(char) -> bool>(
&self,
at: usize,
f: F
) -> Option<usize> { ... } fn consume_while<F: Fn(char) -> bool>(
&self,
at: usize,
f: F
) -> Result<Option<AtStr<'_>>, (ParserError, Option<AtStr<'_>>)> { ... } fn consume_until<F: Fn(char, usize, usize) -> bool>(
&self,
at: usize,
f: F
) -> Result<Option<AtStr<'_>>, (ParserError, Option<AtStr<'_>>)> { ... } fn consume_until_str(
&self,
at: usize,
s: &str
) -> Result<Option<AtStr<'_>>, (ParserError, Option<AtStr<'_>>)> { ... } fn eof(&self, at: usize) -> bool { ... } fn consume_char(&self, at: usize) -> Result<(char, usize), ParserError> { ... }
Expand description
The core of this crate. This trait implements markdown parsing, and several utilities.
Implementing this trait for your own types is very easy, the onyl required methods are next_char
and get_range_str
. You can also provide implementations for other methods if you can include a
more optimized way for your types.
Required methods
fn get_range_str<S: SliceIndex<str>>(&self, range: S) -> &S::Output
fn get_range_str<S: SliceIndex<str>>(&self, range: S) -> &S::Output
Gets a string slice using the provided range.
fn next_char(&self, at: usize) -> Result<char, ParserError>
fn next_char(&self, at: usize) -> Result<char, ParserError>
Gets the character on index at
.
Provided methods
fn parse_md_with_buf<'a>(&'a self, buf: &mut Vec<Token<'a>>)
fn parse_md_with_buf<'a>(&'a self, buf: &mut Vec<Token<'a>>)
Parses self for tokens, and outputs to a buffer.
fn parse_token(&self, at: usize) -> Option<AtToken<'_>>
fn parse_texty(&self, at: usize) -> Option<AtToken<'_>>
fn parse_code(&self, at: usize) -> Option<AtToken<'_>>
fn parse_inline_code(&self, at: usize) -> Option<AtToken<'_>>
fn parse_list_item(&self, at: usize) -> Option<AtToken<'_>>
fn parse_code_fence(&self, at: usize) -> Option<AtToken<'_>>
fn parse_header(&self, at: usize) -> Option<AtToken<'_>>
fn parse_inline_url(&self, at: usize) -> Option<AtToken<'_>>
fn parse_text(&self, at: usize) -> Option<AtText<'_>>
fn parse_line_break(&self, at: usize) -> Option<AtToken<'_>>
fn consume_whitespace(&self, at: usize) -> Option<AtStr<'_>>
fn consume_char_if<F: Fn(char) -> bool>(&self, at: usize, f: F) -> Option<usize>
fn consume_while<F: Fn(char) -> bool>(
&self,
at: usize,
f: F
) -> Result<Option<AtStr<'_>>, (ParserError, Option<AtStr<'_>>)>
fn consume_until<F: Fn(char, usize, usize) -> bool>(
&self,
at: usize,
f: F
) -> Result<Option<AtStr<'_>>, (ParserError, Option<AtStr<'_>>)>
fn consume_until_str(
&self,
at: usize,
s: &str
) -> Result<Option<AtStr<'_>>, (ParserError, Option<AtStr<'_>>)>
fn consume_char(&self, at: usize) -> Result<(char, usize), ParserError>