aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Formats/MarkdownFormatService.kt2
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt4
-rw-r--r--core/testdata/format/codeBlock.md2
-rw-r--r--core/testdata/format/codeBlockNoHtmlEscape.kt15
-rw-r--r--core/testdata/format/codeBlockNoHtmlEscape.md18
5 files changed, 40 insertions, 1 deletions
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")
}
diff --git a/core/testdata/format/codeBlock.md b/core/testdata/format/codeBlock.md
index 55a054f6..d64fb9fd 100644
--- a/core/testdata/format/codeBlock.md
+++ b/core/testdata/format/codeBlock.md
@@ -22,6 +22,6 @@ fun readFile(name: String): String {...}
Check output of
``` brainfuck
-++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
+++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
```
diff --git a/core/testdata/format/codeBlockNoHtmlEscape.kt b/core/testdata/format/codeBlockNoHtmlEscape.kt
new file mode 100644
index 00000000..5f48b39c
--- /dev/null
+++ b/core/testdata/format/codeBlockNoHtmlEscape.kt
@@ -0,0 +1,15 @@
+/**
+ * Try to make this check pass
+ * ```
+ * if(1 > 2)
+ * ```
+ * Or just piece of html
+ * ```
+ * <p>1 = 3</p>
+ * ```
+ */
+fun hackTheArithmetic(){
+ valueOf(1) {
+ set(3)
+ }
+} \ No newline at end of file
diff --git a/core/testdata/format/codeBlockNoHtmlEscape.md b/core/testdata/format/codeBlockNoHtmlEscape.md
new file mode 100644
index 00000000..2622ef38
--- /dev/null
+++ b/core/testdata/format/codeBlockNoHtmlEscape.md
@@ -0,0 +1,18 @@
+[test](test/index) / [hackTheArithmetic](test/hack-the-arithmetic)
+
+# hackTheArithmetic
+
+`fun hackTheArithmetic(): Unit`
+
+Try to make this check pass
+
+```
+if(1 > 2)
+```
+
+Or just piece of html
+
+```
+<p>1 = 3</p>
+```
+