Skip to content

Commit

Permalink
Merge pull request #15 from jaytaph/more-test-fixes
Browse files Browse the repository at this point in the history
more tests will pass
  • Loading branch information
jaytaph authored Sep 24, 2023
2 parents 8027da2 + 81ff73b commit bff2c38
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
34 changes: 17 additions & 17 deletions src/html5_parser/parser/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,23 @@ mod tests {
assert_eq!(
format!("{}", document),
r#"Document
└─ <html>
└─ <head>
└─ <title>
└─ Hello world
└─ <body>
└─ <p>
└─ This is a paragraph
└─ <!-- This is a comment -->
└─ This is another paragraph
└─ This is a third paragraph
└─ This is a fourth paragraph
└─ This is a fifth paragraph
└─ This is a sixth paragraph
└─ This is a seventh paragraph
└─ This is a eighth paragraph
└─ This is a ninth paragraph
"#
└─ <html>
└─ <head>
└─ <title>
└─ Hello world
└─ <body>
└─ <p>
└─ This is a paragraph
└─ <!-- This is a comment -->
└─ This is another paragraph
└─ This is a third paragraph
└─ This is a fourth paragraph
└─ This is a fifth paragraph
└─ This is a sixth paragraph
└─ This is a seventh paragraph
└─ This is a eighth paragraph
└─ This is a ninth paragraph
"#
);
}
}
16 changes: 8 additions & 8 deletions src/html5_parser/tokenizer/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,16 @@ impl std::fmt::Display for Token {
match self {
Token::DocTypeToken {
name,
force_quirks,
pub_identifier,
sys_identifier,
..
} => {
let mut result = format!("<!DOCTYPE {}", name.clone().unwrap_or("".to_string()));
if *force_quirks {
result.push_str(" FORCE_QUIRKS!");
}
if let Some(pub_id) = pub_identifier {
result.push_str(&format!(" {}", pub_id));
result.push_str(&format!(" PUBLIC \"{}\"", pub_id));
}
if let Some(sys_id) = sys_identifier {
result.push_str(&format!(" {}", sys_id));
result.push_str(&format!(" SYSTEM \"{}\"", sys_id));
}
result.push_str(" />");
write!(f, "{}", result)
Expand Down Expand Up @@ -199,7 +196,10 @@ mod tests {
pub_identifier: Some("foo".to_string()),
sys_identifier: Some("bar".to_string()),
};
assert_eq!(format!("{}", token), "<!DOCTYPE html />");
assert_eq!(
format!("{}", token),
"<!DOCTYPE html PUBLIC \"foo\" SYSTEM \"bar\" />"
);
}

#[test]
Expand Down Expand Up @@ -242,7 +242,7 @@ mod tests {
is_self_closing: true,
attributes: HashMap::new(),
};
assert_eq!(format!("{}", token), "StartTag[<br/>]");
assert_eq!(format!("{}", token), "StartTag[<br />]");
}

#[test]
Expand Down

0 comments on commit bff2c38

Please sign in to comment.