aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSimon Ogorodnik <sem-oro@yandex.ru>2016-11-08 21:32:00 +0300
committerGitHub <noreply@github.com>2016-11-08 21:32:00 +0300
commit32cfff6d3dcb099e891e56b969c3c561d8fd9769 (patch)
tree7d7f47715c8e99c0427369ee3747bf35e41f7216 /core
parent15f76be0f994e2ebc13b1c461334ec9c84821cca (diff)
downloaddokka-32cfff6d3dcb099e891e56b969c3c561d8fd9769.tar.gz
dokka-32cfff6d3dcb099e891e56b969c3c561d8fd9769.tar.bz2
dokka-32cfff6d3dcb099e891e56b969c3c561d8fd9769.zip
Fix for KT-14603 Do not escape html inside code blocks in markdown (#112)
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
-++++++++++[&gt;+++++++&gt;++++++++++&gt;+++&gt;+&lt;&lt;&lt;&lt;-]&gt;++.&gt;+.+++++++..+++.&gt;++.&lt;&lt;+++++++++++++++.&gt;.+++.------.--------.&gt;+.&gt;.
+++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
```
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>
+```
+