oliverbooth.dev/OliverBooth.Extensions.Markdig/Markdown/Timestamp/TimestampExtension.cs
Oliver Booth 6ec4103a3a
refactor: separate Markdig extensions from project
Also introduces .Common project to house common references and types
2024-05-05 02:18:20 +01:00

26 lines
695 B
C#

using Markdig;
using Markdig.Renderers;
namespace OliverBooth.Extensions.Markdig.Markdown.Timestamp;
/// <summary>
/// Represents a Markdig extension that supports Discord-style timestamps.
/// </summary>
public class TimestampExtension : IMarkdownExtension
{
/// <inheritdoc />
public void Setup(MarkdownPipelineBuilder pipeline)
{
pipeline.InlineParsers.AddIfNotAlready<TimestampInlineParser>();
}
/// <inheritdoc />
public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer)
{
if (renderer is HtmlRenderer htmlRenderer)
{
htmlRenderer.ObjectRenderers.AddIfNotAlready<TimestampRenderer>();
}
}
}