diff options
| author | 2022-08-11 17:26:17 +0200 | |
|---|---|---|
| committer | 2022-08-11 17:26:17 +0200 | |
| commit | 0d9c4611922535533746d1a86f10ef4e701c950e (patch) | |
| tree | dd776161db75ba264b67830635b736ca5dd5c314 /src/content/document.rs | |
| parent | 90969231bfcdfcd09bae646abba17d832b633376 (diff) | |
| download | markdown-rs-0d9c4611922535533746d1a86f10ef4e701c950e.tar.gz markdown-rs-0d9c4611922535533746d1a86f10ef4e701c950e.tar.bz2 markdown-rs-0d9c4611922535533746d1a86f10ef4e701c950e.zip  | |
Refactor attempts to remove unneeded state name
Diffstat (limited to 'src/content/document.rs')
| -rw-r--r-- | src/content/document.rs | 26 | 
1 files changed, 15 insertions, 11 deletions
diff --git a/src/content/document.rs b/src/content/document.rs index f2890f3..04f9dc6 100644 --- a/src/content/document.rs +++ b/src/content/document.rs @@ -81,10 +81,11 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {      )));      tokenizer.attempt( -        StateName::BomStart,          State::Next(StateName::DocumentContainerExistingBefore),          State::Next(StateName::DocumentContainerExistingBefore), -    ) +    ); + +    State::Retry(StateName::BomStart)  }  /// Before existing containers. @@ -102,14 +103,17 @@ pub fn container_existing_before(tokenizer: &mut Tokenizer) -> State {          let container = &tokenizer.tokenize_state.document_container_stack              [tokenizer.tokenize_state.document_continued]; +        let name = match container.kind { +            Container::BlockQuote => StateName::BlockQuoteContStart, +            Container::ListItem => StateName::ListContStart, +        }; +          tokenizer.attempt( -            match container.kind { -                Container::BlockQuote => StateName::BlockQuoteContStart, -                Container::ListItem => StateName::ListContStart, -            },              State::Next(StateName::DocumentContainerExistingAfter),              State::Next(StateName::DocumentContainerNewBefore), -        ) +        ); + +        State::Retry(name)      }      // Otherwise, check new containers.      else { @@ -173,10 +177,10 @@ pub fn container_new_before(tokenizer: &mut Tokenizer) -> State {          .swap(tokenizer.tokenize_state.document_continued, tail);      tokenizer.attempt( -        StateName::BlockQuoteStart,          State::Next(StateName::DocumentContainerNewAfter),          State::Next(StateName::DocumentContainerNewBeforeNotBlockQuote), -    ) +    ); +    State::Retry(StateName::BlockQuoteStart)  }  /// Maybe before a new container, but not a block quote. @@ -196,10 +200,10 @@ pub fn container_new_before_not_block_quote(tokenizer: &mut Tokenizer) -> State      };      tokenizer.attempt( -        StateName::ListStart,          State::Next(StateName::DocumentContainerNewAfter),          State::Next(StateName::DocumentContainerNewBeforeNotList), -    ) +    ); +    State::Retry(StateName::ListStart)  }  /// Maybe before a new container, but not a list.  | 
