aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-08-19 20:09:12 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-28 15:37:55 +0200
commitde809e8076b3cde06dc29328298112ed4a7026b3 (patch)
tree8773b5f9d0d148d366cd7f250c268716b156b55d /plugins/base/src/main/kotlin/parsers/MarkdownParser.kt
parente64cb9bfbef093bcc4046a5081393f3c9778b42a (diff)
downloaddokka-de809e8076b3cde06dc29328298112ed4a7026b3.tar.gz
dokka-de809e8076b3cde06dc29328298112ed4a7026b3.tar.bz2
dokka-de809e8076b3cde06dc29328298112ed4a7026b3.zip
Draft for improving code formatting #1346
Diffstat (limited to 'plugins/base/src/main/kotlin/parsers/MarkdownParser.kt')
-rw-r--r--plugins/base/src/main/kotlin/parsers/MarkdownParser.kt13
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt
index 8422d3be..53ab6bde 100644
--- a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt
+++ b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt
@@ -280,11 +280,13 @@ class MarkdownParser(
MarkdownElementTypes.IMAGE -> imagesHandler(node)
MarkdownTokenTypes.HARD_LINE_BREAK -> DocTagsFromIElementFactory.getInstance(node.type)
MarkdownTokenTypes.CODE_FENCE_CONTENT,
- MarkdownTokenTypes.CODE_LINE,
+ MarkdownTokenTypes.CODE_LINE -> DocTagsFromIElementFactory.getInstance(
+ MarkdownTokenTypes.TEXT,
+ body = text.substring(node.startOffset, node.endOffset)
+ )
MarkdownTokenTypes.TEXT -> DocTagsFromIElementFactory.getInstance(
MarkdownTokenTypes.TEXT,
- body = text
- .substring(node.startOffset, node.endOffset).transform()
+ body = text.substring(node.startOffset, node.endOffset).transform()
)
MarkdownElementTypes.MARKDOWN_FILE -> if (node.children.size == 1) visitNode(node.children.first()) else defaultHandler(
node
@@ -339,11 +341,12 @@ class MarkdownParser(
children += this[index]
} else {
val startOffset = this[index].startOffset
+ val type = this[index].type
while (index < this.lastIndex) {
if (this.isNotLeaf(index + 1) || this[index + 1].startOffset != this[index].endOffset) {
val endOffset = this[index].endOffset
if (text.substring(startOffset, endOffset).transform().trim().isNotEmpty())
- children += LeafASTNode(MarkdownTokenTypes.TEXT, startOffset, endOffset)
+ children += LeafASTNode(type, startOffset, endOffset)
break
}
index++
@@ -351,7 +354,7 @@ class MarkdownParser(
if (index == this.lastIndex) {
val endOffset = this[index].endOffset
if (text.substring(startOffset, endOffset).transform().trim().isNotEmpty())
- children += LeafASTNode(MarkdownTokenTypes.TEXT, startOffset, endOffset)
+ children += LeafASTNode(type, startOffset, endOffset)
}
}
index++