From 32cfff6d3dcb099e891e56b969c3c561d8fd9769 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 8 Nov 2016 21:32:00 +0300 Subject: Fix for KT-14603 Do not escape html inside code blocks in markdown (#112) --- core/src/main/kotlin/Formats/MarkdownFormatService.kt | 2 ++ core/src/test/kotlin/format/MarkdownFormatTest.kt | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'core/src') diff --git a/core/src/main/kotlin/Formats/MarkdownFormatService.kt b/core/src/main/kotlin/Formats/MarkdownFormatService.kt index 794deedd..fc63b2f2 100644 --- a/core/src/main/kotlin/Formats/MarkdownFormatService.kt +++ b/core/src/main/kotlin/Formats/MarkdownFormatService.kt @@ -164,12 +164,14 @@ open class MarkdownOutputBuilder(to: StringBuilder, } override fun appendBlockCode(language: String, body: () -> Unit) { + inCodeBlock = true ensureParagraph() to.appendln(if (language.isEmpty()) "```" else "``` $language") body() ensureNewline() to.appendln("```") appendLine() + inCodeBlock = false } override fun appendTable(vararg columns: String, body: () -> Unit) { diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index 1dfffbff..7f0922ba 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -135,6 +135,10 @@ class MarkdownFormatTest { } } + @Test fun codeBlockNoHtmlEscape() { + verifyMarkdownNodeByName("codeBlockNoHtmlEscape", "hackTheArithmetic") + } + @Test fun companionObjectExtension() { verifyMarkdownNodeByName("companionObjectExtension", "Foo") } -- cgit