aboutsummaryrefslogtreecommitdiff
path: root/src/emitter.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-03 10:47:44 +0200
committerMartin Fischer <martin@push-f.com>2023-09-03 23:00:05 +0200
commitd56686deab81c8b50207b75a485cf26ec8502383 (patch)
tree47f9466c6643a5851efb10f3422d056598341fab /src/emitter.rs
parent0576e5a9b93f28bd4d2adc224598de319e14f1be (diff)
break!: make Doctype name field optional
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>,