html5ever/tokenizer/states.rs
1// Copyright 2014-2017 The html5ever Project Developers. See the
2// COPYRIGHT file at the top-level directory of this distribution.
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10//! Tokenizer states.
11//!
12//! This is public for use by the tokenizer tests. Other library
13//! users should not have to care about this.
14
15pub use self::AttrValueKind::*;
16pub use self::DoctypeIdKind::*;
17pub use self::RawKind::*;
18pub use self::ScriptEscapeKind::*;
19pub use self::State::*;
20
21#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
22pub enum ScriptEscapeKind {
23 Escaped,
24 DoubleEscaped,
25}
26
27#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
28pub enum DoctypeIdKind {
29 Public,
30 System,
31}
32
33#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
34pub enum RawKind {
35 Rcdata,
36 Rawtext,
37 ScriptData,
38 ScriptDataEscaped(ScriptEscapeKind),
39}
40
41#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
42pub enum AttrValueKind {
43 Unquoted,
44 SingleQuoted,
45 DoubleQuoted,
46}
47
48#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
49pub enum State {
50 /// <https://html.spec.whatwg.org/#data-state>
51 Data,
52 /// <https://html.spec.whatwg.org/#plaintext-state>
53 Plaintext,
54 /// <https://html.spec.whatwg.org/#tag-open-state>
55 TagOpen,
56 /// <https://html.spec.whatwg.org/#tag-open-state>
57 EndTagOpen,
58 /// <https://html.spec.whatwg.org/#tag-name-state>
59 TagName,
60 RawData(RawKind),
61 RawLessThanSign(RawKind),
62 RawEndTagOpen(RawKind),
63 RawEndTagName(RawKind),
64 ScriptDataEscapeStart(ScriptEscapeKind),
65 /// <https://html.spec.whatwg.org/#script-data-escape-start-dash-state>
66 ScriptDataEscapeStartDash,
67 ScriptDataEscapedDash(ScriptEscapeKind),
68 ScriptDataEscapedDashDash(ScriptEscapeKind),
69 /// <https://html.spec.whatwg.org/#script-data-double-escape-end-state>
70 ScriptDataDoubleEscapeEnd,
71 /// <https://html.spec.whatwg.org/#before-attribute-name-state>
72 BeforeAttributeName,
73 /// <https://html.spec.whatwg.org/#attribute-name-state>
74 AttributeName,
75 /// <https://html.spec.whatwg.org/#after-attribute-name-state>
76 AfterAttributeName,
77 /// <https://html.spec.whatwg.org/#before-attribute-value-state>
78 BeforeAttributeValue,
79 AttributeValue(AttrValueKind),
80 /// <https://html.spec.whatwg.org/#after-attribute-value-(quoted)-state>
81 AfterAttributeValueQuoted,
82 /// <https://html.spec.whatwg.org/#self-closing-start-tag-state>
83 SelfClosingStartTag,
84 /// <https://html.spec.whatwg.org/#bogus-comment-state>
85 BogusComment,
86 /// <https://html.spec.whatwg.org/#markup-declaration-open-state>
87 MarkupDeclarationOpen,
88 /// <https://html.spec.whatwg.org/#comment-start-state>
89 CommentStart,
90 /// <https://html.spec.whatwg.org/#comment-start-dash-state>
91 CommentStartDash,
92 /// <https://html.spec.whatwg.org/#comment-state>
93 Comment,
94 /// <https://html.spec.whatwg.org/#comment-less-than-sign-state>
95 CommentLessThanSign,
96 /// <https://html.spec.whatwg.org/#comment-less-than-sign-bang-state>
97 CommentLessThanSignBang,
98 /// <https://html.spec.whatwg.org/#comment-less-than-sign-bang-dash-state>
99 CommentLessThanSignBangDash,
100 /// <https://html.spec.whatwg.org/#comment-less-than-sign-bang-dash-dash-state>
101 CommentLessThanSignBangDashDash,
102 /// <https://html.spec.whatwg.org/#comment-end-dash-state>
103 CommentEndDash,
104 /// <https://html.spec.whatwg.org/#comment-end-state>
105 CommentEnd,
106 /// <https://html.spec.whatwg.org/#comment-end-bang-state>
107 CommentEndBang,
108 /// <https://html.spec.whatwg.org/#doctype-state>
109 Doctype,
110 /// <https://html.spec.whatwg.org/#before-doctype-name-state>
111 BeforeDoctypeName,
112 /// <https://html.spec.whatwg.org/#doctype-name-state>
113 DoctypeName,
114 /// <https://html.spec.whatwg.org/#after-doctype-name-state>
115 AfterDoctypeName,
116 AfterDoctypeKeyword(DoctypeIdKind),
117 BeforeDoctypeIdentifier(DoctypeIdKind),
118 DoctypeIdentifierDoubleQuoted(DoctypeIdKind),
119 DoctypeIdentifierSingleQuoted(DoctypeIdKind),
120 AfterDoctypeIdentifier(DoctypeIdKind),
121 /// <https://html.spec.whatwg.org/#between-doctype-public-and-system-identifiers-state>
122 BetweenDoctypePublicAndSystemIdentifiers,
123 /// <https://html.spec.whatwg.org/#bogus-doctype-state>
124 BogusDoctype,
125 /// <https://html.spec.whatwg.org/#cdata-section-state>
126 CdataSection,
127 /// <https://html.spec.whatwg.org/#cdata-section-bracket-state>
128 CdataSectionBracket,
129 /// <https://html.spec.whatwg.org/#cdata-section-end-state>
130 CdataSectionEnd,
131}