diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 15:33:15 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 15:33:15 +0200 |
commit | 7895cdf9f4e02b20302dd17dddcef32e6bc42c31 (patch) | |
tree | 1caba8f784e3cd3675c2ddeaa7111f4218463372 /src | |
parent | afe75b0508cedba1df5c9701a22e5732c7d0d00e (diff) | |
download | markdown-rs-7895cdf9f4e02b20302dd17dddcef32e6bc42c31.tar.gz markdown-rs-7895cdf9f4e02b20302dd17dddcef32e6bc42c31.tar.bz2 markdown-rs-7895cdf9f4e02b20302dd17dddcef32e6bc42c31.zip |
Refactor to improve coverage of titles
Diffstat (limited to 'src')
-rw-r--r-- | src/construct/partial_title.rs | 16 | ||||
-rw-r--r-- | src/state.rs | 4 |
2 files changed, 8 insertions, 12 deletions
diff --git a/src/construct/partial_title.rs b/src/construct/partial_title.rs index a878be3..a12834f 100644 --- a/src/construct/partial_title.rs +++ b/src/construct/partial_title.rs @@ -99,7 +99,7 @@ pub fn at_break(tokenizer: &mut Tokenizer) -> State { } else if byte == b'\n' { tokenizer.attempt( State::Next(StateName::TitleAfterEol), - State::Next(StateName::TitleAtBlankLine), + State::Next(StateName::TitleNok), ); State::Retry(space_or_tab_eol_with_options( tokenizer, @@ -128,9 +128,7 @@ pub fn at_break(tokenizer: &mut Tokenizer) -> State { State::Retry(StateName::TitleInside) } } else { - tokenizer.tokenize_state.marker = 0; - tokenizer.tokenize_state.connect = false; - State::Nok + State::Retry(StateName::TitleNok) } } @@ -146,15 +144,13 @@ pub fn after_eol(tokenizer: &mut Tokenizer) -> State { State::Retry(StateName::TitleAtBreak) } -/// In title, at blank line. +/// In title, at something that isn’t allowed. /// /// ```markdown -/// | "a␊ -/// > | ␊ -/// ^ -/// | b" +/// > | "a +/// ^ /// ``` -pub fn at_blank_line(tokenizer: &mut Tokenizer) -> State { +pub fn nok(tokenizer: &mut Tokenizer) -> State { tokenizer.tokenize_state.marker = 0; tokenizer.tokenize_state.connect = false; State::Nok diff --git a/src/state.rs b/src/state.rs index 615188e..8dd2ae7 100644 --- a/src/state.rs +++ b/src/state.rs @@ -463,9 +463,9 @@ pub enum Name { TitleBegin, TitleAfterEol, TitleAtBreak, - TitleAtBlankLine, TitleEscape, TitleInside, + TitleNok, } #[allow(clippy::too_many_lines)] @@ -962,9 +962,9 @@ pub fn call(tokenizer: &mut Tokenizer, name: Name) -> State { Name::TitleBegin => construct::partial_title::begin, Name::TitleAfterEol => construct::partial_title::after_eol, Name::TitleAtBreak => construct::partial_title::at_break, - Name::TitleAtBlankLine => construct::partial_title::at_blank_line, Name::TitleEscape => construct::partial_title::escape, Name::TitleInside => construct::partial_title::inside, + Name::TitleNok => construct::partial_title::nok, }; func(tokenizer) |