aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/html_flow.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-09 14:04:27 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-09 14:04:27 +0200
commit8f8d72a749a39845fd03ae259533abe73dc7dcdf (patch)
treeebc54d404f5a5e7e406f6323131dae1ed7a79c50 /src/construct/html_flow.rs
parentfafcfd55e5f7ea8b87cab4bbf979730d81749402 (diff)
downloadmarkdown-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 '')
-rw-r--r--src/construct/html_flow.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/construct/html_flow.rs b/src/construct/html_flow.rs
index 779146c..128fd2e 100644
--- a/src/construct/html_flow.rs
+++ b/src/construct/html_flow.rs
@@ -147,7 +147,7 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
},
);
- tokenizer.go(state_name, StateName::HtmlFlowBefore)
+ tokenizer.attempt(state_name, State::Fn(StateName::HtmlFlowBefore), State::Nok)
} else {
State::Nok
}
@@ -632,13 +632,11 @@ pub fn continuation(tokenizer: &mut Tokenizer) -> State {
|| tokenizer.tokenize_state.marker == COMPLETE =>
{
tokenizer.exit(Token::HtmlFlowData);
- tokenizer.check(StateName::HtmlFlowBlankLineBefore, |ok| {
- State::Fn(if ok {
- StateName::HtmlFlowContinuationAfter
- } else {
- StateName::HtmlFlowContinuationStart
- })
- })
+ tokenizer.check(
+ StateName::HtmlFlowBlankLineBefore,
+ State::Fn(StateName::HtmlFlowContinuationAfter),
+ State::Fn(StateName::HtmlFlowContinuationStart),
+ )
}
// Note: important that this is after the basic/complete case.
None | Some(b'\n') => {
@@ -680,13 +678,11 @@ pub fn continuation(tokenizer: &mut Tokenizer) -> State {
/// | asd
/// ```
pub fn continuation_start(tokenizer: &mut Tokenizer) -> State {
- tokenizer.check(StateName::NonLazyContinuationStart, |ok| {
- State::Fn(if ok {
- StateName::HtmlFlowContinuationStartNonLazy
- } else {
- StateName::HtmlFlowContinuationAfter
- })
- })
+ tokenizer.check(
+ StateName::NonLazyContinuationStart,
+ State::Fn(StateName::HtmlFlowContinuationStartNonLazy),
+ State::Fn(StateName::HtmlFlowContinuationAfter),
+ )
}
/// In continuation, at an eol, before non-lazy content.