Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions html-node-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ version.workspace = true

[dependencies]
axum = { version = "0.6", optional = true, default-features = false }
serde = { version = "1.0", optional = true, features = ["derive"] }

html-escape = "0.2"
paste = "1.0.14"

[features]
axum = ["dep:axum"]
typed = []
serde = ["dep:serde"]
7 changes: 7 additions & 0 deletions html-node-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use self::typed::TypedElement;

/// An HTML node.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Node {
/// A comment.
///
Expand Down Expand Up @@ -116,6 +117,7 @@ impl Display for Node {
/// <!-- I'm a comment! -->
/// ```
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Comment {
/// The text of the comment.
///
Expand All @@ -137,6 +139,7 @@ impl Display for Comment {
/// <!DOCTYPE html>
/// ```
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Doctype {
/// The value of the doctype.
///
Expand All @@ -160,6 +163,7 @@ impl Display for Doctype {
/// </>
/// ```
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Fragment {
/// The children of the fragment.
///
Expand All @@ -185,6 +189,7 @@ impl Display for Fragment {
/// </div>
/// ```
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Element {
/// The name of the element.
///
Expand Down Expand Up @@ -250,6 +255,7 @@ impl Display for Element {
/// I'm a text node!
/// </div>
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Text {
/// The text of the node.
///
Expand All @@ -274,6 +280,7 @@ impl Display for Text {
/// [`UnsafeText`] is not escaped when rendered, and as such, can allow
/// for XSS attacks. Use with caution!
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct UnsafeText {
/// The text of the node.
pub text: String,
Expand Down
1 change: 1 addition & 0 deletions html-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
[features]
axum = ["html-node-core/axum"]
typed = ["html-node-core/typed", "html-node-macro/typed"]
serde = ["html-node-core/serde"]