aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/partial_space_or_tab_eol.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/construct/partial_space_or_tab_eol.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 'src/construct/partial_space_or_tab_eol.rs')
-rw-r--r--src/construct/partial_space_or_tab_eol.rs28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/construct/partial_space_or_tab_eol.rs b/src/construct/partial_space_or_tab_eol.rs
index 0807a5f..2127fe6 100644
--- a/src/construct/partial_space_or_tab_eol.rs
+++ b/src/construct/partial_space_or_tab_eol.rs
@@ -45,7 +45,12 @@ pub fn space_or_tab_eol_with_options(tokenizer: &mut Tokenizer, options: Options
}
pub fn eol_start(tokenizer: &mut Tokenizer) -> State {
- let name = space_or_tab_with_options(
+ tokenizer.attempt(
+ State::Next(StateName::SpaceOrTabEolAfterFirst),
+ State::Next(StateName::SpaceOrTabEolAtEol),
+ );
+
+ State::Retry(space_or_tab_with_options(
tokenizer,
SpaceOrTabOptions {
kind: Name::SpaceOrTab,
@@ -57,13 +62,7 @@ pub fn eol_start(tokenizer: &mut Tokenizer) -> State {
.clone(),
connect: tokenizer.tokenize_state.space_or_tab_eol_connect,
},
- );
-
- tokenizer.attempt(
- name,
- State::Next(StateName::SpaceOrTabEolAfterFirst),
- State::Next(StateName::SpaceOrTabEolAtEol),
- )
+ ))
}
pub fn eol_after_first(tokenizer: &mut Tokenizer) -> State {
@@ -133,7 +132,11 @@ pub fn eol_at_eol(tokenizer: &mut Tokenizer) -> State {
/// ```
#[allow(clippy::needless_pass_by_value)]
pub fn eol_after_eol(tokenizer: &mut Tokenizer) -> State {
- let name = space_or_tab_with_options(
+ tokenizer.attempt(
+ State::Next(StateName::SpaceOrTabEolAfterMore),
+ State::Next(StateName::SpaceOrTabEolAfterMore),
+ );
+ State::Retry(space_or_tab_with_options(
tokenizer,
SpaceOrTabOptions {
kind: Name::SpaceOrTab,
@@ -145,12 +148,7 @@ pub fn eol_after_eol(tokenizer: &mut Tokenizer) -> State {
.clone(),
connect: tokenizer.tokenize_state.space_or_tab_eol_connect,
},
- );
- tokenizer.attempt(
- name,
- State::Next(StateName::SpaceOrTabEolAfterMore),
- State::Next(StateName::SpaceOrTabEolAfterMore),
- )
+ ))
}
/// `space_or_tab_eol`: after more (optional) `space_or_tab`.