Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active November 15, 2022 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/734f066d61ad10e58203ccfdbcf3e654 to your computer and use it in GitHub Desktop.
Save bjoerntx/734f066d61ad10e58203ccfdbcf3e654 to your computer and use it in GitHub Desktop.
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