private bool NodeUsingProperty(StylesheetNode node, string property, string value = null) { List <string[]> definition = GetCssContent(node); foreach (string[] line in definition) { //If looking for "margin", valid values are: margin and margin-x //If looking for "top", valid values are just top //So, the property must be alone or left-sided over the "-" symbol. bool found = false; if (property.Contains("-") || !line[0].Contains("-")) { found = line[0].Equals(property); } else if (line[0].Contains("-")) { found = line[0].Split("-")[0].Equals(property); } if (found) { if (string.IsNullOrEmpty(value)) { return(true); } else if (line[1].Contains(value)) { return(true); } } } return(false); }
override public Node Visit(StylesheetNode node) { if (_stylesheetNodeExpectations.Count > 0) { _stylesheetNodeExpectations.Dequeue().Invoke(node); } return(VisitChildren(node)); }
public override Node VisitStylesheet([NotNull] StylesheetContext context) { var stylesheet = new StylesheetNode(context.Start, context.LABEL().GetText()); foreach (PageContext page in context.page()) { stylesheet.AddChild(Visit(page)); } return(stylesheet); }
private bool CssNodeUsingProperty(StylesheetNode node, string property, string value = null) { List <string[]> definition = GetCssContent(node); foreach (string[] line in definition) { //If looking for "margin", valid values are: margin and margin-x //If looking for "top", valid values are just top //So, the property must be alone or left-sided over the "-" symbol. if (line[0].Contains(property) && (!line[0].Contains("-") || line[0].Split("-")[0] == property)) { if (value == null) { return(true); } else if (line[1].Contains(value)) { return(true); } } } return(false); }
private List <string[]> GetCssContent(StylesheetNode node) { List <string[]> lines = new List <string[]>(); string css = node.ToCss(); css = css.Substring(css.IndexOf("{") + 1); foreach (string line in css.Split(";")) { if (line.Contains(":")) { string[] item = line.Replace(" ", "").Split(":"); if (item[1].Contains("}")) { item[1] = item[1].Replace("}", ""); } if (item[1].Length > 0) { lines.Add(item); } } } return(lines); }
private string[] GetCssSelectors(StylesheetNode node) { string css = node.ToCss(); return(css.Substring(0, css.IndexOf("{")).Trim().Split(',')); }
public static IEnumerable <Comment> GetComments(this StylesheetNode node) { return(node.GetAll <Comment>()); }