diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-07 18:56:06 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-07 18:56:06 +0200 |
commit | 92b42e06f943338ce8b54b7e22cbb116ff598fa6 (patch) | |
tree | ff51df093f52dc33bfac5e1c236b41cfbd21c220 /src/construct/block_quote.rs | |
parent | fdb1f1694f44cfbc59d303a10371300b48d74627 (diff) | |
download | markdown-rs-92b42e06f943338ce8b54b7e22cbb116ff598fa6.tar.gz markdown-rs-92b42e06f943338ce8b54b7e22cbb116ff598fa6.tar.bz2 markdown-rs-92b42e06f943338ce8b54b7e22cbb116ff598fa6.zip |
Refactor to move token types to `token`
Diffstat (limited to '')
-rw-r--r-- | src/construct/block_quote.rs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/construct/block_quote.rs b/src/construct/block_quote.rs index a3ffbc7..096ac0a 100644 --- a/src/construct/block_quote.rs +++ b/src/construct/block_quote.rs @@ -19,10 +19,10 @@ //! //! ## Tokens //! -//! * [`BlockQuote`][TokenType::BlockQuote] -//! * [`BlockQuoteMarker`][TokenType::BlockQuoteMarker] -//! * [`BlockQuotePrefix`][TokenType::BlockQuotePrefix] -//! * [`BlockQuoteWhitespace`][TokenType::BlockQuoteWhitespace] +//! * [`BlockQuote`][Token::BlockQuote] +//! * [`BlockQuoteMarker`][Token::BlockQuoteMarker] +//! * [`BlockQuotePrefix`][Token::BlockQuotePrefix] +//! * [`BlockQuoteWhitespace`][Token::BlockQuoteWhitespace] //! //! ## References //! @@ -35,7 +35,8 @@ use crate::constant::TAB_SIZE; use crate::construct::partial_space_or_tab::space_or_tab_min_max; -use crate::tokenizer::{Code, State, StateFnResult, TokenType, Tokenizer}; +use crate::token::Token; +use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; /// Start of block quote. /// @@ -55,7 +56,7 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { fn before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { match code { Code::Char('>') => { - tokenizer.enter(TokenType::BlockQuote); + tokenizer.enter(Token::BlockQuote); cont_before(tokenizer, code) } _ => cont_before(tokenizer, code), @@ -82,10 +83,10 @@ pub fn cont(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { fn cont_before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { match code { Code::Char('>') => { - tokenizer.enter(TokenType::BlockQuotePrefix); - tokenizer.enter(TokenType::BlockQuoteMarker); + tokenizer.enter(Token::BlockQuotePrefix); + tokenizer.enter(Token::BlockQuoteMarker); tokenizer.consume(code); - tokenizer.exit(TokenType::BlockQuoteMarker); + tokenizer.exit(Token::BlockQuoteMarker); (State::Fn(Box::new(cont_after)), None) } _ => (State::Nok, None), @@ -101,20 +102,20 @@ fn cont_before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { fn cont_after(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { match code { Code::VirtualSpace | Code::Char('\t' | ' ') => { - tokenizer.enter(TokenType::BlockQuoteWhitespace); + tokenizer.enter(Token::BlockQuoteWhitespace); tokenizer.consume(code); - tokenizer.exit(TokenType::BlockQuoteWhitespace); - tokenizer.exit(TokenType::BlockQuotePrefix); + tokenizer.exit(Token::BlockQuoteWhitespace); + tokenizer.exit(Token::BlockQuotePrefix); (State::Ok, None) } _ => { - tokenizer.exit(TokenType::BlockQuotePrefix); + tokenizer.exit(Token::BlockQuotePrefix); (State::Ok, Some(vec![code])) } } } /// End of a block quote. -pub fn end() -> Vec<TokenType> { - vec![TokenType::BlockQuote] +pub fn end() -> Vec<Token> { + vec![Token::BlockQuote] } |