Kotlin Multiplatform String markup library

Overview

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.

GitHub release (latest by date) Maven Central Kotlin Version

// 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!"
)

sample_app View sample app source

sample_console

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.

References

You might also like...
Simple and extendable code highlighter in Kotlin Multiplatform

Kighlighter Simple and extendable code highlighter in Kotlin Multiplatform with a composable output to display the code highlighted on Android and Des

Compile-time dependency injection for Kotlin Multiplatform

Kinzhal Kinzhal is a Kotlin Multiplatform library for compile-time dependency injection. The goal is to emulate basic features of Dagger to achieve si

A simple MVI framework for Kotlin Multiplatform and Android
A simple MVI framework for Kotlin Multiplatform and Android

Orbit Multiplatform Get in touch What is Orbit Orbit is a Redux/MVI-like library - but without the baggage. It's so simple we think of it as MVVM+. Si

Create libraries for all types of Kotlin projects: android, JVM, Multiplatform, Gradle plugins, and so on.

JavierSC Kotlin template Create libraries for all types of Kotlin projects: android, JVM, Multiplatform, Gradle plugins, and so on. Features Easy to p

Kotlin Multiplatform + Pizza = <3
Kotlin Multiplatform + Pizza = 3

KMPizza This repository accompanies a series of blog posts on the process of building an app with Kotlin Multiplatform. What is Kotlin Multiplatform?

HelloKMM - Hello World in Kotlin Multiplatform Mobile (new empty project)
HelloKMM - Hello World in Kotlin Multiplatform Mobile (new empty project)

Hello KMM! Hello World in Kotlin Multiplatform Mobile (new empty project) Gettin

A clean OpenAPI client generator for Kotlin multiplatform

kotlin-openapi-generator A not yet feature complete client generator. Features: generates 100% Kotlin multiplatform code does not generate any useless

A starter project to build command-line tools in Kotlin Multiplatform
A starter project to build command-line tools in Kotlin Multiplatform

A starter project to build command-line tools in Kotlin Multiplatform Contains a re-implementation of a real world CLI tool: git-standup Installation

Multiplatform HTTP-Client implementation using Ktor

Kotlin Multiplatform HTTP-Client using Ktor Simple demonstration of a Ktor-based multiplatform HTTP-client in Kotlin Overview base submodule: common c

Comments
  • Enable self-closing tags

    Enable self-closing tags

    Allow tags to be self-closing, for implementing tags that need tag args but not any inner content. Include a mechanism for tags to configure themselves to allow/forbid/require self-closing tags

    opened by cjbrooks12 0
  • Markdown and HTML widgets

    Markdown and HTML widgets

    Create out-of-the-box parsers for handling basic HTML and Markdown content, especially for Compose. Other platforms have their own mechanisms for handling such input text, but Compose doesn't have anything natively.

    Alternatively, create an out-of-the-box Syntax for HTML or Markdown that can be installed into any parser. Would be nice to have #6 done so that this Syntax can reference the common tags for building itself

    opened by cjbrooks12 0
  • [maybe?] Create a common set of tags to aid in template compatibility between renderers

    [maybe?] Create a common set of tags to aid in template compatibility between renderers

    Currently, each renderer has its own completely separate set of tags. Thus, a given input string is tightly coupled to the formats/tags/parameters available on its own parser/renderer, and there's really no guarantee that any given string will be able to be used across multiple renderers.

    There should be some way to enforce a common API across a minimal set of tags (such as {{foreground}}) so that there exists at lease some compatibility across renderers. Having at least some tags that will always be able to be used from purely common code will help make it more intuitive, and avoid having to duplicating input strings to match the paramters/tag names available for a given renderer.

    opened by cjbrooks12 0
