Struct harper_core::Document
source · pub struct Document { /* private fields */ }
Implementations§
source§impl Document
impl Document
sourcepub fn new(text: &str, parser: Box<dyn Parser>) -> Self
pub fn new(text: &str, parser: Box<dyn Parser>) -> Self
Lexes and parses text to produce a document. Choosing to parse with markdown may have a performance penalty
pub fn new_from_vec(source: Vec<char>, parser: Box<dyn Parser>) -> Self
pub fn new_plain_english(text: &str) -> Self
pub fn new_markdown(text: &str) -> Self
pub fn get_token_at_char_index(&self, char_index: usize) -> Option<Token>
sourcepub fn get_token(&self, index: usize) -> Option<Token>
pub fn get_token(&self, index: usize) -> Option<Token>
Defensively attempt to grab a specific token.
pub fn tokens(&self) -> impl Iterator<Item = Token> + '_
pub fn fat_tokens(&self) -> impl Iterator<Item = FatToken> + '_
pub fn sentences(&self) -> impl Iterator<Item = &[Token]> + '_
sourcepub fn words(&self) -> impl Iterator<Item = Token> + '_
pub fn words(&self) -> impl Iterator<Item = Token> + '_
Returns all tokens whose kind
is TokenKind::Word
pub fn get_span_content(&self, span: Span) -> &[char]
pub fn get_span_content_str(&self, span: Span) -> String
pub fn get_full_string(&self) -> String
pub fn get_full_content(&self) -> &[char]
pub fn apply_suggestion(&mut self, suggestion: &Suggestion, span: Span)
Trait Implementations§
source§impl TokenStringExt for Document
impl TokenStringExt for Document
fn first_word(&self) -> Option<Token>
source§fn first_sentence_word(&self) -> Option<Token>
fn first_sentence_word(&self) -> Option<Token>
Grabs the first word in the sentence.
Will also return
None
if there is an unlintable token in the
position of the first word.source§fn first_non_whitespace(&self) -> Option<Token>
fn first_non_whitespace(&self) -> Option<Token>
Grabs the first token that isn’t whitespace from the token string.
fn iter_word_indices(&self) -> impl Iterator<Item = usize> + '_
fn iter_words(&self) -> impl Iterator<Item = &Token> + '_
fn iter_space_indices(&self) -> impl Iterator<Item = usize> + '_
fn iter_spaces(&self) -> impl Iterator<Item = &Token> + '_
fn iter_apostrophe_indices(&self) -> impl Iterator<Item = usize> + '_
fn iter_apostrophes(&self) -> impl Iterator<Item = &Token> + '_
source§fn span(&self) -> Option<Span>
fn span(&self) -> Option<Span>
Grab the span that represents the beginning of the first element and the
end of the last element.
fn iter_quote_indices(&self) -> impl Iterator<Item = usize> + '_
fn iter_quotes(&self) -> impl Iterator<Item = Token> + '_
fn iter_number_indices(&self) -> impl Iterator<Item = usize> + '_
fn iter_numbers(&self) -> impl Iterator<Item = Token> + '_
Auto Trait Implementations§
impl Freeze for Document
impl !RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl !UnwindSafe for Document
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more