Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gerardpaligot/kighlighter
Simple and extendable code highlighter in Kotlin Multiplatform
https://github.com/gerardpaligot/kighlighter
compose highlighter kmp kotlin multiplatform
Last synced: about 2 months ago
JSON representation
Simple and extendable code highlighter in Kotlin Multiplatform
- Host: GitHub
- URL: https://github.com/gerardpaligot/kighlighter
- Owner: GerardPaligot
- Created: 2021-09-03T21:11:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-18T22:08:39.000Z (over 3 years ago)
- Last Synced: 2024-10-11T11:31:15.349Z (2 months ago)
- Topics: compose, highlighter, kmp, kotlin, multiplatform
- Language: Kotlin
- Homepage:
- Size: 423 KB
- Stars: 22
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kighlighter
Simple and extendable code highlighter in Kotlin Multiplatform with
a composable output to display the code highlighted on Android and
Desktop.## Usage
```kotlin
Kighlighter(
snippet = yourCode,
language = Kotlin(palette = Palettes.Darcula),
modifier = Modifier.height(300.dp)
)
```## Customization
### ColorScheme
If you don't like any palettes provided by the library, you can create
your own palette, the color scheme of the supported language and provide
the palette when you create the language object.When you create your palette object, add the sealed interface as interface
of your own palette.When you create your color scheme value class, add the language color scheme
interface of your own color scheme (e.g. `KotlinColorScheme`).Finally, you can give your palette in the language class:
```kotlin
Kotlin(palette = YourOwnPalette)
```## Download
Release artifacts aren't available yet but if you want to test latest changes merge
in `main` branch, you can test snapshot artifacts.```kotlin
repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}// Android artifact
implementation("com.paligot.kighlighter:kighlighter-compose:1.0.0-SNAPSHOT")
// Desktop artifact
implementation("com.paligot.kighlighter:kighlighter-compose-desktop:1.0.0-SNAPSHOT")
```## License
Copyright 2021 Gérard Paligot.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.