diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-08-01 10:17:25 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-08-01 10:17:25 +0200 |
commit | 82221ba13d2a4ccd119f280aaa3cea9ca2c8fdaf (patch) | |
tree | 5a9fe3ad27ab001e613d6e50c1dd67041862ce3a /src/construct/code_text.rs | |
parent | 0eeff9148e327183e532752f46421a75506dd7a6 (diff) | |
download | markdown-rs-82221ba13d2a4ccd119f280aaa3cea9ca2c8fdaf.tar.gz markdown-rs-82221ba13d2a4ccd119f280aaa3cea9ca2c8fdaf.tar.bz2 markdown-rs-82221ba13d2a4ccd119f280aaa3cea9ca2c8fdaf.zip |
Refactor some states
Diffstat (limited to 'src/construct/code_text.rs')
-rw-r--r-- | src/construct/code_text.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/construct/code_text.rs b/src/construct/code_text.rs index d70fbc2..3f9e5e5 100644 --- a/src/construct/code_text.rs +++ b/src/construct/code_text.rs @@ -184,18 +184,19 @@ fn sequence_close(tokenizer: &mut Tokenizer, size_open: usize, size: usize) -> S tokenizer.consume(); State::Fn(Box::new(move |t| sequence_close(t, size_open, size + 1))) } - _ if size_open == size => { - tokenizer.exit(Token::CodeTextSequence); - tokenizer.exit(Token::CodeText); - State::Ok - } _ => { - let index = tokenizer.events.len(); - tokenizer.exit(Token::CodeTextSequence); - // Change the token type. - tokenizer.events[index - 1].token_type = Token::CodeTextData; - tokenizer.events[index].token_type = Token::CodeTextData; - between(tokenizer, size_open) + if size_open == size { + tokenizer.exit(Token::CodeTextSequence); + tokenizer.exit(Token::CodeText); + State::Ok + } else { + let index = tokenizer.events.len(); + tokenizer.exit(Token::CodeTextSequence); + // More or less accents: mark as data. + tokenizer.events[index - 1].token_type = Token::CodeTextData; + tokenizer.events[index].token_type = Token::CodeTextData; + between(tokenizer, size_open) + } } } } |