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

Ill formated codeblock #13202

Merged
merged 2 commits into from
Jul 29, 2021
Merged
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
17 changes: 17 additions & 0 deletions scaladoc-testcases/src/tests/annotatedmarkdowncomment.scala
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object FlexmarkSnippetProcessor:
case result => result
}

node.insertBefore(new ExtendedFencedCodeBlock(node, snippetCompilationResult))
node.insertBefore(ExtendedFencedCodeBlock(node, snippetCompilationResult))
node.unlink()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ object Regexes {

/** The start of a Scaladoc code block */
val CodeBlockStartRegex =
new Regex("""(.*?)((?:\{\{\{)|(?:\u000E<pre(?: [^>]*)?>\u000E))(.*)""")
new Regex("""(.*?)((?:\{\{\{)|(?:```)|(?:\u000E<pre(?: [^>]*)?>\u000E))(.*)""")

/** The end of a Scaladoc code block */
val CodeBlockEndRegex =
new Regex("""(.*?)((?:\}\}\})|(?:\u000E</pre>\u000E))(.*)""")
new Regex("""(.*?)((?:\}\}\})|(?:```)|(?:\u000E</pre>\u000E))(.*)""")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.isEmpty && !after.trim.isEmpty && marker == "```")
go(docBody, tags, lastTagKey, before :: (marker + after) :: ls, inCodeBlock = false)
else if (!before.trim.isEmpty && !after.trim.isEmpty)
go(docBody, tags, lastTagKey, before :: marker :: after :: ls, inCodeBlock = false)
else if (!before.trim.isEmpty)
go(docBody, tags, lastTagKey, before :: marker :: ls, inCodeBlock = false)
else if (!after.trim.isEmpty)
else if (!after.trim.isEmpty && marker != "```")
go(docBody, tags, lastTagKey, marker :: after :: ls, inCodeBlock = true)
else lastTagKey match {
case Some(key) =>
Expand All @@ -50,7 +52,7 @@ 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 =>
Expand Down