Skip to main content

css_ast/types/
text_edge.rs

1use super::prelude::*;
2/// <https://drafts.csswg.org/css-inline-3/#typedef-text-edge>
3///
4/// ```text,ignore
5/// <text-edge> = [ text | ideographic | ideographic-ink ] | [ text | ideographic | ideographic-ink | cap | ex ] [ text | ideographic | ideographic-ink | alphabetic ]
6/// ```
7#[syntax(
8	" [ text | ideographic | ideographic-ink | cap | ex ] [ text | ideographic | ideographic-ink | alphabetic ] | [ text | ideographic | ideographic-ink ] "
9)]
10#[derive(Parse, Peek, ToCursors, ToSpan, SemanticEq, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())]
12#[cfg_attr(feature = "visitable", derive(csskit_derives::Visitable), visit)]
13#[derive(csskit_derives::NodeWithMetadata)]
14pub enum TextEdge<'a> {}
15
16#[cfg(test)]
17mod tests {
18	use super::*;
19	use crate::CssAtomSet;
20	use css_parse::{assert_parse, assert_parse_error, assert_peek_false};
21
22	#[test]
23	fn test_writes() {
24		assert_parse!(CssAtomSet::ATOMS, TextEdge, "text");
25		assert_parse!(CssAtomSet::ATOMS, TextEdge, "ideographic");
26		assert_parse!(CssAtomSet::ATOMS, TextEdge, "ideographic-ink");
27		assert_parse!(CssAtomSet::ATOMS, TextEdge, "cap alphabetic");
28		assert_parse!(CssAtomSet::ATOMS, TextEdge, "ex alphabetic");
29		assert_parse!(CssAtomSet::ATOMS, TextEdge, "text alphabetic");
30		assert_parse!(CssAtomSet::ATOMS, TextEdge, "cap text");
31		assert_parse!(CssAtomSet::ATOMS, TextEdge, "ideographic ideographic-ink");
32	}
33
34	#[test]
35	fn test_errors() {
36		assert_peek_false!(CssAtomSet::ATOMS, TextEdge, "");
37		assert_parse_error!(CssAtomSet::ATOMS, TextEdge, "cap");
38		assert_parse_error!(CssAtomSet::ATOMS, TextEdge, "ex");
39		assert_peek_false!(CssAtomSet::ATOMS, TextEdge, "alphabetic");
40		assert_parse_error!(CssAtomSet::ATOMS, TextEdge, "text cap");
41		assert_peek_false!(CssAtomSet::ATOMS, TextEdge, "leading");
42	}
43}