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/thematic_break.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/thematic_break.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/construct/thematic_break.rs b/src/construct/thematic_break.rs index 28aca34..4d92f8d 100644 --- a/src/construct/thematic_break.rs +++ b/src/construct/thematic_break.rs @@ -35,8 +35,8 @@ //! //! ## Tokens //! -//! * [`ThematicBreak`][TokenType::ThematicBreak] -//! * [`ThematicBreakSequence`][TokenType::ThematicBreakSequence] +//! * [`ThematicBreak`][Token::ThematicBreak] +//! * [`ThematicBreakSequence`][Token::ThematicBreakSequence] //! //! ## References //! @@ -51,7 +51,8 @@ use super::partial_space_or_tab::{space_or_tab, space_or_tab_min_max}; use crate::constant::{TAB_SIZE, THEMATIC_BREAK_MARKER_COUNT_MIN}; -use crate::tokenizer::{Code, State, StateFnResult, TokenType, Tokenizer}; +use crate::token::Token; +use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; /// Type of thematic break. #[derive(Debug, PartialEq)] @@ -134,7 +135,7 @@ struct Info { /// |*** /// ``` pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { - tokenizer.enter(TokenType::ThematicBreak); + tokenizer.enter(Token::ThematicBreak); // To do: allow arbitrary when code (indented) is turned off. tokenizer.go(space_or_tab_min_max(0, TAB_SIZE - 1), before)(tokenizer, code) } @@ -170,13 +171,13 @@ fn at_break(tokenizer: &mut Tokenizer, code: Code, info: Info) -> StateFnResult Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') if info.size >= THEMATIC_BREAK_MARKER_COUNT_MIN => { - tokenizer.exit(TokenType::ThematicBreak); + tokenizer.exit(Token::ThematicBreak); // Feel free to interrupt. tokenizer.interrupt = false; (State::Ok, Some(vec![code])) } Code::Char(char) if char == info.kind.as_char() => { - tokenizer.enter(TokenType::ThematicBreakSequence); + tokenizer.enter(Token::ThematicBreakSequence); sequence(tokenizer, code, info) } _ => (State::Nok, None), @@ -198,7 +199,7 @@ fn sequence(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnRes (State::Fn(Box::new(|t, c| sequence(t, c, info))), None) } _ => { - tokenizer.exit(TokenType::ThematicBreakSequence); + tokenizer.exit(Token::ThematicBreakSequence); tokenizer.attempt_opt(space_or_tab(), |t, c| at_break(t, c, info))(tokenizer, code) } } |