diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-08-09 14:04:27 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-08-09 14:04:27 +0200 |
commit | 8f8d72a749a39845fd03ae259533abe73dc7dcdf (patch) | |
tree | ebc54d404f5a5e7e406f6323131dae1ed7a79c50 /src/content/document.rs | |
parent | fafcfd55e5f7ea8b87cab4bbf979730d81749402 (diff) | |
download | markdown-rs-8f8d72a749a39845fd03ae259533abe73dc7dcdf.tar.gz markdown-rs-8f8d72a749a39845fd03ae259533abe73dc7dcdf.tar.bz2 markdown-rs-8f8d72a749a39845fd03ae259533abe73dc7dcdf.zip |
Add support for passing `ok`, `nok` as separate states to attempts
Diffstat (limited to 'src/content/document.rs')
-rw-r--r-- | src/content/document.rs | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/content/document.rs b/src/content/document.rs index 7a43d48..d02021a 100644 --- a/src/content/document.rs +++ b/src/content/document.rs @@ -106,7 +106,11 @@ pub fn start(tokenizer: &mut Tokenizer) -> State { tokenizer.parse_state, ))); tokenizer.tokenize_state.document_child_state = Some(State::Fn(StateName::FlowStart)); - tokenizer.attempt_opt(StateName::BomStart, StateName::DocumentLineStart) + tokenizer.attempt( + StateName::BomStart, + State::Fn(StateName::DocumentLineStart), + State::Fn(StateName::DocumentLineStart), + ) } /// Start of a line. @@ -146,13 +150,11 @@ pub fn container_existing_before(tokenizer: &mut Tokenizer) -> State { }; tokenizer.container = Some(container); - tokenizer.attempt(state_name, |ok| { - State::Fn(if ok { - StateName::DocumentContainerExistingAfter - } else { - StateName::DocumentContainerExistingMissing - }) - }) + tokenizer.attempt( + state_name, + State::Fn(StateName::DocumentContainerExistingAfter), + State::Fn(StateName::DocumentContainerExistingMissing), + ) } // Otherwise, check new containers. else { @@ -235,13 +237,11 @@ pub fn container_new_before(tokenizer: &mut Tokenizer) -> State { size: 0, }); - tokenizer.attempt(StateName::BlockQuoteStart, |ok| { - State::Fn(if ok { - StateName::DocumentContainerNewAfter - } else { - StateName::DocumentContainerNewBeforeNotBlockQuote - }) - }) + tokenizer.attempt( + StateName::BlockQuoteStart, + State::Fn(StateName::DocumentContainerNewAfter), + State::Fn(StateName::DocumentContainerNewBeforeNotBlockQuote), + ) } /// To do. @@ -253,13 +253,11 @@ pub fn container_new_before_not_block_quote(tokenizer: &mut Tokenizer) -> State size: 0, }); - tokenizer.attempt(StateName::ListStart, |ok| { - State::Fn(if ok { - StateName::DocumentContainerNewAfter - } else { - StateName::DocumentContainersAfter - }) - }) + tokenizer.attempt( + StateName::ListStart, + State::Fn(StateName::DocumentContainerNewAfter), + State::Fn(StateName::DocumentContainersAfter), + ) } /// After a new container. |