An open API service indexing awesome lists of open source software.

https://github.com/deanalvero/jsx-parser

A Kotlin Multiplatform library for parsing JSX syntax into a type-safe Abstract Syntax Tree (AST). It is available for iOS, Android, Desktop, and Web.
https://github.com/deanalvero/jsx-parser

jsx jsx-parser kmp kmp-library kotlin kotlin-library kotlin-multiplatform kotlin-native

Last synced: 30 days ago
JSON representation

A Kotlin Multiplatform library for parsing JSX syntax into a type-safe Abstract Syntax Tree (AST). It is available for iOS, Android, Desktop, and Web.

Awesome Lists containing this project

README

          

# JSX Parser for Kotlin

A lightweight, zero-dependency, pure Kotlin Multiplatform library for parsing JSX syntax into a type-safe Abstract Syntax Tree (AST).

This parser is written 100% in `commonMain` and works on all Kotlin targets (JVM, JS, Native, Wasm).

Try out the WASM build of the sample app at https://deanalvero.github.io/jsx-parser/.

## Dependency
Add the dependency to your build.gradle. Replace version with what is available [here](https://central.sonatype.com/artifact/io.github.deanalvero/jsx-parser/versions).
```
implementation("io.github.deanalvero:jsx-parser:")
```

## Usage
```
import io.github.deanalvero.parser.jsx.JsxParser

fun main() {
val source = """


Hello, World!


{message}



""".trimIndent()

val result = JsxParser.parse(source)
result.onSuccess { nodes ->
println("Parsed AST: $nodes")
}.onFailure { error ->
println("Parse error: ${error.message}")
}
}
```

## Notes
Enjoy!