diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-06-19 17:29:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-19 17:29:45 +0200 |
commit | a11a8dd92fcccff770d6893f27c3546fef17655d (patch) | |
tree | ada6954c06a5050e1b4785c39e279bcc60053bf0 /plugins/gfm/src/main | |
parent | 9f67dcf75d3b86fa6e4e352d2cebc4f9e17b8048 (diff) | |
download | dokka-a11a8dd92fcccff770d6893f27c3546fef17655d.tar.gz dokka-a11a8dd92fcccff770d6893f27c3546fef17655d.tar.bz2 dokka-a11a8dd92fcccff770d6893f27c3546fef17655d.zip |
Dont escape text inside gfm code blocks (#2541)
Diffstat (limited to 'plugins/gfm/src/main')
-rw-r--r-- | plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt index d192b9a6..a1853899 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt @@ -315,7 +315,17 @@ open class CommonmarkRenderer( append("```") append(code.language.ifEmpty { "kotlin" }) buildNewLine() - code.children.forEach { it.build(this, pageContext) } + code.children.forEach { + if (it is ContentText) { + // since this is a code block where text will be rendered as is, + // no need to escape text, apply styles, etc. Just need the plain value + append(it.text) + } else if (it is ContentBreakLine) { + // since this is a code block where text will be rendered as is, + // there's no need to add tailing slash for line breaks + buildNewLine() + } + } buildNewLine() append("```") buildNewLine() @@ -323,7 +333,7 @@ open class CommonmarkRenderer( override fun StringBuilder.buildCodeInline(code: ContentCodeInline, pageContext: ContentPage) { append("`") - code.children.forEach { it.build(this, pageContext) } + code.children.filterIsInstance<ContentText>().forEach { append(it.text) } append("`") } |