using System.Linq;
using Markdig.Syntax;
using Markdig.Syntax.Inlines;
namespace MfGames.Markdown.Gemtext.Renderers.Gemtext
{
///
/// Various useful extension methods for Markdig classes.
///
public static class MarkdigExtensions
{
///
/// Determines if the paragraph only contains a link.
///
/// The object to inspect.
/// True if there is only a link in the paragraph.
public static bool OnlyHasSingleLink(this ParagraphBlock obj)
{
return obj.Inline != null
&& obj.Inline.Count() == 1
&& obj.Inline.FirstChild is LinkInline;
}
///
/// Determines if the list item only contains a link.
///
/// The object to inspect.
/// True if there is only a link in the paragraph.
public static bool OnlyHasSingleLink(this ListItemBlock obj)
{
return obj.Count == 1
&& obj.LastChild is ParagraphBlock paragraphBlock
&& paragraphBlock.OnlyHasSingleLink();
}
}
}