Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 1.11 KB

README.md

File metadata and controls

46 lines (37 loc) · 1.11 KB

compose-markdown

Kotlin Multiplatform library for rendering Markdown with Compose

commonMain {
    dependencies {
        // ...
        implementation("se.sekvy:compose-markdown:1.0.0-alpha02")
    }
}

Usage

For example

@Composable
fun showArticle(path: String) {
    var nodeType: NodeType? by remember { mutableStateOf(null) }

    LaunchedEffect(path) {
        val bytes = loadBytesFromPath(path)
        nodeType = MarkdownParser(ParserType.CommonMark).parse(bytes.decodeToString())
    }

    nodeType?.let {
        Box(modifier = Modifier.padding(start = 24.dp, end = 24.dp, top = 24.dp, bottom = 24.dp)) {
            Column {
                MDDocument(it) {
                    loadBitmap(it)
                }
            }
        }
    }
}

Recognition

Compose code is orignally based on https://github.com/ErikHellman/MarkdownComposer

Markdown parsing uses Commonmark libraries. commonmark-java for jvm, commonmark.js for Js. Or JetBrains/markdown