Add ToHtmlPretty for AngleSharp

This commit is contained in:
kaso17 2017-02-08 11:28:44 +01:00
parent 5f0eb9a170
commit 042fa5d7d9
1 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,9 @@
using System;
using AngleSharp.Dom;
using AngleSharp.Html;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
@ -76,6 +79,20 @@ namespace Jackett.Utils
return string.Join("&", collection.AllKeys.Select(a => a + "=" + HttpUtility.UrlEncode(collection[a], encoding)));
}
public static string ToHtmlPretty(this IElement element)
{
if (element == null)
return "<NULL>";
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
var formatter = new PrettyMarkupFormatter();
element.ToHtml(sw, formatter);
return sb.ToString();
}
public static string GenerateRandom(int length)
{
var chars = "abcdefghijklmnopqrstuvwxyz0123456789";