aboutsummaryrefslogtreecommitdiffstats
path: root/src/content/string.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-11 17:26:17 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-11 17:26:17 +0200
commit0d9c4611922535533746d1a86f10ef4e701c950e (patch)
treedd776161db75ba264b67830635b736ca5dd5c314 /src/content/string.rs
parent90969231bfcdfcd09bae646abba17d832b633376 (diff)
downloadmarkdown-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/content/string.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/content/string.rs b/src/content/string.rs
index ce850e7..1eefd30 100644
--- a/src/content/string.rs
+++ b/src/content/string.rs
@@ -30,27 +30,28 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
pub fn before(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
None => State::Ok,
- Some(b'&') => tokenizer.attempt(
- StateName::CharacterReferenceStart,
- State::Next(StateName::StringBefore),
- State::Next(StateName::StringBeforeData),
- ),
- Some(b'\\') => tokenizer.attempt(
- StateName::CharacterEscapeStart,
- State::Next(StateName::StringBefore),
- State::Next(StateName::StringBeforeData),
- ),
+ Some(b'&') => {
+ tokenizer.attempt(
+ State::Next(StateName::StringBefore),
+ State::Next(StateName::StringBeforeData),
+ );
+ State::Retry(StateName::CharacterReferenceStart)
+ }
+ Some(b'\\') => {
+ tokenizer.attempt(
+ State::Next(StateName::StringBefore),
+ State::Next(StateName::StringBeforeData),
+ );
+ State::Retry(StateName::CharacterEscapeStart)
+ }
_ => State::Retry(StateName::StringBeforeData),
}
}
/// At data.
pub fn before_data(tokenizer: &mut Tokenizer) -> State {
- tokenizer.attempt(
- StateName::DataStart,
- State::Next(StateName::StringBefore),
- State::Nok,
- )
+ tokenizer.attempt(State::Next(StateName::StringBefore), State::Nok);
+ State::Retry(StateName::DataStart)
}
/// Resolve whitespace.