using Markdig; using MfGames.Markdown.Extensions; using MfGames.Markdown.Gemtext.Extensions; using MfGames.Markdown.Gemtext.Renderers; using MfGames.TestSetup; using Xunit; using Xunit.Abstractions; namespace MfGames.Markdown.Gemtext.Tests; /// /// Tests the functionality of the WriteFiles(). /// public class WikiLinkTest : TestBase { public WikiLinkTest(ITestOutputHelper output) : base(output) { } [Fact] public void PossessiveLabeledWikiLinkGemtext() { MarkdownPipeline pipeline = CreatePipeline(); string result = MarkdownGemtext .ToGemtext( "[[Test|Label]]'s", pipeline) .Replace("%5E", "^"); Assert.Equal("=> ^test$ Label's", result); } private static MarkdownPipeline CreatePipeline() { // Convert all titles to slugs. WikiLinkOptions options = new() { GetUrl = (title) => string.Format( "^{0}$", title.ToLowerInvariant().Replace(" ", "-")), }; // Create the pipeline and return the results. MarkdownPipelineBuilder builder = new MarkdownPipelineBuilder() .Use(new WikiLinkExtension(options)) .Use(new SetBlockLinkHandling(BlockLinkHandling.DocumentEnd)); // Build the pipeline and return it. MarkdownPipeline pipeline = builder.Build(); return pipeline; } }