diff options
author | Martin Fischer <martin@push-f.com> | 2023-09-04 20:32:23 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2023-09-28 10:36:08 +0200 |
commit | 4e0057344381a50cd76419be170eab3d9389f034 (patch) | |
tree | 7bdaab30adfb85766118a7bd779a88eb10bc16d7 | |
parent | 30b4adf60b9423968b0c9c6d23363f6d8cd99384 (diff) |
break!: rename State variants
The spec refers to them only as RCDATA, RAWTEXT and PLAINTEXT.
See https://rust-lang.github.io/api-guidelines/naming.html.
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | src/naive_parser.rs | 6 | ||||
-rw-r--r-- | src/tokenizer.rs | 12 |
3 files changed, 12 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4106edd..d35ffc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,9 @@ * Removed `CdataAction` and changed `handle_cdata_open` to just take a boolean instead. +* Three variants of the `State` enum have been renamed according to the Rust API guidelines + (`RcData` to `Rcdata`, `RawText` to `Rawtext` and `PlainText` to `Plaintext`). + * `NaiveParser`: Removed `new_with_spans`. ### 0.5.1 - 2023-09-03 diff --git a/src/naive_parser.rs b/src/naive_parser.rs index b26e25e..ec07b07 100644 --- a/src/naive_parser.rs +++ b/src/naive_parser.rs @@ -97,10 +97,10 @@ pub(crate) fn naive_next_state(tag_name: &str) -> State { // These transitions are defined in https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments. // TODO: investigate what state logic Python's HTMLParser is using match tag_name { - "title" | "textarea" => State::RcData, - "style" | "xmp" | "iframe" | "noembed" | "noframes" => State::RawText, + "title" | "textarea" => State::Rcdata, + "style" | "xmp" | "iframe" | "noembed" | "noframes" => State::Rawtext, "script" => State::ScriptData, - "plaintext" => State::PlainText, + "plaintext" => State::Plaintext, _other => State::Data, } } diff --git a/src/tokenizer.rs b/src/tokenizer.rs index cd5ae71..4d3c534 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -92,15 +92,15 @@ pub enum State { /// The [PLAINTEXT state]. /// /// [PLAINTEXT state]: https://html.spec.whatwg.org/multipage/parsing.html#plaintext-state - PlainText, + Plaintext, /// The [RCDATA state]. /// /// [RCDATA state]: https://html.spec.whatwg.org/multipage/parsing.html#rcdata-state - RcData, + Rcdata, /// The [RAWTEXT state]. /// /// [RAWTEXT state]: https://html.spec.whatwg.org/multipage/parsing.html#rawtext-state - RawText, + Rawtext, /// The [script data state]. /// /// [script data state]: https://html.spec.whatwg.org/multipage/parsing.html#script-data-state @@ -119,9 +119,9 @@ impl From<State> for machine::State { fn from(state: State) -> Self { match state { State::Data => machine::State::Data, - State::PlainText => machine::State::PlainText, - State::RcData => machine::State::RcData, - State::RawText => machine::State::RawText, + State::Plaintext => machine::State::PlainText, + State::Rcdata => machine::State::RcData, + State::Rawtext => machine::State::RawText, State::ScriptData => machine::State::ScriptData, State::ScriptDataEscaped => machine::State::ScriptDataEscaped, State::ScriptDataDoubleEscaped => machine::State::ScriptDataDoubleEscaped, |