aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Markdown
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2017-02-24 14:44:55 +0100
committerDmitry Jemerov <yole@jetbrains.com>2017-02-24 14:44:55 +0100
commit0f9dac9ea2137fe5935566d84cb2f5264be1a8ba (patch)
tree1064587501fb4e6bad5f4542ddcabfbb31f99749 /core/src/main/kotlin/Markdown
parent004fc0c4eaf9d1ecaa78cf97f7d0fb2e91405031 (diff)
parent2ceff9c41cff42b7fb3ffe75ea36a7c570f3615b (diff)
downloaddokka-0f9dac9ea2137fe5935566d84cb2f5264be1a8ba.tar.gz
dokka-0f9dac9ea2137fe5935566d84cb2f5264be1a8ba.tar.bz2
dokka-0f9dac9ea2137fe5935566d84cb2f5264be1a8ba.zip
Merge remote-tracking branch 'origin/0.9.14/BlankLines'
# Conflicts: # core/src/test/kotlin/format/HtmlFormatTest.kt # core/src/test/kotlin/format/MarkdownFormatTest.kt
Diffstat (limited to 'core/src/main/kotlin/Markdown')
-rw-r--r--core/src/main/kotlin/Markdown/MarkdownProcessor.kt5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/src/main/kotlin/Markdown/MarkdownProcessor.kt b/core/src/main/kotlin/Markdown/MarkdownProcessor.kt
index 46b72c03..d1d40dd4 100644
--- a/core/src/main/kotlin/Markdown/MarkdownProcessor.kt
+++ b/core/src/main/kotlin/Markdown/MarkdownProcessor.kt
@@ -4,13 +4,14 @@ import org.intellij.markdown.IElementType
import org.intellij.markdown.MarkdownElementTypes
import org.intellij.markdown.ast.ASTNode
import org.intellij.markdown.ast.LeafASTNode
+import org.intellij.markdown.ast.getTextInNode
import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor
import org.intellij.markdown.parser.MarkdownParser
class MarkdownNode(val node: ASTNode, val parent: MarkdownNode?, val markdown: String) {
val children: List<MarkdownNode> = node.children.map { MarkdownNode(it, this, markdown) }
val type: IElementType get() = node.type
- val text: String get() = markdown.substring(node.startOffset, node.endOffset)
+ val text: String get() = node.getTextInNode(markdown).toString()
fun child(type: IElementType): MarkdownNode? = children.firstOrNull { it.type == type }
override fun toString(): String = StringBuilder().apply { presentTo(this) }.toString()
@@ -30,6 +31,7 @@ fun MarkdownNode.toTestString(): String {
visit { node, visitChildren ->
sb.append(" ".repeat(level * 2))
node.presentTo(sb)
+ sb.appendln()
level++
visitChildren()
level--
@@ -40,7 +42,6 @@ fun MarkdownNode.toTestString(): String {
private fun MarkdownNode.presentTo(sb: StringBuilder) {
sb.append(type.toString())
sb.append(":" + text.replace("\n", "\u23CE"))
- sb.appendln()
}
fun parseMarkdown(markdown: String): MarkdownNode {