aboutsummaryrefslogtreecommitdiff
path: root/src/emitter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/emitter.rs')
-rw-r--r--src/emitter.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/emitter.rs b/src/emitter.rs
index db3da78..69baec2 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -153,6 +153,11 @@ pub trait Emitter<O> {
/// If there is no current attribute, this method may panic.
fn push_attribute_value(&mut self, s: &str);
+ /// Assuming the _current token_ is a doctype, set its name to the empty string.
+ ///
+ /// If the current token is not a doctype, this method may panic.
+ fn init_doctype_name(&mut self, offset: O) {}
+
/// Assuming the _current token_ is a doctype, set its "public identifier" to the empty string.
///
/// If the current token is not a doctype, this method may panic.
@@ -411,15 +416,26 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
}
}
+ fn init_doctype_name(&mut self, offset: O) {
+ let Some(Token::Doctype(doctype)) = &mut self.current_token else {
+ debug_assert!(false);
+ return;
+ };
+ doctype.name = Some("".into());
+ }
+
fn push_doctype_name(&mut self, s: &str) {
match self.current_token {
- Some(Token::Doctype(ref mut doctype)) => doctype.name.push_str(s),
+ Some(Token::Doctype(Doctype {
+ name: Some(ref mut name),
+ ..
+ })) => name.push_str(s),
_ => debug_assert!(false),
}
}
fn init_doctype(&mut self, offset: O) {
self.current_token = Some(Token::Doctype(Doctype {
- name: String::new(),
+ name: None,
force_quirks: false,
public_id: None,
system_id: None,
@@ -601,7 +617,7 @@ pub struct Doctype<O> {
/// The doctype's name. Uppercase ASCII characters (A-Z) have been
/// converted to lowercase. For HTML documents this should be "html".
- pub name: String,
+ pub name: Option<String>,
/// The doctype's public identifier.
pub public_id: Option<String>,