From 579343145e879f48aad8eed3e8ffa6b4194f24f1 Mon Sep 17 00:00:00 2001 From: usbharu Date: Sat, 16 Nov 2024 02:31:30 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20url=E3=81=AEprint=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/dev/usbharu/markdown/AstNode.kt | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/library/src/commonMain/kotlin/dev/usbharu/markdown/AstNode.kt b/library/src/commonMain/kotlin/dev/usbharu/markdown/AstNode.kt index 9b107fd..f834e96 100644 --- a/library/src/commonMain/kotlin/dev/usbharu/markdown/AstNode.kt +++ b/library/src/commonMain/kotlin/dev/usbharu/markdown/AstNode.kt @@ -76,13 +76,35 @@ sealed class AstNode { } } - data class ImageNode(val urlUrlNode: UrlNode) : InlineNode() + data class ImageNode(val urlUrlNode: UrlNode) : InlineNode() { + override fun print(): String { + return "!" + urlUrlNode.print() + } + } data class UrlNode(val url: UrlUrlNode, val urlNameNode: UrlNameNode, val urlTitleNode: UrlTitleNode?) : - InlineNode() + InlineNode() { + override fun print(): String { + return "[${urlNameNode.print()}](${url.print()} ${urlTitleNode?.print().orEmpty()})" + } + } - data class UrlUrlNode(val url: String) : InlineNode() - data class UrlTitleNode(val title: String) : InlineNode() - data class UrlNameNode(val name: String) : InlineNode() + data class UrlUrlNode(val url: String) : InlineNode() { + override fun print(): String { + return url + } + } + + data class UrlTitleNode(val title: String) : InlineNode() { + override fun print(): String { + return "\"$title\"" + } + } + + data class UrlNameNode(val name: String) : InlineNode() { + override fun print(): String { + return name + } + } }