using Markdig;
using Markdig.Renderers;
using OliverBooth.Services;
namespace OliverBooth.Markdown;
///
/// Represents a Markdown extension that adds support for MediaWiki-style templates.
///
internal sealed class TemplateExtension : IMarkdownExtension
{
private readonly TemplateService _templateService;
public TemplateExtension(TemplateService templateService)
{
_templateService = templateService;
}
///
public void Setup(MarkdownPipelineBuilder pipeline)
{
pipeline.InlineParsers.AddIfNotAlready();
}
///
public void Setup(MarkdownPipeline pipeline, IMarkdownRenderer renderer)
{
if (renderer is HtmlRenderer htmlRenderer)
{
htmlRenderer.ObjectRenderers.Add(new TemplateRenderer(_templateService));
}
}
}