diff --git a/pom.xml b/pom.xml index d101620..552549f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ ru.spbstu kotlin-pandoc - 0.0.10-SNAPSHOT + 0.0.11-SNAPSHOT https://github.com/belyaev-mikhail/kotlin-pandoc scm:git:git@github.com:belyaev-mikhail/kotlin-pandoc.git @@ -12,7 +12,7 @@ - 1.3.61 + 1.3.72 2.10.2 diff --git a/src/main/kotlin/ru/spbstu/pandoc/builder/BlockBuilder.kt b/src/main/kotlin/ru/spbstu/pandoc/builder/BlockBuilder.kt index 9f92001..a74017b 100644 --- a/src/main/kotlin/ru/spbstu/pandoc/builder/BlockBuilder.kt +++ b/src/main/kotlin/ru/spbstu/pandoc/builder/BlockBuilder.kt @@ -12,6 +12,10 @@ sealed class BlockBuilderBase { private val list: MutableList = mutableListOf() fun build(): List = list + operator fun Block.unaryPlus() { list.add(this) } + operator fun Iterable.unaryPlus() { list.addAll(this) } + operator fun Sequence.unaryPlus() { list.addAll(this) } + fun plain(body: InlineBuilder.() -> Unit) { list += Block.Plain(inlines(body)) } @@ -90,3 +94,5 @@ fun blocks(body: BlockBuilder.() -> Unit): List { builder.body() return builder.build() } + +fun block(body: BlockBuilder.() -> Unit): Block = blocks(body).single() diff --git a/src/main/kotlin/ru/spbstu/pandoc/builder/InlineBuilder.kt b/src/main/kotlin/ru/spbstu/pandoc/builder/InlineBuilder.kt index 075d0ca..6fce014 100644 --- a/src/main/kotlin/ru/spbstu/pandoc/builder/InlineBuilder.kt +++ b/src/main/kotlin/ru/spbstu/pandoc/builder/InlineBuilder.kt @@ -12,6 +12,9 @@ sealed class InlineBuilderBase { operator fun String.unaryPlus() { list += Inline.Str(this) } + operator fun Inline.unaryPlus() { list.add(this) } + operator fun Iterable.unaryPlus() { list.addAll(this) } + operator fun Sequence.unaryPlus() { list.addAll(this) } fun str(text: () -> String) { list += Inline.Str(text()) @@ -89,3 +92,5 @@ fun inlines(body: InlineBuilder.() -> Unit): List { builder.body() return builder.build() } + +fun inline(body: InlineBuilder.() -> Unit): Inline = inlines(body).single()