aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-13 19:03:03 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-13 19:03:03 +0200
commitcdf9f97c34734e82431bbc54d3383f7ac6ac328e (patch)
tree70cd2db6d2c7b3a630b08e9f1062fd5a8fe64a44
parentc790a943ab4cbb5eefa8704f017eb3cf070bf860 (diff)
downloadmarkdown-rs-cdf9f97c34734e82431bbc54d3383f7ac6ac328e.tar.gz
markdown-rs-cdf9f97c34734e82431bbc54d3383f7ac6ac328e.tar.bz2
markdown-rs-cdf9f97c34734e82431bbc54d3383f7ac6ac328e.zip
Remove some unused code
-rw-r--r--src/construct/heading_atx.rs25
-rw-r--r--src/construct/label_end.rs17
-rw-r--r--src/construct/partial_space_or_tab.rs2
3 files changed, 19 insertions, 25 deletions
diff --git a/src/construct/heading_atx.rs b/src/construct/heading_atx.rs
index c867117..ca100c8 100644
--- a/src/construct/heading_atx.rs
+++ b/src/construct/heading_atx.rs
@@ -127,20 +127,17 @@ pub fn sequence_open(tokenizer: &mut Tokenizer) -> State {
tokenizer.tokenize_state.size += 1;
tokenizer.consume();
State::Next(StateName::HeadingAtxSequenceOpen)
- } else if tokenizer.tokenize_state.size > 0 {
- if matches!(tokenizer.current, None | Some(b'\n')) {
- tokenizer.tokenize_state.size = 0;
- tokenizer.exit(Name::HeadingAtxSequence);
- State::Retry(StateName::HeadingAtxAtBreak)
- } else if matches!(tokenizer.current, Some(b'\t' | b' ')) {
- tokenizer.tokenize_state.size = 0;
- tokenizer.exit(Name::HeadingAtxSequence);
- tokenizer.attempt(State::Next(StateName::HeadingAtxAtBreak), State::Nok);
- State::Retry(space_or_tab(tokenizer))
- } else {
- tokenizer.tokenize_state.size = 0;
- State::Nok
- }
+ }
+ // Always at least one `#`.
+ else if matches!(tokenizer.current, None | Some(b'\n')) {
+ tokenizer.tokenize_state.size = 0;
+ tokenizer.exit(Name::HeadingAtxSequence);
+ State::Retry(StateName::HeadingAtxAtBreak)
+ } else if matches!(tokenizer.current, Some(b'\t' | b' ')) {
+ tokenizer.tokenize_state.size = 0;
+ tokenizer.exit(Name::HeadingAtxSequence);
+ tokenizer.attempt(State::Next(StateName::HeadingAtxAtBreak), State::Nok);
+ State::Retry(space_or_tab(tokenizer))
} else {
tokenizer.tokenize_state.size = 0;
State::Nok
diff --git a/src/construct/label_end.rs b/src/construct/label_end.rs
index ca71245..d48f0c5 100644
--- a/src/construct/label_end.rs
+++ b/src/construct/label_end.rs
@@ -624,16 +624,13 @@ pub fn reference_full_after(tokenizer: &mut Tokenizer) -> State {
/// ^
/// ```
pub fn reference_collapsed(tokenizer: &mut Tokenizer) -> State {
- match tokenizer.current {
- Some(b'[') => {
- tokenizer.enter(Name::Reference);
- tokenizer.enter(Name::ReferenceMarker);
- tokenizer.consume();
- tokenizer.exit(Name::ReferenceMarker);
- State::Next(StateName::LabelEndReferenceCollapsedOpen)
- }
- _ => State::Nok,
- }
+ // We only attempt a collapsed label if there’s a `[`.
+ debug_assert_eq!(tokenizer.current, Some(b'['), "expected opening bracket");
+ tokenizer.enter(Name::Reference);
+ tokenizer.enter(Name::ReferenceMarker);
+ tokenizer.consume();
+ tokenizer.exit(Name::ReferenceMarker);
+ State::Next(StateName::LabelEndReferenceCollapsedOpen)
}
/// In reference (collapsed), at `]`.
diff --git a/src/construct/partial_space_or_tab.rs b/src/construct/partial_space_or_tab.rs
index 198dae2..6c5c0ca 100644
--- a/src/construct/partial_space_or_tab.rs
+++ b/src/construct/partial_space_or_tab.rs
@@ -96,7 +96,7 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
if tokenizer.tokenize_state.space_or_tab_connect {
let index = tokenizer.events.len() - 1;
link(&mut tokenizer.events, index);
- } else if tokenizer.tokenize_state.space_or_tab_content.is_some() {
+ } else {
tokenizer.tokenize_state.space_or_tab_connect = true;
}