From 2e020055fdad30dee8ea531a0c9f991d659b65d1 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 5 Nov 2023 10:20:51 -0800 Subject: [PATCH] Fix issue in which links to existing pages weren't being rendered correctly when preceded by bullet points --- .../ktt/view/plugins/PageLinkPlugin.kt | 2 +- .../ktt/view/PageRenderingInteractorTest.kt | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/PageLinkPlugin.kt b/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/PageLinkPlugin.kt index 5e0a964..7b3df69 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/PageLinkPlugin.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/PageLinkPlugin.kt @@ -11,7 +11,7 @@ class PageLinkPlugin(private val repository: SQLiteWikiRepository): PageRenderin val prefixChar = it.groupValues[1] repository.searchPageByTitle(linkText)?.let { existingPageId-> - return@replace "[$linkText](/page/$existingPageId)" + return@replace "$prefixChar[$linkText](/page/$existingPageId)" } "$prefixChar[$linkText](/page/create/$linkText)" diff --git a/src/test/kotlin/com/vandenbreemen/ktt/view/PageRenderingInteractorTest.kt b/src/test/kotlin/com/vandenbreemen/ktt/view/PageRenderingInteractorTest.kt index 2f6ee4e..83c704c 100644 --- a/src/test/kotlin/com/vandenbreemen/ktt/view/PageRenderingInteractorTest.kt +++ b/src/test/kotlin/com/vandenbreemen/ktt/view/PageRenderingInteractorTest.kt @@ -169,4 +169,22 @@ This test contains a link to a link that you can try out. rendered.shouldContain("
  • Test.Page") } + @Test + fun `should properly render bullet points with links for existing pages`() { + // Arrange + repository.createPage(Page("Test Page", "This is a test")) + val markdown = + """ +## Here is a Test +This test contains a link to a link that you can try out. +* [Test.Page] +""".trimIndent() + repository.createPage(Page("Test.Page", "This is a test")) + val rendered = pageRenderingInteractor.render(Page("test", markdown)) + + println(rendered) + + rendered.shouldContain("
  • Test.Page") + } + } \ No newline at end of file