using System;
using System.Net;
using Markdig.Extensions.SmartyPants;
namespace MfGames.Markdown.Gemtext.Renderers.Gemtext.Inlines
{
///
/// A Gemtext renderer for a .
///
///
public class GemtextSmartyPantRenderer
: GemtextObjectRenderer
{
private static readonly SmartyPantOptions DefaultOptions = new();
private readonly SmartyPantOptions options;
///
/// Initializes a new instance of the class.
///
/// The options.
///
public GemtextSmartyPantRenderer(SmartyPantOptions? options)
{
this.options = options
?? throw new ArgumentNullException(nameof(options));
}
protected override void Write(GemtextRenderer renderer, SmartyPant obj)
{
if (!this.options.Mapping.TryGetValue(obj.Type, out string? text))
{
DefaultOptions.Mapping.TryGetValue(obj.Type, out text);
}
string? unicode = WebUtility.HtmlDecode(text);
renderer.Write(unicode);
}
}
}