Skip to content

Commit f70b502

Browse files
authored
Merge pull request #10668 from dotty-staging/fix-doc-wiki-link-split
Scala3doc: handle escaped backslash when splitting wiki links
2 parents e108e09 + e9b3d8f commit f70b502

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

scala3doc/src/dotty/dokka/tasty/comments/MarkdownConverter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class MarkdownConverter(val repr: Repr) extends BaseConverter {
195195
object MarkdownConverter {
196196
def splitWikiLink(chars: String): (String, String) =
197197
// split on a space which is not backslash escaped (regex uses "zero-width negative lookbehind")
198-
chars.split("(?<!\\\\) ", /*max*/ 2) match {
198+
chars.split("(?<!(?<!\\\\)\\\\) ", /*max*/ 2) match {
199199
case Array(target) => (target, "")
200200
case Array(target, userText) => (target, userText)
201201
}

scala3doc/test/dotty/dokka/tasty/comments/MarkdownConverterTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ class MarkdownConverterTests {
88
assertEquals(("a", "b c d"), MarkdownConverter.splitWikiLink("a b c d"))
99
assertEquals(("a", "b\\ c d"), MarkdownConverter.splitWikiLink("a b\\ c d"))
1010
assertEquals(("a\\ b", "c d"), MarkdownConverter.splitWikiLink("a\\ b c d"))
11+
assertEquals(("a\\\\", "b c d"), MarkdownConverter.splitWikiLink("a\\\\ b c d"))
1112
}
1213
}

0 commit comments

Comments
 (0)