Exemple #1
0
        private HtmlStringBuilder Append(HtmlElement element)
        {
            Append('<').Append(element.Name);

            foreach (var attribute in element.Attributes)
            {
                Append(' ').Append(attribute);
            }

            Append('>');

            if (HtmlGrammar.IsVoidElement(element.Name) && !element.Children.Any())
            {
                return(this);
            }

            _depth++;

            foreach (var child in element.Children)
            {
                AppendLine().Append(child);
            }

            _depth--;

            AppendLine().Append("</").Append(element.Name).Append('>');

            return(this);
        }
Exemple #2
0
 private HtmlStringBuilder Append(HtmlText text) =>
 HtmlGrammar.IsRawTextElement((text.Parent as HtmlElement)?.Name)
         ? Append(text.Value)
         : Append(WebUtility.HtmlEncode(text.Value));
Exemple #3
0
 private HtmlStringBuilder Append(HtmlText text) =>
 HtmlGrammar.IsRawTextElement(_parentElements.Peek().Name)
         ? Append(text.Content)
         : Append(WebUtility.HtmlEncode(text.Content));