diff options
author | Martin Fischer <martin@push-f.com> | 2023-08-16 18:54:35 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2023-08-19 13:41:55 +0200 |
commit | c07334e7bb613774d3535663433c90b6dde86943 (patch) | |
tree | 56907f1e62718d7caa21d6fc05db1b8e66578e65 /src | |
parent | 26cd63394f640920db4ea9402d77cec1358fb098 (diff) |
break!: rename doctype _identifier methods/fields to _id
Just a bit more succinct. And now rustdoc also no longer
cuts off the names of these Emitter methods in its sidebar.
Diffstat (limited to 'src')
-rw-r--r-- | src/emitter.rs | 44 | ||||
-rw-r--r-- | src/machine.rs | 40 |
2 files changed, 41 insertions, 43 deletions
diff --git a/src/emitter.rs b/src/emitter.rs index cf22a44..ffd51f8 100644 --- a/src/emitter.rs +++ b/src/emitter.rs @@ -140,22 +140,22 @@ pub trait Emitter<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. - fn init_doctype_public_identifier(&mut self); + fn init_doctype_public_id(&mut self); /// Assuming the _current token_ is a doctype, set its "system identifier" to the empty string. /// /// If the current token is not a doctype, this method may panic. - fn init_doctype_system_identifier(&mut self); + fn init_doctype_system_id(&mut self); /// Assuming the _current token_ is a doctype, append a string to its "public identifier" to the given string. /// /// If the current token is not a doctype, this method may panic. - fn push_doctype_public_identifier(&mut self, s: &str); + fn push_doctype_public_id(&mut self, s: &str); /// Assuming the _current token_ is a doctype, append a string to its "system identifier" to the given string. /// /// If the current token is not a doctype, this method may panic. - fn push_doctype_system_identifier(&mut self, s: &str); + fn push_doctype_system_id(&mut self, s: &str); } /// The default implementation of [`Emitter`], used to produce tokens. @@ -372,8 +372,8 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> { self.current_token = Some(Token::Doctype(Doctype { name: String::new(), force_quirks: false, - public_identifier: None, - system_identifier: None, + public_id: None, + system_id: None, })); } @@ -403,31 +403,29 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> { let current_attr = self.current_attribute.as_mut().unwrap(); current_attr.1.value.push_str(s); } - fn init_doctype_public_identifier(&mut self) { + fn init_doctype_public_id(&mut self) { if let Some(Token::Doctype(Doctype { - ref mut public_identifier, - .. + ref mut public_id, .. })) = self.current_token { - *public_identifier = Some("".to_owned()); + *public_id = Some("".to_owned()); } else { debug_assert!(false); } } - fn init_doctype_system_identifier(&mut self) { + fn init_doctype_system_id(&mut self) { if let Some(Token::Doctype(Doctype { - ref mut system_identifier, - .. + ref mut system_id, .. })) = self.current_token { - *system_identifier = Some("".to_owned()); + *system_id = Some("".to_owned()); } else { debug_assert!(false); } } - fn push_doctype_public_identifier(&mut self, s: &str) { + fn push_doctype_public_id(&mut self, s: &str) { if let Some(Token::Doctype(Doctype { - public_identifier: Some(ref mut id), + public_id: Some(ref mut id), .. })) = self.current_token { @@ -436,9 +434,9 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> { debug_assert!(false); } } - fn push_doctype_system_identifier(&mut self, s: &str) { + fn push_doctype_system_id(&mut self, s: &str) { if let Some(Token::Doctype(Doctype { - system_identifier: Some(ref mut id), + system_id: Some(ref mut id), .. })) = self.current_token { @@ -514,9 +512,9 @@ impl<O: Offset> Comment<O> { /// A doctype. Some examples: /// /// * `<!DOCTYPE {name}>` -/// * `<!DOCTYPE {name} PUBLIC '{public_identifier}'>` -/// * `<!DOCTYPE {name} SYSTEM '{system_identifier}'>` -/// * `<!DOCTYPE {name} PUBLIC '{public_identifier}' '{system_identifier}'>` +/// * `<!DOCTYPE {name} PUBLIC '{public_id}'>` +/// * `<!DOCTYPE {name} SYSTEM '{system_id}'>` +/// * `<!DOCTYPE {name} PUBLIC '{public_id}' '{system_id}'>` #[derive(Debug, Eq, PartialEq)] pub struct Doctype { /// The ["force quirks"](https://html.spec.whatwg.org/#force-quirks-flag) flag. @@ -526,10 +524,10 @@ pub struct Doctype { pub name: String, /// The doctype's public identifier. - pub public_identifier: Option<String>, + pub public_id: Option<String>, /// The doctype's system identifier. - pub system_identifier: Option<String>, + pub system_id: Option<String>, } /// The token type used by default. You can define your own token type by implementing the diff --git a/src/machine.rs b/src/machine.rs index 4a9034e..0755e20 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -1266,13 +1266,13 @@ where } Some('"') => { slf.emit_error(Error::MissingWhitespaceAfterDoctypePublicKeyword); - slf.emitter.init_doctype_public_identifier(); + slf.emitter.init_doctype_public_id(); slf.state = State::DoctypePublicIdentifierDoubleQuoted; Ok(ControlToken::Continue) } Some('\'') => { slf.emit_error(Error::MissingWhitespaceAfterDoctypePublicKeyword); - slf.emitter.init_doctype_public_identifier(); + slf.emitter.init_doctype_public_id(); slf.state = State::DoctypePublicIdentifierSingleQuoted; Ok(ControlToken::Continue) } @@ -1300,12 +1300,12 @@ where State::BeforeDoctypePublicIdentifier => match slf.read_char()? { Some(whitespace_pat!()) => Ok(ControlToken::Continue), Some('"') => { - slf.emitter.init_doctype_public_identifier(); + slf.emitter.init_doctype_public_id(); slf.state = State::DoctypePublicIdentifierDoubleQuoted; Ok(ControlToken::Continue) } Some('\'') => { - slf.emitter.init_doctype_public_identifier(); + slf.emitter.init_doctype_public_id(); slf.state = State::DoctypePublicIdentifierSingleQuoted; Ok(ControlToken::Continue) } @@ -1337,7 +1337,7 @@ where } Some('\0') => { slf.emit_error(Error::UnexpectedNullCharacter); - slf.emitter.push_doctype_public_identifier("\u{fffd}"); + slf.emitter.push_doctype_public_id("\u{fffd}"); Ok(ControlToken::Continue) } Some('>') => { @@ -1354,7 +1354,7 @@ where Ok(ControlToken::Eof) } Some(x) => { - slf.emitter.push_doctype_public_identifier(ctostr!(x)); + slf.emitter.push_doctype_public_id(ctostr!(x)); Ok(ControlToken::Continue) } }, @@ -1365,7 +1365,7 @@ where } Some('\0') => { slf.emit_error(Error::UnexpectedNullCharacter); - slf.emitter.push_doctype_public_identifier("\u{fffd}"); + slf.emitter.push_doctype_public_id("\u{fffd}"); Ok(ControlToken::Continue) } Some('>') => { @@ -1382,7 +1382,7 @@ where Ok(ControlToken::Eof) } Some(x) => { - slf.emitter.push_doctype_public_identifier(ctostr!(x)); + slf.emitter.push_doctype_public_id(ctostr!(x)); Ok(ControlToken::Continue) } }, @@ -1398,13 +1398,13 @@ where } Some('"') => { slf.emit_error(Error::MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers); - slf.emitter.init_doctype_system_identifier(); + slf.emitter.init_doctype_system_id(); slf.state = State::DoctypeSystemIdentifierDoubleQuoted; Ok(ControlToken::Continue) } Some('\'') => { slf.emit_error(Error::MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers); - slf.emitter.init_doctype_system_identifier(); + slf.emitter.init_doctype_system_id(); slf.state = State::DoctypeSystemIdentifierSingleQuoted; Ok(ControlToken::Continue) } @@ -1430,12 +1430,12 @@ where Ok(ControlToken::Continue) } Some('"') => { - slf.emitter.init_doctype_system_identifier(); + slf.emitter.init_doctype_system_id(); slf.state = State::DoctypeSystemIdentifierDoubleQuoted; Ok(ControlToken::Continue) } Some('\'') => { - slf.emitter.init_doctype_system_identifier(); + slf.emitter.init_doctype_system_id(); slf.state = State::DoctypeSystemIdentifierSingleQuoted; Ok(ControlToken::Continue) } @@ -1460,13 +1460,13 @@ where } Some('"') => { slf.emit_error(Error::MissingWhitespaceAfterDoctypeSystemKeyword); - slf.emitter.init_doctype_system_identifier(); + slf.emitter.init_doctype_system_id(); slf.state = State::DoctypeSystemIdentifierDoubleQuoted; Ok(ControlToken::Continue) } Some('\'') => { slf.emit_error(Error::MissingWhitespaceAfterDoctypeSystemKeyword); - slf.emitter.init_doctype_system_identifier(); + slf.emitter.init_doctype_system_id(); slf.state = State::DoctypeSystemIdentifierSingleQuoted; Ok(ControlToken::Continue) } @@ -1494,12 +1494,12 @@ where State::BeforeDoctypeSystemIdentifier => match slf.read_char()? { Some(whitespace_pat!()) => Ok(ControlToken::Continue), Some('"') => { - slf.emitter.init_doctype_system_identifier(); + slf.emitter.init_doctype_system_id(); slf.state = State::DoctypeSystemIdentifierDoubleQuoted; Ok(ControlToken::Continue) } Some('\'') => { - slf.emitter.init_doctype_system_identifier(); + slf.emitter.init_doctype_system_id(); slf.state = State::DoctypeSystemIdentifierSingleQuoted; Ok(ControlToken::Continue) } @@ -1531,7 +1531,7 @@ where } Some('\0') => { slf.emit_error(Error::UnexpectedNullCharacter); - slf.emitter.push_doctype_system_identifier("\u{fffd}"); + slf.emitter.push_doctype_system_id("\u{fffd}"); Ok(ControlToken::Continue) } Some('>') => { @@ -1548,7 +1548,7 @@ where Ok(ControlToken::Eof) } Some(x) => { - slf.emitter.push_doctype_system_identifier(ctostr!(x)); + slf.emitter.push_doctype_system_id(ctostr!(x)); Ok(ControlToken::Continue) } }, @@ -1559,7 +1559,7 @@ where } Some('\0') => { slf.emit_error(Error::UnexpectedNullCharacter); - slf.emitter.push_doctype_system_identifier("\u{fffd}"); + slf.emitter.push_doctype_system_id("\u{fffd}"); Ok(ControlToken::Continue) } Some('>') => { @@ -1576,7 +1576,7 @@ where Ok(ControlToken::Eof) } Some(x) => { - slf.emitter.push_doctype_system_identifier(ctostr!(x)); + slf.emitter.push_doctype_system_id(ctostr!(x)); Ok(ControlToken::Continue) } }, |