diff options
Diffstat (limited to '')
-rw-r--r-- | src/construct/heading_setext.rs | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/construct/heading_setext.rs b/src/construct/heading_setext.rs index 4e6345a..1f6270a 100644 --- a/src/construct/heading_setext.rs +++ b/src/construct/heading_setext.rs @@ -85,16 +85,20 @@ pub fn start(tokenizer: &mut Tokenizer) -> State { .name == Name::Paragraph) { - tokenizer.attempt(State::Next(StateName::HeadingSetextBefore), State::Nok); - State::Retry(space_or_tab_min_max( - tokenizer, - 0, - if tokenizer.parse_state.constructs.code_indented { - TAB_SIZE - 1 - } else { - usize::MAX - }, - )) + if matches!(tokenizer.current, Some(b'\t' | b' ')) { + tokenizer.attempt(State::Next(StateName::HeadingSetextBefore), State::Nok); + State::Retry(space_or_tab_min_max( + tokenizer, + 0, + if tokenizer.parse_state.constructs.code_indented { + TAB_SIZE - 1 + } else { + usize::MAX + }, + )) + } else { + State::Retry(StateName::HeadingSetextBefore) + } } else { State::Nok } @@ -132,11 +136,13 @@ pub fn inside(tokenizer: &mut Tokenizer) -> State { } else { tokenizer.tokenize_state.marker = 0; tokenizer.exit(Name::HeadingSetextUnderline); - tokenizer.attempt( - State::Next(StateName::HeadingSetextAfter), - State::Next(StateName::HeadingSetextAfter), - ); - State::Retry(space_or_tab(tokenizer)) + + if matches!(tokenizer.current, Some(b'\t' | b' ')) { + tokenizer.attempt(State::Next(StateName::HeadingSetextAfter), State::Nok); + State::Retry(space_or_tab(tokenizer)) + } else { + State::Retry(StateName::HeadingSetextAfter) + } } } |