aboutsummaryrefslogtreecommitdiff
path: root/src/emitter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/emitter.rs')
-rw-r--r--src/emitter.rs35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/emitter.rs b/src/emitter.rs
index a5ecd55..dee0aa0 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -156,13 +156,6 @@ pub trait Emitter<O> {
///
/// If the current token is not a doctype, this method may panic.
fn push_doctype_system_id(&mut self, s: &str);
-
- /// Returns true if there is an _adjusted current node_ and it is not an element in the HTML namespace.
- ///
- /// See the third list item under [Markup declaration open state].
- ///
- /// [Markup declaration open state]: https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state
- fn adjusted_current_node_present_and_not_in_html_namespace(&mut self) -> bool;
}
/// The DefaultEmitter is not exposed in the public API because:
@@ -172,26 +165,12 @@ pub trait Emitter<O> {
///
#[cfg_attr(not(feature = "integration-tests"), doc = "```ignore")]
#[cfg_attr(feature = "integration-tests", doc = "```")]
-/// # use html5tokenizer::{DefaultEmitter, Tokenizer, Token};
+/// # use html5tokenizer::{DefaultEmitter, Event, Tokenizer, Token};
/// let emitter = DefaultEmitter::default();
/// let html = "<script><b>";
/// let mut tokens = Tokenizer::new(html, emitter).flatten();
-/// assert!(matches!(tokens.next().unwrap(), Token::StartTag(tag) if tag.name == "script"));
-/// assert!(matches!(tokens.next().unwrap(), Token::StartTag(tag) if tag.name == "b"));
-/// ```
-///
-/// * The DefaultEmitter implements [`Emitter::adjusted_current_node_present_and_not_in_html_namespace`]
-/// by returning false, which results in all CDATA sections being tokenized as bogus comments.
-///
-#[cfg_attr(not(feature = "integration-tests"), doc = "```ignore")]
-#[cfg_attr(feature = "integration-tests", doc = "```")]
-/// # use html5tokenizer::{DefaultEmitter, Tokenizer, Token};
-/// let emitter = DefaultEmitter::default();
-/// let html = "<svg><![CDATA[I love SVG]]>";
-/// let mut tokens = Tokenizer::new(html, emitter).flatten();
-/// assert!(matches!(tokens.next().unwrap(), Token::StartTag(tag) if tag.name == "svg"));
-/// assert!(matches!(tokens.next().unwrap(), Token::Error {..}));
-/// assert!(matches!(tokens.next().unwrap(), Token::Comment(_bogus_comment)));
+/// assert!(matches!(tokens.next().unwrap(), Event::Token(Token::StartTag(tag)) if tag.name == "script"));
+/// assert!(matches!(tokens.next().unwrap(), Event::Token(Token::StartTag(tag)) if tag.name == "b"));
/// ```
///
/// [`Tokenizer::set_state`]: crate::Tokenizer::set_state
@@ -467,10 +446,6 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
debug_assert!(false);
}
}
-
- fn adjusted_current_node_present_and_not_in_html_namespace(&mut self) -> bool {
- false
- }
}
/// An HTML start tag, such as `<p>` or `<a>`.
@@ -613,7 +588,7 @@ pub enum Token<O> {
#[cfg(test)]
mod tests {
use super::{DefaultEmitter, Token};
- use crate::{attr::AttrValueSyntax, Tokenizer};
+ use crate::{attr::AttrValueSyntax, Event, Tokenizer};
#[test]
fn test_attribute_value_syntax() {
@@ -622,7 +597,7 @@ mod tests {
DefaultEmitter::default(),
)
.flatten();
- let Token::StartTag(start_tag) = tokenizer.next().unwrap() else {
+ let Event::Token(Token::StartTag(start_tag)) = tokenizer.next().unwrap() else {
panic!("expected start tag");
};
assert_eq!(