mirror of https://github.com/Jackett/Jackett
Add ToHtmlPretty for AngleSharp
This commit is contained in:
parent
5f0eb9a170
commit
042fa5d7d9
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue