Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove The Unicode Escape \u000E In Scaladoc Code Comment Parsing #2336

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ object ScaladocParser {
* The start of a Scaladoc code block
*/
private val CodeBlockStartRegex =
new Regex("""(.*?)((?:\{\{\{)|(?:\u000E<pre(?: [^>]*)?>\u000E))(.*)""")
new Regex("""(.*?)((?:\{\{\{)|(?:<pre(?: [^>]*)?>))(.*)""")

/**
* The end of a Scaladoc code block
*/
private val CodeBlockEndRegex =
new Regex("""(.*?)((?:\}\}\})|(?:\u000E</pre>\u000E))(.*)""")
new Regex("""(.*?)((?:\}\}\})|(?:</pre>))(.*)""")

/**
* A key used for a tag map. The key is built from the name of the tag and
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/src/test/scala/tests/ScaladocSuite.scala
Original file line number Diff line number Diff line change
@@ -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 <pre> style code comment",
"""/**<pre>val foo: Int = 1</pre> */""",
Body(List(Code("val foo: Int = 1")))
)
}