
Facilitates creation of composable Markdown documents using a DSL, supporting standard programming features and customizable printing options for flexible document generation.
A Kotlin DSL for making composable Markdown documents.
This library is still early in development. Feedback can be submitted through GitHub Issues. Open-source contributions are very welcome, especially implementations of other Markdown features and flavors.
Add it as a dependency to your project, hosted in Maven Central.
dependencies {
implementation("com.thebrownfoxx:karbon:0.6.1")
}You can start writing your Karbon Markdown inside a markdown block.
markdown {
h1("Headline")
p {
text("The quick brown ")
bold("foxx")
text(" jumps over the ")
italic("lazy dog.")
}
}You can use all your standard Kotlin features to build your Markdown.
val roll = (1..6).random()
markdown {
p("You rolled a $roll")
if (roll == 1) p("You won!")
}You can break Markdown into smaller composable functions via extension functions for the Markdown interface.
fun Markdown.header() {
h1("Karbon")
}
fun Markdown.body() {
p("The quick brown foxx.")
p { link("https://example.com", "Link") }
}
fun main() {
markdown {
header()
body()
}
}You can print the Markdown you wrote with the print function, which accepts MarkdownPrinters. There are prebuilt printers included in this library including ConsolePrinter and FilePrinter. You can also extend the MarkdownPrinter interface to make your own.
markdown {
text("Print this.")
}.print(ConsolePrinter)Alternatively, you can access the value property of a Markdown instance to get the raw Markdown String.
A Kotlin DSL for making composable Markdown documents.
This library is still early in development. Feedback can be submitted through GitHub Issues. Open-source contributions are very welcome, especially implementations of other Markdown features and flavors.
Add it as a dependency to your project, hosted in Maven Central.
dependencies {
implementation("com.thebrownfoxx:karbon:0.6.1")
}You can start writing your Karbon Markdown inside a markdown block.
markdown {
h1("Headline")
p {
text("The quick brown ")
bold("foxx")
text(" jumps over the ")
italic("lazy dog.")
}
}You can use all your standard Kotlin features to build your Markdown.
val roll = (1..6).random()
markdown {
p("You rolled a $roll")
if (roll == 1) p("You won!")
}You can break Markdown into smaller composable functions via extension functions for the Markdown interface.
fun Markdown.header() {
h1("Karbon")
}
fun Markdown.body() {
p("The quick brown foxx.")
p { link("https://example.com", "Link") }
}
fun main() {
markdown {
header()
body()
}
}You can print the Markdown you wrote with the print function, which accepts MarkdownPrinters. There are prebuilt printers included in this library including ConsolePrinter and FilePrinter. You can also extend the MarkdownPrinter interface to make your own.
markdown {
text("Print this.")
}.print(ConsolePrinter)Alternatively, you can access the value property of a Markdown instance to get the raw Markdown String.