Thistle
Kotlin multiplatform String markup library, inspired by SRML. Thistle is a common parser which produces an AST that can be rendered to a variety of platform-specific UIs.
// Android
val thistle = ThistleParser(AndroidDefaults)
binding.textView.applyStyledText(
thistle,
"This is a {{b}}very important{{/b}}, {{foreground color=#ff0000}}urgent{{/foreground}} message!"
)
// Console
val thistle = ThistleParser(ConsoleDefaults)
binding.textView.applyStyledText(
thistle,
"This is a {{b}}very important{{/b}}, {{red}}urgent{{/red}} message!"
)
Supported Platforms/Features
Platform | Markup Target |
---|---|
Android | android.text.Spannable |
Compose UI | AttributedString (TODO) |
iOS | NSAttributedString (TODO) |
JS | HTML DOM (TODO) |
Any | HTML Text (TODO) |
Any | HTML Console ANSI Sequences |
Installation
repositories {
mavenCentral()
}
// for plain JVM or Android projects
dependencies {
implementation("io.github.copper-leaf:thistle-core:{{site.version}}")
}
// for multiplatform projects
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.copper-leaf:thistle-core:{{site.version}}")
}
}
}
}
Documentation
See the website for detailed documentation and usage instructions.
License
Thistle is licensed under the BSD 3-Clause License, see LICENSE.md.