protected virtual string AppendElementNode(string text, ParsedElement element) { if (element.StartTag.Equals("<ul>", StringComparison.InvariantCultureIgnoreCase)) { return(ListTagsFormatter.AppendUnorderedList(text, element, this)); } else if (element.StartTag.Equals("<ol>", StringComparison.InvariantCultureIgnoreCase)) { return(ListTagsFormatter.AppendOrderedList(text, element, this)); } else if (element.StartTag.StartsWith("<a ", StringComparison.InvariantCultureIgnoreCase)) { return(UrlTagsFormatter.AppendUrlTag(text, element, this)); } else if (element.StartTag.Equals("<hr>", StringComparison.InvariantCultureIgnoreCase)) { return(HorizontalRuleTagsFormatter.AppendHorizontalRule(text, element, this)); } else if (element.StartTag.Equals("<noparse>", StringComparison.InvariantCultureIgnoreCase)) { return(text + element.ToString()); } else { return(AppendGenericElementNode(text, element)); } }
public virtual string AppendUnorderedList(string text, ParsedElement element, IChildTagsFormatter childTagsFormatter) { UnorderedIndentLevel++; text = AppendListStart(text); text = AppendUnorderedListChildren(text, element.Children, childTagsFormatter); text = AppendListEnd(text); UnorderedIndentLevel--; return(text); }
protected virtual string GetOrderedListItemText(int index, ParsedElement element, IChildTagsFormatter childTagsFormatter) => "\n" + GetOrderedListItemStart(index++) + GetIndentOpeningTag() + childTagsFormatter.FormatChildren(element.Children).Trim() + IndentClosingTag;
protected virtual string GetUnorderedListItemText(char bulletChar, ParsedElement element, IChildTagsFormatter childTagsFormatter) => "\n" + bulletChar + GetIndentOpeningTag() + childTagsFormatter.FormatChildren(element.Children).Trim() + IndentClosingTag;
protected virtual string AppendGenericElementNode(string text, ParsedElement element) => $"{text}{element.StartTag}{AppendChildren("", element.Children)}{element.EndTag}";