예제 #1
0
        /// <summary>
        /// Convert parsed HTML to plain text
        /// </summary>
        /// <param name="html">The HTML content to minify. A <see cref="string"/> or <see cref="Stream"/> can also be used.</param>
        /// <param name="settings">Settings controlling how the plain text is rendered</param>
        /// <returns>A plain text representation of the HTML</returns>
        public static string ToPlainText(TextSource html, TextWriterSettings settings = null)
        {
            var sb = Pool.NewStringBuilder();

            sb.EnsureCapacity(html.Length);
            using (var sw = new StringWriter(sb))
                using (var reader = new HtmlReader(html, false))
                {
                    reader.ToPlainText(sw, settings);
                    sw.Flush();
                    return(sb.ToPool());
                }
        }