diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-29 15:54:13 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-29 16:16:48 +0100 |
commit | 26a4b848cd83ed5fea3fb2b420d1295b784f449b (patch) | |
tree | 3090beaaf64e094c9caba93d1e33b9ffdc7dacba /src/tokenizer/mod.rs | |
parent | 20c0bdba6386a72dffa9fa55c4bb6d4fffd378ca (diff) |
set tokenization state depending on tag name
Diffstat (limited to 'src/tokenizer/mod.rs')
-rw-r--r-- | src/tokenizer/mod.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/tokenizer/mod.rs b/src/tokenizer/mod.rs index fa01be8..f5968b2 100644 --- a/src/tokenizer/mod.rs +++ b/src/tokenizer/mod.rs @@ -418,6 +418,17 @@ impl<Sink: TokenSink> Tokenizer<Sink> { } } + // https://html.spec.whatwg.org/multipage/#concept-frag-parse-context + let next_state = match name.as_str() { + "title" | "textarea" => states::RawData(RawKind::Rcdata), + "style" | "xmp" | "iframe" | "noembed" | "noframes" => { + states::RawData(RawKind::Rawtext) + } + "script" => states::RawData(RawKind::ScriptData), + "plaintext" => states::Plaintext, + _other => states::Data, + }; + let token = TagToken(Tag { kind: self.current_tag_kind, name, @@ -426,7 +437,10 @@ impl<Sink: TokenSink> Tokenizer<Sink> { }); match self.process_token(token) { - TokenSinkResult::Continue => ControlFlow::Continue(()), + TokenSinkResult::Continue => { + self.state = next_state; + ControlFlow::Continue(()) + } TokenSinkResult::Plaintext => { self.state = states::Plaintext; ControlFlow::Continue(()) |