From 315e2c7a56450eb24a5d5e4e526c36ead8d10965 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Mon, 14 Sep 2020 11:51:30 +0200 Subject: Fix parsing strikethrough --- .../base/src/main/kotlin/parsers/MarkdownParser.kt | 4 ++-- plugins/base/src/test/kotlin/markdown/ParserTest.kt | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt index a74f2b05..3fc570a0 100644 --- a/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt +++ b/plugins/base/src/main/kotlin/parsers/MarkdownParser.kt @@ -222,8 +222,8 @@ class MarkdownParser( defaultHandler(node) private fun strikeThroughHandler(node: ASTNode) = DocTagsFromIElementFactory.getInstance( - GFMElementTypes.STRIKETHROUGH, - body = text.substring(node.startOffset, node.endOffset).transform() + node.type, + children = node.children.evaluateChildrenWithDroppedEnclosingTokens(2) ) private fun tableHandler(node: ASTNode) = DocTagsFromIElementFactory.getInstance( diff --git a/plugins/base/src/test/kotlin/markdown/ParserTest.kt b/plugins/base/src/test/kotlin/markdown/ParserTest.kt index 268af405..c25678d4 100644 --- a/plugins/base/src/test/kotlin/markdown/ParserTest.kt +++ b/plugins/base/src/test/kotlin/markdown/ParserTest.kt @@ -1307,5 +1307,25 @@ class ParserTest : KDocTest() { ) executeTest(kdoc, expectedDocumentationNode) } + + @Test + fun `Text with Strikethrough`() { + val kdoc = """ + | This is ~~strikethroughed~~ + """.trimMargin() + val expectedDocumentationNode = DocumentationNode( + listOf( + Description( + P( + listOf( + Text("This is "), + Strikethrough(listOf(Text("strikethroughed"))) + ) + ) + ) + ) + ) + executeTest(kdoc, expectedDocumentationNode) + } } -- cgit