diff --git a/typed-html/src/elements.rs b/typed-html/src/elements.rs index 5312da1..53de1eb 100644 --- a/typed-html/src/elements.rs +++ b/typed-html/src/elements.rs @@ -40,6 +40,10 @@ marker_trait!(PhrasingContent, FlowContent); marker_trait!(EmbeddedContent); marker_trait!(InteractiveContent); marker_trait!(FormContent); +marker_trait!(SvgContent); +marker_trait!(ClipPathContent); +marker_trait!(DefsContent); +marker_trait!(FilterContent); // Traits for elements that are more picky about their children marker_trait!(DescriptionListContent); @@ -98,7 +102,7 @@ declare_elements! { rel: SpacedList, target: Target, type: Mime, - } in [FlowContent, PhrasingContent, InteractiveContent] with FlowContent; + } in [FlowContent, PhrasingContent, InteractiveContent, SvgContent] with FlowContent; abbr in [FlowContent, PhrasingContent] with PhrasingContent; address in [FlowContent] with FlowContent; article in [FlowContent, SectioningContent] with FlowContent; @@ -435,6 +439,77 @@ declare_elements! { srclang: LanguageTag, } in [MediaContent]; + svg { + height: String, + width: String, + preserveAspectRatio: PreserveAspectRatio, + viewBox: String, + x: String, + y: String, + xmlns: String, + clip-path: String, + clip-rule: String, + color: String, + color-interpolation: String, + color-rendering: String, + cursor: String, + display: String, + fill: String, + fill-opacity: String, + fill-rule: String, + filter: String, + mask: String, + opacity: String, + pointer-events: String, + shape-rendering: String, + stroke: String, + stroke-dasharray: String, + stroke-dashoffset: String, + stroke-linecap: String, + stroke-linejoin: String, + stroke-miterlimit: String, + stroke-opacity: String, + stroke-width: String, + transform: String, + vector-effect: String, + visibility: String + } in [FlowContent] with SvgContent; + path { + d: String, + pathLength: usize, + } in [SvgContent, ClipPathContent, DefsContent]; + circle { + cx: String, + pathLength: usize, + cy: String, + r: String + } in [SvgContent, ClipPathContent, DefsContent]; + clipPath { + clipPathUnits: ClipPathIUnits, + } in [SvgContent] with ClipPathContent; + defs in [SvgContent] with DefsContent; + desc in [SvgContent] with PhrasingContent; + + ellipse { + cx: String, + pathLength: usize, + cy: String, + rx: String, + ry: String + } in [SvgContent, ClipPathContent, DefsContent]; + feBlend { + _in: String, // TODO OMG FUCK THIS + in2: usize, + mode: Blends + } in [SvgContent, ClipPathContent, DefsContent, FilterContent]; + filter { + x: String, + y: String, + width: String, + height: String, + filterUnits: ClipPathIUnits, + primitiveUnits: ClipPathIUnits, + } in [SvgContent, ClipPathContent, DefsContent] with FilterContent; // Don't @ me blink in [FlowContent, PhrasingContent] with PhrasingContent; marquee { @@ -488,3 +563,20 @@ fn test_aria() { frag.to_string() ); } + +#[test] +fn test_svg() { + use crate as axohtml; + use crate::{dom::DOMTree, html}; + + let frag: DOMTree = html!( + + + + ); + + assert_eq!( + "
", + frag.to_string() + ); +} diff --git a/typed-html/src/types/mod.rs b/typed-html/src/types/mod.rs index f2d81bc..cc14595 100644 --- a/typed-html/src/types/mod.rs +++ b/typed-html/src/types/mod.rs @@ -537,3 +537,104 @@ pub enum Wrap { #[strum(to_string = "off")] Off, } + +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] +pub enum AriaSort { + #[strum(to_string = "ascending")] + Ascending, + #[strum(to_string = "descending")] + Descending, + #[strum(to_string = "none")] + None, + #[strum(to_string = "other")] + Other, +} + +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] +pub enum PreserveAspectRatio { + #[strum(to_string = "none meet")] + NoneMeet, + #[strum(to_string = "xMinYMin meet")] + XMinYMinMeet, + #[strum(to_string = "xMidYMin meet")] + XMidYMinMeet, + #[strum(to_string = "xMaxYMin meet")] + XMaxYMinMeet, + #[strum(to_string = "xMinYMid meet")] + XMinYMidMeet, + #[strum(to_string = "xMidYMid meet")] + XMidYMidMeet, + #[strum(to_string = "xMaxYMid meet")] + XMaxYMidMeet, + #[strum(to_string = "xMinYMax meet")] + XMinYMaxMeet, + #[strum(to_string = "xMidYMax meet")] + XMidYMaxMeet, + #[strum(to_string = "xMaxYMax meet")] + XMaxYMaxMeet, + + #[strum(to_string = "none slice")] + NoneSlice, + #[strum(to_string = "xMinYMin slice")] + XMinYMinSlice, + #[strum(to_string = "xMidYMin slice")] + XMidYMinSlice, + #[strum(to_string = "xMaxYMin slice")] + XMaxYMinSlice, + #[strum(to_string = "xMinYMid slice")] + XMinYMidSlice, + #[strum(to_string = "xMidYMid slice")] + XMidYMidSlice, + #[strum(to_string = "xMaxYMid slice")] + XMaxYMidSlice, + #[strum(to_string = "xMinYMax slice")] + XMinYMaxSlice, + #[strum(to_string = "xMidYMax slice")] + XMidYMaxSlice, + #[strum(to_string = "xMaxYMax slice")] + XMaxYMaxSlice, +} + +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] +pub enum ClipPathIUnits { + #[strum(to_string = "userSpaceOnUse")] + UserSpaceOnUse, + #[strum(to_string = "objectBoundingBox")] + ObjectBoundingBox, +} + +#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, IntoStaticStr)] +pub enum Blends { + #[strum(to_string = "normal")] + Normal, + #[strum(to_string = "multiply")] + Multiply, + #[strum(to_string = "screen")] + Screen, + #[strum(to_string = "overlay")] + Overlay, + #[strum(to_string = "darken")] + Darken, + #[strum(to_string = "lighten")] + Lighten, + #[strum(to_string = "color-dodge")] + ColorDodge, + #[strum(to_string = "color-burn")] + ColorBurn, + #[strum(to_string = "hard-light")] + HardLight, + #[strum(to_string = "soft-light")] + SoftLight, + #[strum(to_string = "difference")] + Difference, + #[strum(to_string = "exclusion")] + Exclusion, + #[strum(to_string = "hue")] + Hue, + #[strum(to_string = "saturation")] + Saturation, + #[strum(to_string = "color")] + Color, + #[strum(to_string = "luminosity")] + Luminosity, +}