예제 #1
0
        public static string HtmlSanitizer(this string html)
        {
            var sanitizer = new HtmlSanitizer();

            sanitizer.AllowDataAttributes = true;
            sanitizer.KeepChildNodes      = true;
            sanitizer.AllowedAttributes.Add("class");
            sanitizer.AllowedAttributes.Add("id");
            sanitizer.AllowedCssProperties.Add("word-break");
            var parsedCOntent = sanitizer.HtmlParserFactory().Parse(html);
            var sanitizedHmtl = sanitizer.Sanitize(parsedCOntent.Body.OuterHtml, "");

            return(sanitizedHmtl);
        }