/// <exception cref="Sharpen.SAXException"></exception> public bool Start(NBoilerpipeContentHandler instance, string localName, HtmlAttributeCollection atts) { IList <string> labels = new AList <string>(5); labels.AddItem(DefaultLabels.MARKUP_PREFIX + localName); string classVal = atts["class"].Value; if (classVal != null && classVal.Length > 0) { classVal = PAT_NUM.Matcher(classVal).ReplaceAll("#"); classVal = classVal.Trim(); string[] vals = classVal.Split("[ ]+"); labels.AddItem(DefaultLabels.MARKUP_PREFIX + "." + classVal.Replace(' ', '.')); if (vals.Length > 1) { foreach (string s in vals) { labels.AddItem(DefaultLabels.MARKUP_PREFIX + "." + s); } } } var att = atts["id"]; var id = (atts != null) ? att.Name : ""; if (id != null && id.Length > 0) { id = PAT_NUM.Matcher(id).ReplaceAll("#"); labels.AddItem(DefaultLabels.MARKUP_PREFIX + "#" + id); } ICollection <string> ancestors = GetAncestorLabels(); IList <string> labelsWithAncestors = new AList <string>((ancestors.Count + 1) * labels .Count); foreach (string l in labels) { foreach (string an in ancestors) { labelsWithAncestors.AddItem(an); labelsWithAncestors.AddItem(an + " " + l); } labelsWithAncestors.AddItem(l); } instance.AddLabelAction(new LabelAction(Sharpen.Collections.ToArray(labelsWithAncestors , new string[labelsWithAncestors.Count]))); labelStack.AddItem(labels); return(isBlockLevel); }
public bool Start(NBoilerpipeContentHandler instance, string localName, HtmlAttributeCollection atts) { instance.AddLabelAction(action); return true; }
public bool Start(NBoilerpipeContentHandler instance, string localName, HtmlAttributeCollection atts) { instance.AddWhitespaceIfNecessary(); instance.AddLabelAction(action); return false; }
public bool Start(NBoilerpipeContentHandler instance, string localName, HtmlAttributeCollection atts) { instance.AddLabelAction(action); return(true); }
public bool Start(NBoilerpipeContentHandler instance, string localName, HtmlAttributeCollection atts) { instance.AddWhitespaceIfNecessary(); instance.AddLabelAction(action); return(false); }
/// <exception cref="Sharpen.SAXException"></exception> public bool Start(NBoilerpipeContentHandler instance, string localName, HtmlAttributeCollection atts) { IList<string> labels = new AList<string> (5); labels.AddItem (DefaultLabels.MARKUP_PREFIX + localName); string classVal = atts ["class"].Value; if (classVal != null && classVal.Length > 0) { classVal = PAT_NUM.Matcher (classVal).ReplaceAll ("#"); classVal = classVal.Trim (); string[] vals = classVal.Split ("[ ]+"); labels.AddItem (DefaultLabels.MARKUP_PREFIX + "." + classVal.Replace (' ', '.')); if (vals.Length > 1) { foreach (string s in vals) { labels.AddItem (DefaultLabels.MARKUP_PREFIX + "." + s); } } } var att = atts["id"]; var id = ( atts !=null) ? att.Name : ""; if (id != null && id.Length > 0) { id = PAT_NUM.Matcher (id).ReplaceAll ("#"); labels.AddItem (DefaultLabels.MARKUP_PREFIX + "#" + id); } ICollection<string> ancestors = GetAncestorLabels (); IList<string> labelsWithAncestors = new AList<string> ((ancestors.Count + 1) * labels .Count); foreach (string l in labels) { foreach (string an in ancestors) { labelsWithAncestors.AddItem (an); labelsWithAncestors.AddItem (an + " " + l); } labelsWithAncestors.AddItem (l); } instance.AddLabelAction (new LabelAction (Sharpen.Collections.ToArray (labelsWithAncestors , new string[labelsWithAncestors.Count]))); labelStack.AddItem (labels); return isBlockLevel; }