aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/attr.rs14
-rw-r--r--src/emitter.rs19
-rw-r--r--src/lib.rs4
3 files changed, 20 insertions, 17 deletions
diff --git a/src/attr.rs b/src/attr.rs
new file mode 100644
index 0000000..d0d506e
--- /dev/null
+++ b/src/attr.rs
@@ -0,0 +1,14 @@
+use std::ops::Range;
+
+/// A HTML attribute value (plus spans).
+#[derive(Debug, Eq, PartialEq)]
+pub struct Attribute<O> {
+ /// The value of the attribute.
+ pub value: String,
+
+ /// The source code span of the attribute name.
+ pub name_span: Range<O>,
+
+ /// The source code span of the attribute value.
+ pub value_span: Range<O>,
+}
diff --git a/src/emitter.rs b/src/emitter.rs
index fcfb251..d3258e2 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -179,7 +179,7 @@ pub trait Emitter<O> {
pub struct DefaultEmitter<O = NoopOffset> {
current_characters: String,
current_token: Option<Token<O>>,
- current_attribute: Option<(String, Attribute<O>)>,
+ current_attribute: Option<(String, crate::attr::Attribute<O>)>,
seen_attributes: BTreeSet<String>,
emitted_tokens: VecDeque<Token<O>>,
attr_in_end_tag_span: Option<Range<O>>,
@@ -380,7 +380,7 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
self.flush_current_attribute();
self.current_attribute = Some((
String::new(),
- Attribute {
+ crate::attr::Attribute {
name_span: offset..offset,
value: String::new(),
value_span: Range::default(),
@@ -461,7 +461,7 @@ pub struct StartTag<O> {
///
/// Duplicate attributes are ignored after the first one as per WHATWG spec. Implement your own
/// [`Emitter`] to tweak this behavior.
- pub attributes: BTreeMap<String, Attribute<O>>,
+ pub attributes: BTreeMap<String, crate::attr::Attribute<O>>,
/// The source code span of the tag.
pub span: Range<O>,
@@ -475,19 +475,6 @@ impl<O: Offset> StartTag<O> {
}
}
-/// A HTML attribute value (plus spans).
-#[derive(Debug, Eq, PartialEq)]
-pub struct Attribute<O> {
- /// The value of the attribute.
- pub value: String,
-
- /// The source code span of the attribute name.
- pub name_span: Range<O>,
-
- /// The source code span of the attribute value.
- pub value_span: Range<O>,
-}
-
/// A HTML end/close tag, such as `</p>` or `</a>`.
#[derive(Debug, Eq, PartialEq)]
pub struct EndTag<O> {
diff --git a/src/lib.rs b/src/lib.rs
index 1105141..4f2cf9c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,6 +3,7 @@
#![forbid(unsafe_code)]
#![doc = include_str!("../README.md")]
+mod attr;
mod emitter;
mod entities;
mod error;
@@ -15,6 +16,7 @@ mod utils;
#[cfg(feature = "integration-tests")]
pub use utils::State as InternalState;
-pub use emitter::{Attribute, Comment, DefaultEmitter, Doctype, Emitter, EndTag, StartTag, Token};
+pub use attr::Attribute;
+pub use emitter::{Comment, DefaultEmitter, Doctype, Emitter, EndTag, StartTag, Token};
pub use error::Error;
pub use tokenizer::{State, Tokenizer};