1- namespace AngleSharp . Css . Parser
1+ namespace AngleSharp . Css . Parser
22{
33 using AngleSharp . Css . Parser . Tokens ;
4+ using AngleSharp . Text ;
45 using System ;
56
67 /// <summary>
78 /// Extensions to be used exclusively by the tokenizer.
89 /// </summary>
910 static class CssTokenExtensions
1011 {
12+ public static Boolean IsPotentiallyNested ( this CssToken token )
13+ {
14+ if ( token . Is ( CssTokenType . Hash , CssTokenType . Colon , CssTokenType . SquareBracketOpen ) )
15+ {
16+ return true ;
17+ }
18+ else if ( token . Type == CssTokenType . Delim && token . Data . Length == 1 )
19+ {
20+ return token . Data [ 0 ] switch
21+ {
22+ Symbols . Asterisk or Symbols . Plus or Symbols . Dollar or Symbols . Dot or Symbols . Tilde or Symbols . GreaterThan or Symbols . Ampersand => true ,
23+ _ => false ,
24+ } ;
25+ }
26+
27+ return false ;
28+ }
29+
1130 /// <summary>
1231 /// Checks if the provided token is either of the first or the second
1332 /// type of token.
@@ -22,6 +41,39 @@ public static Boolean Is(this CssToken token, CssTokenType a, CssTokenType b)
2241 return type == a || type == b ;
2342 }
2443
44+ /// <summary>
45+ /// Checks if the provided token is one of the list of tokens.
46+ /// </summary>
47+ /// <param name="token">The token to examine.</param>
48+ /// <param name="a">The 1st type to match.</param>
49+ /// <param name="b">The 2nd type to match.</param>
50+ /// <param name="c">The 3rd type to match.</param>
51+ /// <returns>Result of the examination.</returns>
52+ public static Boolean Is ( this CssToken token , CssTokenType a , CssTokenType b , CssTokenType c )
53+ {
54+ var type = token . Type ;
55+ return type == a || type == b || type == c ;
56+ }
57+
58+ /// <summary>
59+ /// Checks if the provided token is one of the list of tokens.
60+ /// </summary>
61+ /// <param name="token">The token to examine.</param>
62+ /// <param name="a">The 1st type to match.</param>
63+ /// <param name="b">The 2nd type to match.</param>
64+ /// <param name="c">The 3rd type to match.</param>
65+ /// <param name="d">The 4th type to match.</param>
66+ /// <param name="e">The 5th type to match.</param>
67+ /// <param name="f">The 6th type to match.</param>
68+ /// <param name="g">The 7th type to match.</param>
69+ /// <param name="h">The 8th type to match.</param>
70+ /// <returns>Result of the examination.</returns>
71+ public static Boolean Is ( this CssToken token , CssTokenType a , CssTokenType b , CssTokenType c , CssTokenType d , CssTokenType e , CssTokenType f , CssTokenType g , CssTokenType h )
72+ {
73+ var type = token . Type ;
74+ return type == a || type == b || type == c || type == d || type == e || type == f || type == g || type == h ;
75+ }
76+
2577 /// <summary>
2678 /// Checks if the provided token is neither of the first nor the second
2779 /// type of token.
0 commit comments