public void Write(CssFunctionToken func) { _writer.Write(func.Data); _writer.Write('('); foreach (var arg in func) { Write(arg); } }
CssToken NewFunction(String value) { var function = new CssFunctionToken(value, _position); var token = NextToken(); while (token.Type != CssTokenType.EndOfFile) { function.AddArgumentToken(token); if (token.Type == CssTokenType.RoundBracketClose) { break; } token = NextToken(); } return(function); }
/// <summary> /// Combine consecutive ident tokens along with ident tokens followed by functions /// </summary> private static IEnumerable <CssToken> Normalize2(this IEnumerable <CssToken> reader) { using (var e = reader.GetEnumerator()) { if (!e.MoveNext()) { yield break; } var prev = e.Current; while (e.MoveNext()) { if (e.Current.Type == CssTokenType.Ident && prev.Type == CssTokenType.Ident) { prev = new CssToken(CssTokenType.Ident, prev.Data + e.Current.Data, prev.Position); } else if (e.Current.Type == CssTokenType.Function && prev.Type == CssTokenType.Ident) { var currFunc = (CssFunctionToken)e.Current; var func = new CssFunctionToken(prev.Data + e.Current.Data, prev.Position); foreach (var arg in currFunc.ArgumentTokens) { func.AddArgumentToken(arg); } prev = func; } else { yield return(prev); prev = e.Current; } } yield return(prev); } }