feat: urlのprintを追加

This commit is contained in:
usbharu 2024-11-16 02:31:30 +09:00
parent 5fd15c975b
commit 579343145e
Signed by: usbharu
GPG Key ID: 95CBCF7046307B77
1 changed files with 27 additions and 5 deletions

View File

@ -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 {
data class UrlNode(val url: UrlUrlNode, val urlNameNode: UrlNameNode, val urlTitleNode: UrlTitleNode?) : return "!" + urlUrlNode.print()
InlineNode() }
}
data class UrlUrlNode(val url: String) : InlineNode()
data class UrlTitleNode(val title: String) : InlineNode() data class UrlNode(val url: UrlUrlNode, val urlNameNode: UrlNameNode, val urlTitleNode: UrlTitleNode?) :
data class UrlNameNode(val name: String) : InlineNode() InlineNode() {
override fun print(): String {
return "[${urlNameNode.print()}](${url.print()} ${urlTitleNode?.print().orEmpty()})"
}
}
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
}
}
} }