From b78e3bb6c7d689bc1650088096461e687ee6441f Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 6 Feb 2015 16:41:39 +0100 Subject: handle code spans in markdown --- src/Kotlin/ContentBuilder.kt | 7 ++++++- test/data/format/codeSpan.html | 13 +++++++++++++ test/data/format/codeSpan.kt | 4 ++++ test/src/format/HtmlFormatTest.kt | 6 ++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 test/data/format/codeSpan.html create mode 100644 test/data/format/codeSpan.kt diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt index b5647ff0..80d49a85 100644 --- a/src/Kotlin/ContentBuilder.kt +++ b/src/Kotlin/ContentBuilder.kt @@ -49,11 +49,16 @@ public fun DocumentationBuilder.buildContentTo(tree: MarkdownNode, target: Conte processChildren() parent.append(nodeStack.pop()) } - MarkdownTokenTypes.CODE -> { + MarkdownElementTypes.CODE_SPAN -> { nodeStack.push(ContentCode()) processChildren() parent.append(nodeStack.pop()) } + MarkdownElementTypes.CODE_BLOCK -> { + nodeStack.push(ContentBlockCode()) + processChildren() + parent.append(nodeStack.pop()) + } MarkdownElementTypes.INLINE_LINK -> { val label = node.child(MarkdownElementTypes.LINK_TEXT)?.child(MarkdownTokenTypes.TEXT) val destination = node.child(MarkdownElementTypes.LINK_DESTINATION) diff --git a/test/data/format/codeSpan.html b/test/data/format/codeSpan.html new file mode 100644 index 00000000..37bb62f0 --- /dev/null +++ b/test/data/format/codeSpan.html @@ -0,0 +1,13 @@ + + +test / foo + + +test /  / foo
+
+

foo

+
fun foo(): Unit

This is a code span.

+
+
+ + diff --git a/test/data/format/codeSpan.kt b/test/data/format/codeSpan.kt new file mode 100644 index 00000000..645f454a --- /dev/null +++ b/test/data/format/codeSpan.kt @@ -0,0 +1,4 @@ +/** + * This is a `code span`. + */ +fun foo() {} \ No newline at end of file diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt index dfecb4d4..0170d148 100644 --- a/test/src/format/HtmlFormatTest.kt +++ b/test/src/format/HtmlFormatTest.kt @@ -39,4 +39,10 @@ public class HtmlFormatTest { htmlService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun codeSpan() { + verifyOutput("test/data/format/codeSpan.kt", ".html") { model, output -> + htmlService.appendNodes(tempLocation, output, model.members.single().members) + } + } } -- cgit