コード例 #1
0
ファイル: MarkdownTests.cs プロジェクト: shekky/BracketPipe
 private void CheckConversion(string html, string expected)
 {
     using (var reader = new HtmlReader(html))
     {
         var actual = reader.ToMarkdown();
         Assert.Equal(expected, actual);
     }
 }
コード例 #2
0
        /// <summary>
        /// Convert parsed HTML to markdown
        /// </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 markdown is rendered</param>
        /// <returns>A markdown representation of the HTML</returns>
        public static string ToMarkdown(TextSource html, MarkdownWriterSettings settings = null)
        {
            var sb = Pool.NewStringBuilder();

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