diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-08-11 17:26:17 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-08-11 17:26:17 +0200 |
commit | 0d9c4611922535533746d1a86f10ef4e701c950e (patch) | |
tree | dd776161db75ba264b67830635b736ca5dd5c314 /src/construct/code_indented.rs | |
parent | 90969231bfcdfcd09bae646abba17d832b633376 (diff) | |
download | markdown-rs-0d9c4611922535533746d1a86f10ef4e701c950e.tar.gz markdown-rs-0d9c4611922535533746d1a86f10ef4e701c950e.tar.bz2 markdown-rs-0d9c4611922535533746d1a86f10ef4e701c950e.zip |
Refactor attempts to remove unneeded state name
Diffstat (limited to '')
-rw-r--r-- | src/construct/code_indented.rs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/construct/code_indented.rs b/src/construct/code_indented.rs index 598d2b0..2ab117e 100644 --- a/src/construct/code_indented.rs +++ b/src/construct/code_indented.rs @@ -65,12 +65,8 @@ pub fn start(tokenizer: &mut Tokenizer) -> State { // Do not interrupt paragraphs. if !tokenizer.interrupt && tokenizer.parse_state.constructs.code_indented { tokenizer.enter(Name::CodeIndented); - let name = space_or_tab_min_max(tokenizer, TAB_SIZE, TAB_SIZE); - tokenizer.attempt( - name, - State::Next(StateName::CodeIndentedAtBreak), - State::Nok, - ) + tokenizer.attempt(State::Next(StateName::CodeIndentedAtBreak), State::Nok); + State::Retry(space_or_tab_min_max(tokenizer, TAB_SIZE, TAB_SIZE)) } else { State::Nok } @@ -85,11 +81,13 @@ pub fn start(tokenizer: &mut Tokenizer) -> State { pub fn at_break(tokenizer: &mut Tokenizer) -> State { match tokenizer.current { None => State::Retry(StateName::CodeIndentedAfter), - Some(b'\n') => tokenizer.attempt( - StateName::CodeIndentedFurtherStart, - State::Next(StateName::CodeIndentedAtBreak), - State::Next(StateName::CodeIndentedAfter), - ), + Some(b'\n') => { + tokenizer.attempt( + State::Next(StateName::CodeIndentedAtBreak), + State::Next(StateName::CodeIndentedAfter), + ); + State::Retry(StateName::CodeIndentedFurtherStart) + } _ => { tokenizer.enter(Name::CodeFlowChunk); State::Retry(StateName::CodeIndentedInside) @@ -145,12 +143,11 @@ pub fn further_start(tokenizer: &mut Tokenizer) -> State { State::Next(StateName::CodeIndentedFurtherStart) } _ if !tokenizer.lazy => { - let name = space_or_tab_min_max(tokenizer, TAB_SIZE, TAB_SIZE); tokenizer.attempt( - name, State::Next(StateName::CodeIndentedFurtherEnd), State::Next(StateName::CodeIndentedFurtherBegin), - ) + ); + State::Retry(space_or_tab_min_max(tokenizer, TAB_SIZE, TAB_SIZE)) } _ => State::Nok, } @@ -175,12 +172,11 @@ pub fn further_end(_tokenizer: &mut Tokenizer) -> State { /// ^ /// ``` pub fn further_begin(tokenizer: &mut Tokenizer) -> State { - let name = space_or_tab(tokenizer); tokenizer.attempt( - name, State::Next(StateName::CodeIndentedFurtherAfter), State::Next(StateName::CodeIndentedFurtherAfter), - ) + ); + State::Retry(space_or_tab(tokenizer)) } /// After whitespace, not indented enough. |