aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/partial_destination.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_destination.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_destination.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/construct/partial_destination.rs b/src/construct/partial_destination.rs
index 735fb38..5aa0539 100644
--- a/src/construct/partial_destination.rs
+++ b/src/construct/partial_destination.rs
@@ -71,8 +71,9 @@
//! [label_end]: crate::construct::label_end
//! [sanitize_uri]: crate::util::sanitize_uri
+use crate::state::{Name, State};
use crate::token::Token;
-use crate::tokenizer::{ContentType, State, StateName, Tokenizer};
+use crate::tokenizer::{ContentType, Tokenizer};
/// Before a destination.
///
@@ -90,7 +91,7 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
tokenizer.enter(tokenizer.tokenize_state.token_3.clone());
tokenizer.consume();
tokenizer.exit(tokenizer.tokenize_state.token_3.clone());
- State::Next(StateName::DestinationEnclosedBefore)
+ State::Next(Name::DestinationEnclosedBefore)
}
// ASCII control, space, closing paren, but *not* `\0`.
None | Some(0x01..=0x1F | b' ' | b')' | 0x7F) => State::Nok,
@@ -99,7 +100,7 @@ pub fn start(tokenizer: &mut Tokenizer) -> State {
tokenizer.enter(tokenizer.tokenize_state.token_4.clone());
tokenizer.enter(tokenizer.tokenize_state.token_5.clone());
tokenizer.enter_with_content(Token::Data, Some(ContentType::String));
- State::Retry(StateName::DestinationRaw)
+ State::Retry(Name::DestinationRaw)
}
}
}
@@ -121,7 +122,7 @@ pub fn enclosed_before(tokenizer: &mut Tokenizer) -> State {
} else {
tokenizer.enter(tokenizer.tokenize_state.token_5.clone());
tokenizer.enter_with_content(Token::Data, Some(ContentType::String));
- State::Retry(StateName::DestinationEnclosed)
+ State::Retry(Name::DestinationEnclosed)
}
}
@@ -137,15 +138,15 @@ pub fn enclosed(tokenizer: &mut Tokenizer) -> State {
Some(b'>') => {
tokenizer.exit(Token::Data);
tokenizer.exit(tokenizer.tokenize_state.token_5.clone());
- State::Retry(StateName::DestinationEnclosedBefore)
+ State::Retry(Name::DestinationEnclosedBefore)
}
Some(b'\\') => {
tokenizer.consume();
- State::Next(StateName::DestinationEnclosedEscape)
+ State::Next(Name::DestinationEnclosedEscape)
}
_ => {
tokenizer.consume();
- State::Next(StateName::DestinationEnclosed)
+ State::Next(Name::DestinationEnclosed)
}
}
}
@@ -160,9 +161,9 @@ pub fn enclosed_escape(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
Some(b'<' | b'>' | b'\\') => {
tokenizer.consume();
- State::Next(StateName::DestinationEnclosed)
+ State::Next(Name::DestinationEnclosed)
}
- _ => State::Retry(StateName::DestinationEnclosed),
+ _ => State::Retry(Name::DestinationEnclosed),
}
}
@@ -185,7 +186,7 @@ pub fn raw(tokenizer: &mut Tokenizer) -> State {
Some(b'(') if tokenizer.tokenize_state.size < tokenizer.tokenize_state.size_b => {
tokenizer.consume();
tokenizer.tokenize_state.size += 1;
- State::Next(StateName::DestinationRaw)
+ State::Next(Name::DestinationRaw)
}
// ASCII control (but *not* `\0`) and space and `(`.
None | Some(0x01..=0x1F | b' ' | b'(' | 0x7F) => {
@@ -195,15 +196,15 @@ pub fn raw(tokenizer: &mut Tokenizer) -> State {
Some(b')') => {
tokenizer.consume();
tokenizer.tokenize_state.size -= 1;
- State::Next(StateName::DestinationRaw)
+ State::Next(Name::DestinationRaw)
}
Some(b'\\') => {
tokenizer.consume();
- State::Next(StateName::DestinationRawEscape)
+ State::Next(Name::DestinationRawEscape)
}
Some(_) => {
tokenizer.consume();
- State::Next(StateName::DestinationRaw)
+ State::Next(Name::DestinationRaw)
}
}
}
@@ -218,8 +219,8 @@ pub fn raw_escape(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
Some(b'(' | b')' | b'\\') => {
tokenizer.consume();
- State::Next(StateName::DestinationRaw)
+ State::Next(Name::DestinationRaw)
}
- _ => State::Retry(StateName::DestinationRaw),
+ _ => State::Retry(Name::DestinationRaw),
}
}