diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-08-12 17:02:01 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-08-12 17:02:01 +0200 |
commit | 6ba11bdaca1721fb4591819604c340d147798f45 (patch) | |
tree | ef602b518043c0a7228e76d9d00bee95a17798d4 /src/construct/code_indented.rs | |
parent | 504729a4a0c8f3e0d8fc9159e0273150b169e184 (diff) | |
download | markdown-rs-6ba11bdaca1721fb4591819604c340d147798f45.tar.gz markdown-rs-6ba11bdaca1721fb4591819604c340d147798f45.tar.bz2 markdown-rs-6ba11bdaca1721fb4591819604c340d147798f45.zip |
Remove `match` statements if clumsy
Diffstat (limited to '')
-rw-r--r-- | src/construct/code_indented.rs | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/src/construct/code_indented.rs b/src/construct/code_indented.rs index 3a82dc4..5805346 100644 --- a/src/construct/code_indented.rs +++ b/src/construct/code_indented.rs @@ -135,33 +135,19 @@ pub fn after(tokenizer: &mut Tokenizer) -> State { /// | bbb /// ``` pub fn further_start(tokenizer: &mut Tokenizer) -> State { - match tokenizer.current { - Some(b'\n') if !tokenizer.lazy => { - tokenizer.enter(Name::LineEnding); - tokenizer.consume(); - tokenizer.exit(Name::LineEnding); - State::Next(StateName::CodeIndentedFurtherStart) - } - _ if !tokenizer.lazy => { - tokenizer.attempt( - State::Next(StateName::CodeIndentedFurtherEnd), - State::Next(StateName::CodeIndentedFurtherBegin), - ); - State::Retry(space_or_tab_min_max(tokenizer, TAB_SIZE, TAB_SIZE)) - } - _ => State::Nok, + if tokenizer.lazy { + return State::Nok; } -} -/// At eol, followed by an indented line. -/// -/// ```markdown -/// > | aaa -/// ^ -/// | bbb -/// ``` -pub fn further_end(_tokenizer: &mut Tokenizer) -> State { - State::Ok + if tokenizer.current == Some(b'\n') { + tokenizer.enter(Name::LineEnding); + tokenizer.consume(); + tokenizer.exit(Name::LineEnding); + State::Next(StateName::CodeIndentedFurtherStart) + } else { + tokenizer.attempt(State::Ok, State::Next(StateName::CodeIndentedFurtherBegin)); + State::Retry(space_or_tab_min_max(tokenizer, TAB_SIZE, TAB_SIZE)) + } } /// At the beginning of a line that is not indented enough. |