diff --git a/scaladoc-testcases/src/tests/annotatedmarkdowncomment.scala b/scaladoc-testcases/src/tests/annotatedmarkdowncomment.scala new file mode 100644 index 000000000000..9803a8453a2d --- /dev/null +++ b/scaladoc-testcases/src/tests/annotatedmarkdowncomment.scala @@ -0,0 +1,17 @@ +package tests.annotatedmarkdowncomment + +/** + * + * This comment should be correctly rendered. + * + * ```scala + * @experimental + * class NotExperimental extends Any + * + * @deprecated + * def commentInSwedish: String = "kommentar" + * ``` + * + * @syntax markdown + */ +class Luokassa diff --git a/scaladoc/src/dotty/tools/scaladoc/snippets/FlexmarkSnippetProcessor.scala b/scaladoc/src/dotty/tools/scaladoc/snippets/FlexmarkSnippetProcessor.scala index eb67e2e1fc2a..0b1bea5df2e9 100644 --- a/scaladoc/src/dotty/tools/scaladoc/snippets/FlexmarkSnippetProcessor.scala +++ b/scaladoc/src/dotty/tools/scaladoc/snippets/FlexmarkSnippetProcessor.scala @@ -48,7 +48,7 @@ object FlexmarkSnippetProcessor: case result => result } - node.insertBefore(new ExtendedFencedCodeBlock(node, snippetCompilationResult)) + node.insertBefore(ExtendedFencedCodeBlock(node, snippetCompilationResult)) node.unlink() } } diff --git a/scaladoc/src/dotty/tools/scaladoc/tasty/comments/CommentRegex.scala b/scaladoc/src/dotty/tools/scaladoc/tasty/comments/CommentRegex.scala index 6b1cd970453e..3ff022198446 100644 --- a/scaladoc/src/dotty/tools/scaladoc/tasty/comments/CommentRegex.scala +++ b/scaladoc/src/dotty/tools/scaladoc/tasty/comments/CommentRegex.scala @@ -75,9 +75,9 @@ object Regexes { /** The start of a Scaladoc code block */ val CodeBlockStartRegex = - new Regex("""(.*?)((?:\{\{\{)|(?:\u000E
]*)?>\u000E))(.*)""") + new Regex("""(.*?)((?:\{\{\{)|(?:```)|(?:\u000E\u000E))(.*)""") } diff --git a/scaladoc/src/dotty/tools/scaladoc/tasty/comments/Preparser.scala b/scaladoc/src/dotty/tools/scaladoc/tasty/comments/Preparser.scala index 7e149f7d4a9a..65ed604d64e3 100644 --- a/scaladoc/src/dotty/tools/scaladoc/tasty/comments/Preparser.scala +++ b/scaladoc/src/dotty/tools/scaladoc/tasty/comments/Preparser.scala @@ -35,11 +35,13 @@ object Preparser { inCodeBlock: Boolean ): PreparsedComment = remaining match { case CodeBlockStartRegex(before, marker, after) :: ls if !inCodeBlock => - if (!before.trim.isEmpty && !after.trim.isEmpty) + if (before.trim.nonEmpty && after.trim.nonEmpty && marker == "```") + go(docBody, tags, lastTagKey, before :: (marker + after) :: ls, inCodeBlock = false) + else if (before.trim.nonEmpty && after.trim.nonEmpty) go(docBody, tags, lastTagKey, before :: marker :: after :: ls, inCodeBlock = false) - else if (!before.trim.isEmpty) + else if (before.trim.nonEmpty) go(docBody, tags, lastTagKey, before :: marker :: ls, inCodeBlock = false) - else if (!after.trim.isEmpty) + else if (after.trim.nonEmpty && marker != "```") go(docBody, tags, lastTagKey, marker :: after :: ls, inCodeBlock = true) else lastTagKey match { case Some(key) => @@ -50,15 +52,15 @@ object Preparser { } go(docBody, tags + (key -> value), lastTagKey, ls, inCodeBlock = true) case None => - go(docBody append endOfLine append marker, tags, lastTagKey, ls, inCodeBlock = true) + go(docBody append endOfLine append (marker + after), tags, lastTagKey, ls, inCodeBlock = true) } case CodeBlockEndRegex(before, marker, after) :: ls => - if (!before.trim.isEmpty && !after.trim.isEmpty) + if (before.trim.nonEmpty && after.trim.nonEmpty) go(docBody, tags, lastTagKey, before :: marker :: after :: ls, inCodeBlock = true) - if (!before.trim.isEmpty) + if (before.trim.nonEmpty) go(docBody, tags, lastTagKey, before :: marker :: ls, inCodeBlock = true) - else if (!after.trim.isEmpty) + else if (after.trim.nonEmpty) go(docBody, tags, lastTagKey, marker :: after :: ls, inCodeBlock = false) else lastTagKey match { case Some(key) =>]*)?>\u000E))(.*)""") /** The end of a Scaladoc code block */ val CodeBlockEndRegex = - new Regex("""(.*?)((?:\}\}\})|(?:\u000E\u000E))(.*)""") + new Regex("""(.*?)((?:\}\}\})|(?:```)|(?:\u000E