From ef831b50469c01fa109a14e70d5102e977617ce8 Mon Sep 17 00:00:00 2001 From: Kazik Pogoda Date: Thu, 9 Jul 2026 17:03:44 +0200 Subject: [PATCH] Rework the README transformer example into a single streaming pipeline Inline the rule-set extensions into one parse().transform{}.asHtml() chain collected incrementally, showing the streaming consumption path instead of the composed-extensions + render() variant. --- README.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index feb02b3..bf8b08b 100644 --- a/README.md +++ b/README.md @@ -176,24 +176,25 @@ Note: Typically `markdownFlow: Flow` 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

as

, keeping its content -} +flowOf(markdown).parse().transform { -fun TransformerBuilder.emphasizeToStrong() { - match("em") { "strong" { children() } } // re-emit as -} + // re-emit

as

, 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 as + match("em") { + "strong" { children() } + } + + // copy every other mark and its text verbatim + passthrough() + +}.asHtml().collect { + // incremental output + println(it) +} ``` Will print: