2023-08-11 15:51:20 +01:00
|
|
|
using Markdig;
|
2023-08-10 01:49:09 +01:00
|
|
|
using Markdig.Renderers;
|
|
|
|
|
|
|
|
namespace OliverBooth.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>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|