MarkdownContentBuilder

A dedicated builder for creating markdown content. Wraps TextContentBuilder and provides markdown-specific functionality for generating well-formatted Markdown documents programmatically.

Example usage:

val document = markdown {
    h1("Hello, Markdown!")
    +"This is a paragraph of text."

    h2("Features")
    bulleted {
        item("Easy to use")
        item("Type-safe")
        item("Extensible")
    }

    link("Learn more", "https://example.com")
}

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
class LineContext(builder: TextContentBuilder = TextContentBuilder())

Context for building a single line of markdown with mixed formatting elements. Used within the line method to create complex inline formatting.

Link copied to clipboard
inner class ListContext(bullet: (counter: Int) -> String)

Context for building structured lists (bulleted, numbered).

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun blockquote(text: String)

Adds a blockquote to the content.

Link copied to clipboard
fun bold(text: String)

Adds a bold text (text) to the content.

Link copied to clipboard
fun br()
Link copied to clipboard
fun build(): String
Link copied to clipboard

Adds a bulleted list with a block structure.

Link copied to clipboard
fun code(code: String)

Adds a code span (code) to the content.

Link copied to clipboard
fun codeblock(code: String, language: String = "")

Adds a code block with optional language specification to the content.

Link copied to clipboard
fun h1(text: String)

Adds a level 1 header (# Header) to the content.

Link copied to clipboard
fun h2(text: String)

Adds a level 2 header (## Header) to the content.

Link copied to clipboard
fun h3(text: String)

Adds a level 3 header (### Header) to the content.

Link copied to clipboard
fun h4(text: String)

Adds a level 4 header (#### Header) to the content.

Link copied to clipboard
fun h5(text: String)

Adds a level 5 header (##### Header) to the content.

Link copied to clipboard
fun h6(text: String)

Adds a level 6 header (###### Header) to the content.

Link copied to clipboard
fun header(level: Int, text: String)

Adds a markdown header to the content.

Link copied to clipboard

Adds a horizontal rule (---) to the content.

Link copied to clipboard
fun image(alt: String, url: String)

Adds an image () to the content.

Link copied to clipboard
fun italic(text: String)

Adds an italic text (text) to the content.

Link copied to clipboard

Creates a single line of markdown content with mixed formatting. Useful for creating complex inline formatting combinations.

Link copied to clipboard
fun link(text: String, url: String)

Adds a link (text) to the content.

Link copied to clipboard

Extension function to add markdown content to a TextContentBuilder.

Link copied to clipboard
fun newline()
Link copied to clipboard
operator fun String.not()
Link copied to clipboard

Adds a numbered list with a block structure.

Link copied to clipboard
fun padding(padding: String, body: TextContentBuilder.() -> Unit)
Link copied to clipboard

Adds a strikethrough text (text) to the content.

Link copied to clipboard
fun table(headers: List<String>, rows: List<List<String>>, alignments: List<TableAlignment> = List(headers.size) { TableAlignment.LEFT })

Adds a table to the content.

Link copied to clipboard
fun text(text: String)
Link copied to clipboard
Link copied to clipboard
open operator fun String.unaryPlus()