diff options
author | Martin Fischer <martin@push-f.com> | 2021-04-08 10:01:14 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-04-08 15:40:48 +0200 |
commit | fc9d3132f390b038544e45048b4fe345a3d47793 (patch) | |
tree | 0178d2f7abc72590147f4fb9585abfd37b978d54 /src/tokenizer | |
parent | da4bd49ed1d51461e0841d426784cab4c0f84d1d (diff) |
merge Attribute from markup5ever
Diffstat (limited to 'src/tokenizer')
-rw-r--r-- | src/tokenizer/interface.rs | 17 | ||||
-rw-r--r-- | src/tokenizer/mod.rs | 4 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/tokenizer/interface.rs b/src/tokenizer/interface.rs index 35ba9c5..ebb8569 100644 --- a/src/tokenizer/interface.rs +++ b/src/tokenizer/interface.rs @@ -7,10 +7,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use markup5ever::interface::Attribute; use tendril::StrTendril; use crate::tokenizer::states; -use markup5ever::LocalName; +use markup5ever::{LocalName, QualName}; use std::borrow::Cow; pub use self::TagKind::{EndTag, StartTag}; @@ -44,6 +43,20 @@ pub enum TagKind { EndTag, } +/// A tag attribute, e.g. `class="test"` in `<div class="test" ...>`. +/// +/// The namespace on the attribute name is almost always ns!(""). +/// The tokenizer creates all attributes this way, but the tree +/// builder will adjust certain attribute names inside foreign +/// content (MathML, SVG). +#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug)] +pub struct Attribute { + /// The name of the attribute (e.g. the `class` in `<div class="test">`) + pub name: QualName, + /// The value of the attribute (e.g. the `"test"` in `<div class="test">`) + pub value: StrTendril, +} + /// A tag token. #[derive(PartialEq, Eq, Clone, Debug)] pub struct Tag { diff --git a/src/tokenizer/mod.rs b/src/tokenizer/mod.rs index 6c5823f..c6f7276 100644 --- a/src/tokenizer/mod.rs +++ b/src/tokenizer/mod.rs @@ -11,7 +11,7 @@ pub use self::interface::{CharacterTokens, EOFToken, NullCharacterToken, ParseError}; pub use self::interface::{CommentToken, DoctypeToken, TagToken, Token}; -pub use self::interface::{Doctype, EndTag, StartTag, Tag, TagKind}; +pub use self::interface::{Doctype, EndTag, StartTag, Tag, TagKind, Attribute}; pub use self::interface::{TokenSink, TokenSinkResult}; use self::states::{DoctypeIdKind, Public, System}; @@ -33,7 +33,7 @@ use std::mem::replace; pub use crate::util::buffer_queue::{BufferQueue, FromSet, NotFromSet, SetResult}; use tendril::StrTendril; -use markup5ever::{Attribute, LocalName, QualName}; +use markup5ever::{LocalName, QualName}; mod char_ref; mod interface; |