diff options
| author | Dmitry Jemerov <yole@jetbrains.com> | 2016-07-06 14:39:31 +0200 |
|---|---|---|
| committer | Dmitry Jemerov <yole@jetbrains.com> | 2016-07-06 14:39:31 +0200 |
| commit | 0f65cf0e4ce531715b76ac32a36a3dff488b2d70 (patch) | |
| tree | 3682da97a5a1eb105f6319a0afc141af4a4fa6a1 /core/src/main/kotlin/Kotlin | |
| parent | b5367f295be47f2f6ad26f113d80362102b6c36d (diff) | |
| download | dokka-0f65cf0e4ce531715b76ac32a36a3dff488b2d70.tar.gz dokka-0f65cf0e4ce531715b76ac32a36a3dff488b2d70.tar.bz2 dokka-0f65cf0e4ce531715b76ac32a36a3dff488b2d70.zip | |
handle code blocks escaped with multiple backticks correctly; generate extra backticks if text in code block contains backticks (KT-12998, KT-12999)
Diffstat (limited to 'core/src/main/kotlin/Kotlin')
| -rw-r--r-- | core/src/main/kotlin/Kotlin/ContentBuilder.kt | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/src/main/kotlin/Kotlin/ContentBuilder.kt b/core/src/main/kotlin/Kotlin/ContentBuilder.kt index c16b19c5..7bee6936 100644 --- a/core/src/main/kotlin/Kotlin/ContentBuilder.kt +++ b/core/src/main/kotlin/Kotlin/ContentBuilder.kt @@ -43,7 +43,12 @@ fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (Stri MarkdownElementTypes.EMPH -> appendNodeWithChildren(ContentEmphasis()) MarkdownElementTypes.STRONG -> appendNodeWithChildren(ContentStrong()) MarkdownElementTypes.CODE_SPAN -> { - appendNodeWithChildren(ContentCode()) + val startDelimiter = node.child(MarkdownTokenTypes.BACKTICK)?.text + if (startDelimiter != null) { + val text = node.text.substring(startDelimiter.length).removeSuffix(startDelimiter) + val codeSpan = ContentCode().apply { append(ContentText(text)) } + parent.append(codeSpan) + } } MarkdownElementTypes.CODE_BLOCK, MarkdownElementTypes.CODE_FENCE -> appendNodeWithChildren(ContentBlockCode()) @@ -126,6 +131,7 @@ fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: (Stri MarkdownTokenTypes.LBRACKET, MarkdownTokenTypes.RBRACKET, MarkdownTokenTypes.EXCLAMATION_MARK, + MarkdownTokenTypes.BACKTICK, MarkdownTokenTypes.CODE_FENCE_CONTENT -> { parent.append(ContentText(node.text)) } |
