From a11a8dd92fcccff770d6893f27c3546fef17655d Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Sun, 19 Jun 2022 17:29:45 +0200 Subject: Dont escape text inside gfm code blocks (#2541) --- .../org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'plugins/gfm/src/main') 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().forEach { append(it.text) } append("`") } -- cgit