Releases(4.0.1)
  • 4.0.1(Dec 7, 2022)

    • Fix an issue where thistle-android and thistle-compose-ui artifacts both generated the same Android BuildConfig class, causing an issue when both libraries are used in the same app.
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0(Oct 21, 2022)

  • 3.1.0(Mar 4, 2022)

    • Updates Kotlin version to 1.6.10
    • Enables ExplicitApi and BinaryCompatibilityValidator on the repo, to improve the stability of its API
    • [thistle-compose-ui] Adds a noLinkClickedHandler callback to StyledText, to help propagate clicks that do not fall onto clickable regions of text.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.2(Dec 7, 2021)

  • 2.0.1(Dec 6, 2021)

  • 2.0.0(Dec 3, 2021)

    • Adds Compose target
    • Splits Android and Console targets into separate artifacts
    • Other minor refactoring of core APIs (some class names/packages may be slightly different)
    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Jul 15, 2021)

    • Make tag names dynamic and checked against configured tags to ensure no tag is left unparsed, and undeclared tags throw and error
    • Renames a couple classes to prevent ambiguity:
      • ThistleTag is now ThistleTagFactory
      • ThistleTagBuilder is now ThistleTagConfiguration
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Jul 14, 2021)

    • Rewrites Console renderer builder to use an intermediary tree structure to collect nested ASNI codes, rather than managing a local stack. This allows the tags for the console to have access to their own content during creation, like with the Android renderer.
    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Jul 13, 2021)

    • Refactors AndroidThistleRenderer so that creating the actual Spans happens after recursion, to allow access to their nested content and the View's Context when creating the Span.
    • Changes signature of ThistleTag to accept a generic ThistleRenderContext instead of the context and args as separate parameters. This requires the parsing and rendering context to match by the renderer's specific RenderContext implementation and provide additional information for that render target.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(May 17, 2021)

  • 1.0.0(May 13, 2021)

  • 0.1.0(May 11, 2021)

Owner
Copper Leaf
Supplemental utility libraries for Orchid and Kotlin
Copper Leaf
FizzBuzzKotlin - A function fizzBuzz to generate a list of string based on the input number

FizzBuzzKotlin write a function fizzBuzz to generate a list of string based on t

gson 0 Feb 12, 2022
FlowExt is a Kotlin Multiplatform library, that provides many operators and extensions to Kotlin Coroutines Flow

FlowExt | Kotlinx Coroutines Flow Extensions | Kotlinx Coroutines Flow Extensions. Extensions to the Kotlin Flow library | kotlin-flow-extensions | Coroutines Flow Extensions | Kotlin Flow extensions | kotlin flow extensions | Flow extensions

Petrus Nguyễn Thái Học 151 Jan 1, 2023
Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP)

Mockative Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP). Installation Mockative uses KSP to generate

Mockative 121 Dec 26, 2022
This Kotlin Multiplatform library is for accessing the TMDB API to get movie and TV show content. Using for Android, iOS, and JS projects.

Website | Forum | Documentation | TMDb 3 API Get movie and TV show content from TMDb in a fast and simple way. TMDb API This library gives access to T

Moviebase 37 Dec 29, 2022
Integration Testing Kotlin Multiplatform Kata for Kotlin Developers. The main goal is to practice integration testing using Ktor and Ktor Client Mock

This kata is a Kotlin multiplatform version of the kata KataTODOApiClientKotlin of Karumi. We are here to practice integration testing using HTTP stub

Jorge Sánchez Fernández 29 Oct 3, 2022
Kotlin-phoenix - A set of tools aimed to bridge Phoenix with the Kotlin Multiplatform world

Kotlin Phoenix This project is aimed to allow developers to work with Phoenix Ch

Adrien Jacquier Bret 5 Sep 21, 2022
MMKV for Kotlin Multiplatform is a wrapper for MMKV using Kotlin API

MMKV for Kotlin Multiplatform is a wrapper for MMKV using Kotlin API

Ctrip, Inc. 65 Dec 29, 2022
Mobile client for official Nextcloud News App written as Kotlin Multiplatform Project

Newsout Android and iOS mobile client for Nextcloud news App. The Android client is already available to download in the Play Store. F-Droid and Apple

Simon Schubert 118 Oct 3, 2022
KMMT : Kotlin Multiplatform Mobile Template

Kotlin Multiplatform Mobile App Template

Jitty Andiyan 206 Dec 22, 2022
SSU u-saint parser with Kotlin-Multiplatform and Ktor.

kusaint Soongsil University(SSU) u-Saint Parser with Kotlin Multiplatform. Prerequisites JVM !!IMPORTANT!! To run kusaint as a library in JVM environm

Hyomin Koo 3 Mar 23, 2022