Closed tlyau62 closed 1 year ago
looks like it's more related to the AngleSharp
looks like it's more related to the AngleSharp
Correct. If an example helps, this is a method I created in a helper/utility class:
public static readonly string[] MinimumTags = { "b", "i", "u", "em", "strong", "q" };
public static string SanitizeReduceMarkup(string markup)
{
if (!string.IsNullOrWhiteSpace(markup))
{
var options = new HtmlSanitizerOptions
{
AllowedTags = new HashSet<string>(MinimumTags)
};
var sanitizer = new HtmlSanitizer(options);
markup = sanitizer.Sanitize(markup, outputFormatter: AngleSharp.Xhtml.XhtmlMarkupFormatter.Instance);
}
return markup;
}
AngleSharp.Xhtml.XhtmlMarkupFormatter.Instance
replaces the default HTML formatter with one that follows XML rules. This is also covered in the wiki: https://github.com/mganss/HtmlSanitizer/wiki/Examples#ex3-replacing-the-default-formatter
Great👍 Thank you
For example the html
<br />
is formatted with<br>
as output. Is it possible to keep the/
?