public static string PrefixCssSelectors(string css, string selectorPrefix)
{
if (string.IsNullOrWhiteSpace(css))
{
return null;
}
// Strip CSS Comments:
var cssWithoutComments = Regex.Replace(css, "/\\*.+?\\*/", string.Empty, RegexOptions.Singleline);
var rules = Regex.Split(cssWithoutComments, "(?<=\\}).", RegexOptions.Singleline);
var cssRules = new List<string>();
var prefix = selectorPrefix + " ";
foreach (var rule in rules.Where(s => !string.IsNullOrWhiteSpace(s)))
{
cssRules.Add(PrefixCssSelectorsForSingleRule(prefix, rule));
}
return string.Join(Environment.NewLine, cssRules.ToArray());
}