private IEnumerable <IHtmlMarkup> GetTagElement(IHtmlContent content, RefIndex refIndex) { var matchResult = _startRegex.Match(content.Content.ToString()); var name = matchResult.Groups[1].Value; refIndex.Index = matchResult.Index; if (content.CurrentChar == '>') { yield return(new Tag(content.Content.ToString(), name, Array.Empty <IAttribute>(), GetElements(name, CloneContent(content)))); yield break; } var beginPosition = refIndex.Index + (matchResult.Length) + content.From; // {from}this is test code <div{beginPosition} name='4'>{index} IHtmlContent currentContent = content; if (beginPosition < content.Index) { currentContent = new HtmlContent(content.RootContent.Substring(beginPosition, content.Index - beginPosition)); } var attributes = new AttributeCollection(GetAttributes(currentContent)).ToArray(); yield return(new Tag(content.Content.ToString(), name, attributes, GetElements(name, CloneContent(currentContent)))); }
public object Clone() { var result = new HtmlContent(this.RootContent) { From = this.From, Index = this.Index }; result.SetContent(this.Content); return(result); }
public AttributeCollection(string content) { this._content = new HtmlContent(content); }