aboutsummaryrefslogtreecommitdiffstats
path: root/src/content/string.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/content/string.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/content/string.rs')
-rw-r--r--src/content/string.rs25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/content/string.rs b/src/content/string.rs
index 5dfceb0..927f582 100644
--- a/src/content/string.rs
+++ b/src/content/string.rs
@@ -13,7 +13,8 @@
//! [text]: crate::content::text
use crate::construct::partial_whitespace::resolve_whitespace;
-use crate::tokenizer::{State, StateName, Tokenizer};
+use crate::state::{Name, State};
+use crate::tokenizer::Tokenizer;
const MARKERS: [u8; 2] = [b'&', b'\\'];
@@ -21,7 +22,7 @@ const MARKERS: [u8; 2] = [b'&', b'\\'];
pub fn start(tokenizer: &mut Tokenizer) -> State {
tokenizer.register_resolver("whitespace".to_string(), Box::new(resolve));
tokenizer.tokenize_state.markers = &MARKERS;
- State::Retry(StateName::StringBefore)
+ State::Retry(Name::StringBefore)
}
/// Before string.
@@ -29,26 +30,22 @@ pub fn before(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
None => State::Ok,
Some(b'&') => tokenizer.attempt(
- StateName::CharacterReferenceStart,
- State::Next(StateName::StringBefore),
- State::Next(StateName::StringBeforeData),
+ Name::CharacterReferenceStart,
+ State::Next(Name::StringBefore),
+ State::Next(Name::StringBeforeData),
),
Some(b'\\') => tokenizer.attempt(
- StateName::CharacterEscapeStart,
- State::Next(StateName::StringBefore),
- State::Next(StateName::StringBeforeData),
+ Name::CharacterEscapeStart,
+ State::Next(Name::StringBefore),
+ State::Next(Name::StringBeforeData),
),
- _ => State::Retry(StateName::StringBeforeData),
+ _ => State::Retry(Name::StringBeforeData),
}
}
/// At data.
pub fn before_data(tokenizer: &mut Tokenizer) -> State {
- tokenizer.attempt(
- StateName::DataStart,
- State::Next(StateName::StringBefore),
- State::Nok,
- )
+ tokenizer.attempt(Name::DataStart, State::Next(Name::StringBefore), State::Nok)
}
/// Resolve whitespace.