24 lines
773 B
C#
24 lines
773 B
C#
using Markdig;
|
|
|
|
namespace Elternbeirat.Web.Shared;
|
|
|
|
/// <summary>
|
|
/// Renders Markdown to HTML. Content now comes from PocketBase as raw Markdown
|
|
/// (the <c>body</c> field), so the pages render it at display time instead of
|
|
/// reading pre-rendered HTML from files.
|
|
/// </summary>
|
|
public static class Markdown
|
|
{
|
|
private static readonly MarkdownPipeline Pipeline =
|
|
new MarkdownPipelineBuilder().Build();
|
|
|
|
/// <summary>
|
|
/// Converts a Markdown string to HTML. Returns an empty string for
|
|
/// <c>null</c> or empty input, so callers can bind the result directly.
|
|
/// </summary>
|
|
public static string ToHtml(string? markdown) =>
|
|
string.IsNullOrEmpty(markdown)
|
|
? ""
|
|
: Markdig.Markdown.ToHtml(markdown, Pipeline);
|
|
}
|