using Markdig;
using Markdig.Renderers;
using OliverBooth.Common.Services;
namespace OliverBooth.Common.Markdown.Template;
///
/// Represents a Markdown extension that adds support for MediaWiki-style templates.
///
public sealed class TemplateExtension : IMarkdownExtension
{
private readonly ITemplateService _templateService;
///
/// Initializes a new instance of the class.
///
/// The template service.
public TemplateExtension(ITemplateService 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));
}
}
}