2023-08-11 15:51:20 +01:00
|
|
|
using Markdig.Renderers;
|
2023-08-08 21:03:41 +01:00
|
|
|
using Markdig.Renderers.Html;
|
2023-08-13 17:33:54 +01:00
|
|
|
using OliverBooth.Services;
|
2023-08-08 21:03:41 +01:00
|
|
|
|
2023-08-13 17:33:54 +01:00
|
|
|
namespace OliverBooth.Markdown.Template;
|
2023-08-08 21:03:41 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents a Markdown object renderer that handles <see cref="TemplateInline" /> elements.
|
|
|
|
/// </summary>
|
|
|
|
internal sealed class TemplateRenderer : HtmlObjectRenderer<TemplateInline>
|
|
|
|
{
|
2023-08-13 13:27:44 +01:00
|
|
|
private readonly ITemplateService _templateService;
|
2023-08-08 21:03:41 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="TemplateRenderer" /> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="templateService">The <see cref="TemplateService" />.</param>
|
2023-08-13 13:27:44 +01:00
|
|
|
public TemplateRenderer(ITemplateService templateService)
|
2023-08-08 21:03:41 +01:00
|
|
|
{
|
|
|
|
_templateService = templateService;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
protected override void Write(HtmlRenderer renderer, TemplateInline template)
|
|
|
|
{
|
2023-08-13 18:02:19 +01:00
|
|
|
renderer.Write(_templateService.RenderGlobalTemplate(template));
|
2023-08-08 21:03:41 +01:00
|
|
|
}
|
|
|
|
}
|