aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/thematic_break.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-11 13:45:24 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-11 13:45:24 +0200
commit6eb2f644057f371841fe25330a57ee185f91c7af (patch)
tree7b4d02586339d1a7f82104b4473d9ac243b3abf9 /src/construct/thematic_break.rs
parent2d35cbfceace81a217cd0fbdae7a8777c7a6465e (diff)
downloadmarkdown-rs-6eb2f644057f371841fe25330a57ee185f91c7af.tar.gz
markdown-rs-6eb2f644057f371841fe25330a57ee185f91c7af.tar.bz2
markdown-rs-6eb2f644057f371841fe25330a57ee185f91c7af.zip
Refactor to move some code to `state.rs`
Diffstat (limited to 'src/construct/thematic_break.rs')
-rw-r--r--src/construct/thematic_break.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/construct/thematic_break.rs b/src/construct/thematic_break.rs
index 288d818..fc71d73 100644
--- a/src/construct/thematic_break.rs
+++ b/src/construct/thematic_break.rs
@@ -50,8 +50,9 @@
use super::partial_space_or_tab::{space_or_tab, space_or_tab_min_max};
use crate::constant::{TAB_SIZE, THEMATIC_BREAK_MARKER_COUNT_MIN};
+use crate::state::{Name, State};
use crate::token::Token;
-use crate::tokenizer::{State, StateName, Tokenizer};
+use crate::tokenizer::Tokenizer;
/// Start of a thematic break.
///
@@ -72,11 +73,7 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
},
);
- tokenizer.attempt(
- name,
- State::Next(StateName::ThematicBreakBefore),
- State::Nok,
- )
+ tokenizer.attempt(name, State::Next(Name::ThematicBreakBefore), State::Nok)
} else {
State::Nok
}
@@ -92,7 +89,7 @@ pub fn before(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
Some(b'*' | b'-' | b'_') => {
tokenizer.tokenize_state.marker = tokenizer.current.unwrap();
- State::Retry(StateName::ThematicBreakAtBreak)
+ State::Retry(Name::ThematicBreakAtBreak)
}
_ => State::Nok,
}
@@ -118,7 +115,7 @@ pub fn at_break(tokenizer: &mut Tokenizer) -> State {
if tokenizer.current.unwrap() == tokenizer.tokenize_state.marker =>
{
tokenizer.enter(Token::ThematicBreakSequence);
- State::Retry(StateName::ThematicBreakSequence)
+ State::Retry(Name::ThematicBreakSequence)
}
_ => {
tokenizer.tokenize_state.marker = 0;
@@ -141,15 +138,15 @@ pub fn sequence(tokenizer: &mut Tokenizer) -> State {
{
tokenizer.consume();
tokenizer.tokenize_state.size += 1;
- State::Next(StateName::ThematicBreakSequence)
+ State::Next(Name::ThematicBreakSequence)
}
_ => {
tokenizer.exit(Token::ThematicBreakSequence);
let name = space_or_tab(tokenizer);
tokenizer.attempt(
name,
- State::Next(StateName::ThematicBreakAtBreak),
- State::Next(StateName::ThematicBreakAtBreak),
+ State::Next(Name::ThematicBreakAtBreak),
+ State::Next(Name::ThematicBreakAtBreak),
)
}
}