This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-markdown-cil/tests/MfGames.Markdown.Gemtext.Tests/WikiLinkTests.cs

57 lines
1.4 KiB
C#

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;
/// <summary>
/// Tests the functionality of the WriteFiles().
/// </summary>
public class WikiLinkTest : TestBase<TestContext>
{
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;
}
}