Example #1
0
        public static string RemoveHtmlMarkup(this string value)
        {
            if (String.IsNullOrWhiteSpace(value))
            {
                return(value);
            }

            value = Regex.Replace(value, @"<[^>]+>", String.Empty).Trim();
            value = HtmlUtility.HtmlDecode(value);
            return(Regex.Replace(value, @"\s{2,}", " "));
        }
Example #2
0
        public static string HtmlDecode(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }

            if (!HtmlUtility.StringRequiresHtmlDecoding(value))
            {
                return(value);
            }

            var stringWriter = new StringWriter(CultureInfo.InvariantCulture);

            HtmlUtility.HtmlDecode(value, stringWriter);

            return(stringWriter.ToString());
        }