Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,25 @@ Note: Typically `markdownFlow: Flow<String>` represents a Markdown text stream,
Each reusable rule set is an extension on `TransformerBuilder` — think of one as an XSLT stylesheet you can compose with others:

```kotlin
fun TransformerBuilder.demoteHeadings() {
match("h1") { "h2" { children() } } // re-emit <h1> as <h2>, keeping its content
}
flowOf(markdown).parse().transform {

fun TransformerBuilder.emphasizeToStrong() {
match("em") { "strong" { children() } } // re-emit <em> as <strong>
}
// re-emit <h1> as <h2>, keeping its content
match("h1") {
"h2" { children() }
}

println(
flowOf(markdown)
.parse()
.transform {
demoteHeadings()
emphasizeToStrong()
passthrough() // copy every other mark and its text verbatim
}
.render()
)
// re-emit <em> as <strong>
match("em") {
"strong" { children() }
}

// copy every other mark and its text verbatim
passthrough()

}.asHtml().collect {
// incremental output
println(it)
}
```

Will print:
Expand Down