diff --git a/build.gradle.kts b/build.gradle.kts index 8125cba..31521aa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,7 +23,7 @@ plugins { } val groupId = "com.theonlytails" -val libVersion = "0.1.5" +val libVersion = "0.1.6" group = groupId version = libVersion diff --git a/src/main/kotlin/com/theonlytails/ketex/groups.kt b/src/main/kotlin/com/theonlytails/ketex/groups.kt index 000e624..f666085 100644 --- a/src/main/kotlin/com/theonlytails/ketex/groups.kt +++ b/src/main/kotlin/com/theonlytails/ketex/groups.kt @@ -78,9 +78,33 @@ class KetexGroup(private val type: KetexGroupType, private val name: String) : K } context(KetexFragment) - @KetexMarker - inline fun group( +@KetexMarker +inline fun group( type: KetexGroupType = KetexGroupType.Capture, name: String = "", block: KetexGroup.() -> Unit, -) = KetexGroup(type, name).apply(block) \ No newline at end of file +) = KetexGroup(type, name).apply(block) + +context(KetexFragment) +@KetexMarker +fun group(vararg tokens: String) = group { + tokens.forEach { +it } +} + +context(KetexFragment) +@KetexMarker +fun group(vararg tokens: Char) = group { + tokens.forEach { +it } +} + +context(KetexFragment) +@KetexMarker +fun group(vararg tokens: CharRange) = group { + tokens.forEach { +it } +} + +context(KetexFragment) +@KetexMarker +fun group(vararg tokens: KetexToken) = group { + tokens.forEach { +it } +} diff --git a/src/test/kotlin/KetexTest.kt b/src/test/kotlin/KetexTest.kt index 2aa6a20..dab3b6a 100644 --- a/src/test/kotlin/KetexTest.kt +++ b/src/test/kotlin/KetexTest.kt @@ -325,4 +325,13 @@ class KetexTest { } ) } + + @Test + fun `group with vararg`() { + assertEquals("""(abc)""", + regexAsString { + +group("abc") + } + ) + } }