Skip to content

Commit

Permalink
Fix issue in which links to existing pages weren't being rendered cor…
Browse files Browse the repository at this point in the history
…rectly when preceded by bullet points
  • Loading branch information
kevinvandenbreemen committed Nov 5, 2023
1 parent 8256322 commit 2e02005
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,22 @@ This test contains a link to a link that you can try out.
rendered.shouldContain("<li><a href=\"/page/create/Test.Page\">Test.Page</a>")
}

@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("<li><a href=\"/page/2\">Test.Page</a>")
}

}

0 comments on commit 2e02005

Please sign in to comment.