diff options
Diffstat (limited to 'tests/test_spans.rs')
-rw-r--r-- | tests/test_spans.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_spans.rs b/tests/test_spans.rs index 6bd9378..70bcf6e 100644 --- a/tests/test_spans.rs +++ b/tests/test_spans.rs @@ -167,6 +167,37 @@ fn comment_bogus_data_span() { "###); } +#[test] +fn doctype_span() { + let html = r#"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >"#; + let Token::Doctype(doctype) = tokenizer(html).next().unwrap() else { + panic!("expected doctype"); + }; + let labels = vec![(doctype.span, "")]; + assert_snapshot!(annotate(html, labels), @r###" + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + "###); +} + +#[test] +fn doctype_id_spans() { + let html = r#"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">"#; + let Token::Doctype(doctype) = tokenizer(html).next().unwrap() else { + panic!("expected doctype"); + }; + let labels = vec![ + (doctype.public_id_span().unwrap(), "public id"), + (doctype.system_id_span().unwrap(), "system id"), + ]; + assert_snapshot!(annotate(html, labels), @r###" + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> + ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ system id + │ + public id + "###); +} + fn annotate_errors(html: &'static str) -> String { let mut labels = Vec::new(); for token in tokenizer(html) { |