//! CSS syntax strings use super::ident::Ident; use super::number::{CSSInteger, CSSNumber}; use crate::error::{ParserError, PrinterError}; use crate::printer::Printer; use crate::properties::custom::TokenList; use crate::stylesheet::ParserOptions; use crate::traits::{Parse, ToCss}; use crate::values; #[cfg(feature = "visitor")] use crate::visitor::Visit; use cssparser::*; /// A CSS [syntax string](https://drafts.css-houdini.org/css-properties-values-api/#syntax-strings) /// used to define the grammar for a registered custom property. #[derive(Debug, PartialEq, Clone)] #[cfg_attr( feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] #[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))] #[cfg_attr(feature = "into_owned", derive(static_self::IntoOwned))] pub enum SyntaxString { /// A list of syntax components. Components(Vec), /// The universal syntax definition. Universal, } /// A [syntax component](https://drafts.css-houdini.org/css-properties-values-api/#syntax-component) /// within a [SyntaxString](SyntaxString). /// /// A syntax component consists of a component kind an a multiplier, which indicates how the component /// may repeat during parsing. #[derive(Debug, PartialEq, Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))] #[cfg_attr(feature = "into_owned", derive(static_self::IntoOwned))] pub struct SyntaxComponent { /// The kind of component. pub kind: SyntaxComponentKind, /// A multiplier for the component. pub multiplier: Multiplier, } /// A [syntax component component name](https://drafts.css-houdini.org/css-properties-values-api/#supported-names). #[derive(Debug, PartialEq, Clone)] #[cfg_attr( feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", content = "value", rename_all = "kebab-case") )] #[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))] #[cfg_attr(feature = "into_owned", derive(static_self::IntoOwned))] pub enum SyntaxComponentKind { /// A `` component. Length, /// A `` component. Number, /// A `` component. Percentage, /// A `` component. LengthPercentage, /// A `` component. Color, /// An `` component. Image, /// A `` component. Url, /// An `` component. Integer, /// An `` component. Angle, /// A `