aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/autolink.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-21 16:06:50 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-21 16:06:50 +0200
commitc6f92eaedf197beafef461ee6c2bd067e7160c49 (patch)
treec919113a51065c5d8126991cde1edf7fd6609e8b /src/construct/autolink.rs
parentbcc4676b84a06af5e38ebaa31f0217cae090be08 (diff)
downloadmarkdown-rs-c6f92eaedf197beafef461ee6c2bd067e7160c49.tar.gz
markdown-rs-c6f92eaedf197beafef461ee6c2bd067e7160c49.tar.bz2
markdown-rs-c6f92eaedf197beafef461ee6c2bd067e7160c49.zip
Refactor to improve a bunch of states
* Improve passing stuff around * Add traits to enums for markers and such * Fix “life time” stuff I didn’t understand
Diffstat (limited to 'src/construct/autolink.rs')
-rw-r--r--src/construct/autolink.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/construct/autolink.rs b/src/construct/autolink.rs
index c9596a6..8376b98 100644
--- a/src/construct/autolink.rs
+++ b/src/construct/autolink.rs
@@ -266,12 +266,11 @@ fn email_label(tokenizer: &mut Tokenizer, code: Code, size: usize) -> StateFnRes
)
}
Code::Char('>') => {
- let tail_index = tokenizer.events.len();
- let head_index = tokenizer.events.len() - 1;
+ let index = tokenizer.events.len();
tokenizer.exit(TokenType::AutolinkProtocol);
// Change the token type.
- tokenizer.events[head_index].token_type = TokenType::AutolinkEmail;
- tokenizer.events[tail_index].token_type = TokenType::AutolinkEmail;
+ tokenizer.events[index - 1].token_type = TokenType::AutolinkEmail;
+ tokenizer.events[index].token_type = TokenType::AutolinkEmail;
end(tokenizer, code)
}
_ => email_value(tokenizer, code, size),