Skip to content

A simple syntax highlighter to use with TextView or Compose Text. Supported Kotlin, Java, JavaScript and Python.

Notifications You must be signed in to change notification settings

cinkhangin/glow

Repository files navigation

screenshot

glow

A simple syntax highlighter to use with TextView. Kotlin, Java, JavaScript, and Python are Supported.

Jitpack

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    implementation 'com.naulian:glow:latest_version'
    //kotlin dsl
    implementation("com.naulian:glow:latest_version")
}
val sourceCode = "print('hello')"
val language = "py" //or "python"

val highlighted = glowSyntax(sourceCode, language, CodeTheme.kotlinLight)
//textView.text = highlighted.raw 
textView.setCodeTheme(CodeTheme.kotlinLight.normal)
textView.text = highlighted.spanned

//compose
val annotatedHighLight = Glow.highlight(sourceCode, language, CodeTheme.kotlinLight)
Text(text= annotatedHighLight.value)

About

A simple syntax highlighter to use with TextView or Compose Text. Supported Kotlin, Java, JavaScript and Python.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages