aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/thematic_break.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-11 14:53:42 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-11 14:53:42 +0200
commitd87dc75500a2e73d9521135054b42c18e6eae987 (patch)
tree4bc3f4a72894db3ec5ed4069841c6be5be69713d /src/construct/thematic_break.rs
parent6eb2f644057f371841fe25330a57ee185f91c7af (diff)
downloadmarkdown-rs-d87dc75500a2e73d9521135054b42c18e6eae987.tar.gz
markdown-rs-d87dc75500a2e73d9521135054b42c18e6eae987.tar.bz2
markdown-rs-d87dc75500a2e73d9521135054b42c18e6eae987.zip
Refactor to move some code to `event.rs`
Diffstat (limited to 'src/construct/thematic_break.rs')
-rw-r--r--src/construct/thematic_break.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/construct/thematic_break.rs b/src/construct/thematic_break.rs
index fc71d73..8e3c4f4 100644
--- a/src/construct/thematic_break.rs
+++ b/src/construct/thematic_break.rs
@@ -50,8 +50,8 @@
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::event::Name;
+use crate::state::{Name as StateName, State};
use crate::tokenizer::Tokenizer;
/// Start of a thematic break.
@@ -62,7 +62,7 @@ use crate::tokenizer::Tokenizer;
/// ```
pub fn start(tokenizer: &mut Tokenizer) -> State {
if tokenizer.parse_state.constructs.thematic_break {
- tokenizer.enter(Token::ThematicBreak);
+ tokenizer.enter(Name::ThematicBreak);
let name = space_or_tab_min_max(
tokenizer,
0,
@@ -73,7 +73,11 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
},
);
- tokenizer.attempt(name, State::Next(Name::ThematicBreakBefore), State::Nok)
+ tokenizer.attempt(
+ name,
+ State::Next(StateName::ThematicBreakBefore),
+ State::Nok,
+ )
} else {
State::Nok
}
@@ -89,7 +93,7 @@ pub fn before(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
Some(b'*' | b'-' | b'_') => {
tokenizer.tokenize_state.marker = tokenizer.current.unwrap();
- State::Retry(Name::ThematicBreakAtBreak)
+ State::Retry(StateName::ThematicBreakAtBreak)
}
_ => State::Nok,
}
@@ -106,7 +110,7 @@ pub fn at_break(tokenizer: &mut Tokenizer) -> State {
None | Some(b'\n') if tokenizer.tokenize_state.size >= THEMATIC_BREAK_MARKER_COUNT_MIN => {
tokenizer.tokenize_state.marker = 0;
tokenizer.tokenize_state.size = 0;
- tokenizer.exit(Token::ThematicBreak);
+ tokenizer.exit(Name::ThematicBreak);
// Feel free to interrupt.
tokenizer.interrupt = false;
State::Ok
@@ -114,8 +118,8 @@ pub fn at_break(tokenizer: &mut Tokenizer) -> State {
Some(b'*' | b'-' | b'_')
if tokenizer.current.unwrap() == tokenizer.tokenize_state.marker =>
{
- tokenizer.enter(Token::ThematicBreakSequence);
- State::Retry(Name::ThematicBreakSequence)
+ tokenizer.enter(Name::ThematicBreakSequence);
+ State::Retry(StateName::ThematicBreakSequence)
}
_ => {
tokenizer.tokenize_state.marker = 0;
@@ -138,15 +142,15 @@ pub fn sequence(tokenizer: &mut Tokenizer) -> State {
{
tokenizer.consume();
tokenizer.tokenize_state.size += 1;
- State::Next(Name::ThematicBreakSequence)
+ State::Next(StateName::ThematicBreakSequence)
}
_ => {
- tokenizer.exit(Token::ThematicBreakSequence);
+ tokenizer.exit(Name::ThematicBreakSequence);
let name = space_or_tab(tokenizer);
tokenizer.attempt(
name,
- State::Next(Name::ThematicBreakAtBreak),
- State::Next(Name::ThematicBreakAtBreak),
+ State::Next(StateName::ThematicBreakAtBreak),
+ State::Next(StateName::ThematicBreakAtBreak),
)
}
}