From 1f280bbe4d585255f6889e047bf6b8dbf40f0721 Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Fri, 28 Jan 2022 13:36:11 +0100 Subject: [PATCH] Scaladoc: Unescaped special characters in Quotes documentation closes #13746 --- scaladoc-testcases/src/tests/markdowncode.scala | 5 +++++ .../src/dotty/tools/scaladoc/renderers/DocRenderer.scala | 2 +- .../signatures/TranslatableSignaturesTestCases.scala | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 scaladoc-testcases/src/tests/markdowncode.scala diff --git a/scaladoc-testcases/src/tests/markdowncode.scala b/scaladoc-testcases/src/tests/markdowncode.scala new file mode 100644 index 000000000000..ac8238b7f0f6 --- /dev/null +++ b/scaladoc-testcases/src/tests/markdowncode.scala @@ -0,0 +1,5 @@ +package tests.markdowncode + +/** Some text `{ ; }` */ +val aVal: Float + = 1.2f diff --git a/scaladoc/src/dotty/tools/scaladoc/renderers/DocRenderer.scala b/scaladoc/src/dotty/tools/scaladoc/renderers/DocRenderer.scala index 19e7e8a86995..a2c653208a83 100644 --- a/scaladoc/src/dotty/tools/scaladoc/renderers/DocRenderer.scala +++ b/scaladoc/src/dotty/tools/scaladoc/renderers/DocRenderer.scala @@ -86,7 +86,7 @@ class DocRender(signatureRenderer: SignatureRenderer)(using DocContext): case Subscript(text) => span(cls:="subscript")(renderElement(text)) // TODO implement style case Link(target, body) => renderLink(target, default => body.fold[TagArg](default)(renderElement)) - case Text(text) => raw(text) + case Text(text) => raw(text.escapeReservedTokens) case Summary(text) => renderElement(text) case HtmlTag(content) => raw(content) diff --git a/scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala b/scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala index e56b741f5fee..699aff7b6cf6 100644 --- a/scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala +++ b/scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala @@ -92,3 +92,5 @@ class FBoundedTypeParameters extends SignatureTest("fboundedTypeParameters", Sig class Exports extends SignatureTest("exports2", SignatureTest.all, sourceFiles = List("exports1", "exports2")) class ContextFunctions extends SignatureTest("contextfunctions", SignatureTest.all) + +class MarkdownCode extends SignatureTest("markdowncode", SignatureTest.all)