aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/partial_title.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/partial_title.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 '')
-rw-r--r--src/construct/partial_title.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/construct/partial_title.rs b/src/construct/partial_title.rs
index 209240e..11c28bd 100644
--- a/src/construct/partial_title.rs
+++ b/src/construct/partial_title.rs
@@ -31,9 +31,10 @@
//! [label_end]: crate::construct::label_end
use crate::construct::partial_space_or_tab::{space_or_tab_eol_with_options, EolOptions};
+use crate::state::{Name, State};
use crate::subtokenize::link;
use crate::token::Token;
-use crate::tokenizer::{ContentType, State, StateName, Tokenizer};
+use crate::tokenizer::{ContentType, Tokenizer};
/// Before a title.
///
@@ -50,7 +51,7 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
tokenizer.enter(tokenizer.tokenize_state.token_2.clone());
tokenizer.consume();
tokenizer.exit(tokenizer.tokenize_state.token_2.clone());
- State::Next(StateName::TitleBegin)
+ State::Next(Name::TitleBegin)
}
_ => State::Nok,
}
@@ -79,7 +80,7 @@ pub fn begin(tokenizer: &mut Tokenizer) -> State {
}
_ => {
tokenizer.enter(tokenizer.tokenize_state.token_3.clone());
- State::Retry(StateName::TitleAtBreak)
+ State::Retry(Name::TitleAtBreak)
}
}
}
@@ -108,15 +109,15 @@ pub fn at_break(tokenizer: &mut Tokenizer) -> State {
tokenizer.attempt(
name,
- State::Next(StateName::TitleAfterEol),
- State::Next(StateName::TitleAtBlankLine),
+ State::Next(Name::TitleAfterEol),
+ State::Next(Name::TitleAtBlankLine),
)
}
Some(b'"' | b'\'' | b')')
if tokenizer.current.unwrap() == tokenizer.tokenize_state.marker =>
{
tokenizer.exit(tokenizer.tokenize_state.token_3.clone());
- State::Retry(StateName::TitleBegin)
+ State::Retry(Name::TitleBegin)
}
Some(_) => {
tokenizer.enter_with_content(Token::Data, Some(ContentType::String));
@@ -128,7 +129,7 @@ pub fn at_break(tokenizer: &mut Tokenizer) -> State {
tokenizer.tokenize_state.connect = true;
}
- State::Retry(StateName::TitleInside)
+ State::Retry(Name::TitleInside)
}
}
}
@@ -142,7 +143,7 @@ pub fn at_break(tokenizer: &mut Tokenizer) -> State {
/// ```
pub fn after_eol(tokenizer: &mut Tokenizer) -> State {
tokenizer.tokenize_state.connect = true;
- State::Retry(StateName::TitleAtBreak)
+ State::Retry(Name::TitleAtBreak)
}
/// In a title, at a blank line.
@@ -169,20 +170,20 @@ pub fn inside(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
None | Some(b'\n') => {
tokenizer.exit(Token::Data);
- State::Retry(StateName::TitleAtBreak)
+ State::Retry(Name::TitleAtBreak)
}
Some(b'"' | b'\'' | b')')
if tokenizer.current.unwrap() == tokenizer.tokenize_state.marker =>
{
tokenizer.exit(Token::Data);
- State::Retry(StateName::TitleAtBreak)
+ State::Retry(Name::TitleAtBreak)
}
Some(byte) => {
tokenizer.consume();
State::Next(if matches!(byte, b'\\') {
- StateName::TitleEscape
+ Name::TitleEscape
} else {
- StateName::TitleInside
+ Name::TitleInside
})
}
}
@@ -198,8 +199,8 @@ pub fn escape(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
Some(b'"' | b'\'' | b')') => {
tokenizer.consume();
- State::Next(StateName::TitleInside)
+ State::Next(Name::TitleInside)
}
- _ => State::Retry(StateName::TitleInside),
+ _ => State::Retry(Name::TitleInside),
}
}