Last active
November 15, 2022 18:52
-
-
Save bjoerntx/734f066d61ad10e58203ccfdbcf3e654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Markdig; | |
namespace TXTextControl { | |
public static class Markdown { | |
public static byte[] Convert(string markdown, BinaryStreamType binaryStreamType) { | |
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build(); | |
var htmlString = Markdig.Markdown.ToHtml(markdown, pipeline); | |
using (ServerTextControl tx = new ServerTextControl()) { | |
tx.Create(); | |
tx.Load(htmlString, StringStreamType.HTMLFormat); | |
byte[] results; | |
tx.Save(out results, binaryStreamType); | |
return results; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment