/// <summary> /// Convert html string to IHtmlElementsCollection. /// </summary> /// <param name="html">Valid html string.</param> /// <returns cref="IHtmlElementsCollection">IHtmlElementsCollection instance represent given html string.</returns> public IHtmlElementsCollection ParseString(string html) { if (html.IsNullOrEmpty()) { throw new ArgumentNullException("html"); } IHtmlParserManager parserManger = _parserManagerFactory.Create(html); return(parserManger.Parse()); }
public override IHtmlElement Create(HtmlAttributesCollection attributes, string html, IHtmlParserManager htmlParserManager) { HtmlDocTypeElement document = new HtmlDocTypeElement(); document.Attributes = attributes; return(document); }
public override IHtmlElement Create(HtmlAttributesCollection attributes, string html, int startContentIndex, int endContentIndex, IHtmlParserManager htmlParserManager) { HtmlScriptElement element = new HtmlScriptElement(); element.Attributes = attributes; element.Text(html.SubStringToIndex(startContentIndex, endContentIndex - 1), true); return(element); }
public override IHtmlElement Create(HtmlAttributesCollection attributes, string html, int startContentIndex, int endContentIndex, IHtmlParserManager htmlParserManager) { HtmlNodeElement element = (HtmlNodeElement)CreateInstance(); // add children and texts if (endContentIndex - startContentIndex > 0) { element.Children = htmlParserManager.ParseElements(startContentIndex, endContentIndex); Dictionary <int, string> texts = htmlParserManager.ParseText(startContentIndex, endContentIndex); foreach (var text in texts) { string decodedText = HttpUtility.HtmlDecode(text.Value); string value = text.Value; if (Regex.IsMatch(decodedText, HtmlRegexParserManager.commentRegex)) { value = decodedText; } if (text.Key >= 0) { element.Text(new HtmlString(value), element.Children[text.Key].UId); } else { element.Text(new HtmlString(value)); } } } element.Attributes = attributes; return(element); }
public DefaultSnippetTextService(IHtmlParserManager htmpParserManager, IEverNoteService everNoteService, ISnippetTextRepository snippetTextRepository) { _htmlParserManager = htmpParserManager; _everNoteService = everNoteService; _snippetTextRepository = snippetTextRepository; }
public virtual IHtmlElement Create(HtmlAttributesCollection attributes, string html, int startContentIndex, int endContentIndex, IHtmlParserManager htmlParserManager) { HtmlPairTagsElement element = (HtmlPairTagsElement)CreateInstance(); element.Attributes = attributes; element.Text(html.SubStringToIndex(startContentIndex, endContentIndex - 1)); return(element); }
public virtual IHtmlElement Create(HtmlAttributesCollection attributes, string html, IHtmlParserManager htmlParserManager) { IHtmlElement element = (HtmlSelfClosingTagElement)CreateInstance(); element.Attributes = attributes; return(element); }