aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/html_text.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/construct/html_text.rs')
-rw-r--r--src/construct/html_text.rs95
1 files changed, 47 insertions, 48 deletions
diff --git a/src/construct/html_text.rs b/src/construct/html_text.rs
index 1b15956..b92b9fa 100644
--- a/src/construct/html_text.rs
+++ b/src/construct/html_text.rs
@@ -208,11 +208,10 @@ pub fn comment_start_dash(tokenizer: &mut Tokenizer) -> State {
pub fn comment(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
None => State::Nok,
- Some(b'\n') => tokenizer.attempt(
- StateName::HtmlTextLineEndingBefore,
- State::Next(StateName::HtmlTextComment),
- State::Nok,
- ),
+ Some(b'\n') => {
+ tokenizer.attempt(State::Next(StateName::HtmlTextComment), State::Nok);
+ State::Retry(StateName::HtmlTextLineEndingBefore)
+ }
Some(b'-') => {
tokenizer.consume();
State::Next(StateName::HtmlTextCommentClose)
@@ -271,11 +270,10 @@ pub fn cdata_open_inside(tokenizer: &mut Tokenizer) -> State {
pub fn cdata(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
None => State::Nok,
- Some(b'\n') => tokenizer.attempt(
- StateName::HtmlTextLineEndingBefore,
- State::Next(StateName::HtmlTextCdata),
- State::Nok,
- ),
+ Some(b'\n') => {
+ tokenizer.attempt(State::Next(StateName::HtmlTextCdata), State::Nok);
+ State::Retry(StateName::HtmlTextLineEndingBefore)
+ }
Some(b']') => {
tokenizer.consume();
State::Next(StateName::HtmlTextCdataClose)
@@ -326,11 +324,10 @@ pub fn cdata_end(tokenizer: &mut Tokenizer) -> State {
pub fn declaration(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
None | Some(b'>') => State::Retry(StateName::HtmlTextEnd),
- Some(b'\n') => tokenizer.attempt(
- StateName::HtmlTextLineEndingBefore,
- State::Next(StateName::HtmlTextDeclaration),
- State::Nok,
- ),
+ Some(b'\n') => {
+ tokenizer.attempt(State::Next(StateName::HtmlTextDeclaration), State::Nok);
+ State::Retry(StateName::HtmlTextLineEndingBefore)
+ }
_ => {
tokenizer.consume();
State::Next(StateName::HtmlTextDeclaration)
@@ -347,11 +344,10 @@ pub fn declaration(tokenizer: &mut Tokenizer) -> State {
pub fn instruction(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
None => State::Nok,
- Some(b'\n') => tokenizer.attempt(
- StateName::HtmlTextLineEndingBefore,
- State::Next(StateName::HtmlTextInstruction),
- State::Nok,
- ),
+ Some(b'\n') => {
+ tokenizer.attempt(State::Next(StateName::HtmlTextInstruction), State::Nok);
+ State::Retry(StateName::HtmlTextLineEndingBefore)
+ }
Some(b'?') => {
tokenizer.consume();
State::Next(StateName::HtmlTextInstructionClose)
@@ -418,11 +414,10 @@ pub fn tag_close(tokenizer: &mut Tokenizer) -> State {
/// ```
pub fn tag_close_between(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
- Some(b'\n') => tokenizer.attempt(
- StateName::HtmlTextLineEndingBefore,
- State::Next(StateName::HtmlTextTagCloseBetween),
- State::Nok,
- ),
+ Some(b'\n') => {
+ tokenizer.attempt(State::Next(StateName::HtmlTextTagCloseBetween), State::Nok);
+ State::Retry(StateName::HtmlTextLineEndingBefore)
+ }
Some(b'\t' | b' ') => {
tokenizer.consume();
State::Next(StateName::HtmlTextTagCloseBetween)
@@ -457,11 +452,10 @@ pub fn tag_open(tokenizer: &mut Tokenizer) -> State {
/// ```
pub fn tag_open_between(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
- Some(b'\n') => tokenizer.attempt(
- StateName::HtmlTextLineEndingBefore,
- State::Next(StateName::HtmlTextTagOpenBetween),
- State::Nok,
- ),
+ Some(b'\n') => {
+ tokenizer.attempt(State::Next(StateName::HtmlTextTagOpenBetween), State::Nok);
+ State::Retry(StateName::HtmlTextLineEndingBefore)
+ }
Some(b'\t' | b' ') => {
tokenizer.consume();
State::Next(StateName::HtmlTextTagOpenBetween)
@@ -505,11 +499,13 @@ pub fn tag_open_attribute_name(tokenizer: &mut Tokenizer) -> State {
/// ```
pub fn tag_open_attribute_name_after(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
- Some(b'\n') => tokenizer.attempt(
- StateName::HtmlTextLineEndingBefore,
- State::Next(StateName::HtmlTextTagOpenAttributeNameAfter),
- State::Nok,
- ),
+ Some(b'\n') => {
+ tokenizer.attempt(
+ State::Next(StateName::HtmlTextTagOpenAttributeNameAfter),
+ State::Nok,
+ );
+ State::Retry(StateName::HtmlTextLineEndingBefore)
+ }
Some(b'\t' | b' ') => {
tokenizer.consume();
State::Next(StateName::HtmlTextTagOpenAttributeNameAfter)
@@ -532,11 +528,13 @@ pub fn tag_open_attribute_name_after(tokenizer: &mut Tokenizer) -> State {
pub fn tag_open_attribute_value_before(tokenizer: &mut Tokenizer) -> State {
match tokenizer.current {
None | Some(b'<' | b'=' | b'>' | b'`') => State::Nok,
- Some(b'\n') => tokenizer.attempt(
- StateName::HtmlTextLineEndingBefore,
- State::Next(StateName::HtmlTextTagOpenAttributeValueBefore),
- State::Nok,
- ),
+ Some(b'\n') => {
+ tokenizer.attempt(
+ State::Next(StateName::HtmlTextTagOpenAttributeValueBefore),
+ State::Nok,
+ );
+ State::Retry(StateName::HtmlTextLineEndingBefore)
+ }
Some(b'\t' | b' ') => {
tokenizer.consume();
State::Next(StateName::HtmlTextTagOpenAttributeValueBefore)
@@ -565,11 +563,13 @@ pub fn tag_open_attribute_value_quoted(tokenizer: &mut Tokenizer) -> State {
tokenizer.tokenize_state.marker = 0;
State::Nok
}
- Some(b'\n') => tokenizer.attempt(
- StateName::HtmlTextLineEndingBefore,
- State::Next(StateName::HtmlTextTagOpenAttributeValueQuoted),
- State::Nok,
- ),
+ Some(b'\n') => {
+ tokenizer.attempt(
+ State::Next(StateName::HtmlTextTagOpenAttributeValueQuoted),
+ State::Nok,
+ );
+ State::Retry(StateName::HtmlTextLineEndingBefore)
+ }
Some(b'"' | b'\'') if tokenizer.current.unwrap() == tokenizer.tokenize_state.marker => {
tokenizer.tokenize_state.marker = 0;
tokenizer.consume();
@@ -665,12 +665,11 @@ pub fn line_ending_before(tokenizer: &mut Tokenizer) -> State {
/// ^
/// ```
pub fn line_ending_after(tokenizer: &mut Tokenizer) -> State {
- let name = space_or_tab(tokenizer);
tokenizer.attempt(
- name,
State::Next(StateName::HtmlTextLineEndingAfterPrefix),
State::Next(StateName::HtmlTextLineEndingAfterPrefix),
- )
+ );
+ State::Retry(space_or_tab(tokenizer))
}
/// After a line ending, after indent.