diff options
-rw-r--r-- | src/Kotlin/ContentBuilder.kt | 19 | ||||
-rw-r--r-- | test/data/format/htmlEscaping.html | 12 | ||||
-rw-r--r-- | test/data/format/htmlEscaping.kt | 4 | ||||
-rw-r--r-- | test/src/format/HtmlFormatTest.kt | 6 |
4 files changed, 40 insertions, 1 deletions
diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt index 0c82a522..0143feed 100644 --- a/src/Kotlin/ContentBuilder.kt +++ b/src/Kotlin/ContentBuilder.kt @@ -101,6 +101,17 @@ public fun DocumentationBuilder.buildContent(tree: MarkdownNode, descriptor: Dec processChildren() parent.append(nodeStack.pop()) } + MarkdownTokenTypes.COLON -> { + // TODO fix markdown parser + if (!isColonAfterSectionLabel(node)) { + parent.append(ContentText(node.text)) + } + } + MarkdownTokenTypes.DOUBLE_QUOTE, + MarkdownTokenTypes.LT, + MarkdownTokenTypes.GT -> { + parent.append(ContentText(node.text)) + } else -> { processChildren() } @@ -147,4 +158,10 @@ private fun DocumentationBuilder.resolveInScope(functionName: String, scope: Jet } return symbol -}
\ No newline at end of file +} + +private fun isColonAfterSectionLabel(node: MarkdownNode): Boolean { + val parent = node.parent + return parent != null && parent.type == MarkdownElementTypes.SECTION && parent.children.size() >= 2 && + node == parent.children[1]; +} diff --git a/test/data/format/htmlEscaping.html b/test/data/format/htmlEscaping.html new file mode 100644 index 00000000..4f1409c4 --- /dev/null +++ b/test/data/format/htmlEscaping.html @@ -0,0 +1,12 @@ +<HTML> +<HEAD> +</HEAD> +<BODY> +<a href="out.html">test</a> / <a href="out.html"></a> / <a href="out.html">x</a><br/> +<br/> +<h1>x</h1> +<pre><code><span class="keyword">fun </span><span class="symbol"><</span><span class="identifier">T</span><span class="symbol">> </span><span class="identifier">x</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">T?</span></code></pre><p>Special characters: < is "less than", > is "greater than", & is "ampersand"</p> +<br/> +<br/> +</BODY> +</HTML> diff --git a/test/data/format/htmlEscaping.kt b/test/data/format/htmlEscaping.kt new file mode 100644 index 00000000..8778d8a5 --- /dev/null +++ b/test/data/format/htmlEscaping.kt @@ -0,0 +1,4 @@ +/** + * Special characters: < is "less than", > is "greater than", & is "ampersand" + */ +fun x<T>(): T? = null diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt index 758c6e7b..a47b5774 100644 --- a/test/src/format/HtmlFormatTest.kt +++ b/test/src/format/HtmlFormatTest.kt @@ -12,4 +12,10 @@ public class HtmlFormatTest { htmlService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun htmlEscaping() { + verifyOutput("test/data/format/htmlEscaping.kt", ".html") { model, output -> + htmlService.appendNodes(tempLocation, output, model.members.single().members) + } + } } |