diff --git a/mtags/src/main/scala-2/scala/meta/internal/docstrings/ScaladocParser.scala b/mtags/src/main/scala-2/scala/meta/internal/docstrings/ScaladocParser.scala index 764fad547bc..d18a22abc02 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/docstrings/ScaladocParser.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/docstrings/ScaladocParser.scala @@ -234,13 +234,13 @@ object ScaladocParser { * The start of a Scaladoc code block */ private val CodeBlockStartRegex = - new Regex("""(.*?)((?:\{\{\{)|(?:\u000E]*)?>\u000E))(.*)""") + new Regex("""(.*?)((?:\{\{\{)|(?:]*)?>))(.*)""") /** * The end of a Scaladoc code block */ private val CodeBlockEndRegex = - new Regex("""(.*?)((?:\}\}\})|(?:\u000E\u000E))(.*)""") + new Regex("""(.*?)((?:\}\}\})|(?:))(.*)""") /** * A key used for a tag map. The key is built from the name of the tag and diff --git a/tests/unit/src/test/scala/tests/ScaladocSuite.scala b/tests/unit/src/test/scala/tests/ScaladocSuite.scala new file mode 100644 index 00000000000..345224e27f1 --- /dev/null +++ b/tests/unit/src/test/scala/tests/ScaladocSuite.scala @@ -0,0 +1,32 @@ +package tests + +import scala.meta.internal.docstrings._ + +import munit.Location + +final class ScaladocSuite extends BaseSuite { + + /** + * Comment does not directly declare a meaningful equality definition, thus + * this check compares [[Comment.body]] instead. + */ + def checkCommentBody(name: String, original: String, expected: Body)(implicit + loc: Location + ): Unit = + test(name) { + val obtained: Comment = ScaladocParser.parseComment(original) + assertEquals(obtained.body, expected) + } + + checkCommentBody( + "Brace ({{{) style code comment", + """/**{{{val foo: Int = 1}}} */""", + Body(List(Code("val foo: Int = 1"))) + ) + + checkCommentBody( + "HTML
 style code comment",
+    """/**
val foo: Int = 1
*/""", + Body(List(Code("val foo: Int = 1"))) + ) +}