Coming Back to Kotlin: Building a Real App with KMP Part 3 — From Raw HTML to Native Content
Part 3 — Parsing WordPress HTML and Enriching Embeds WordPress posts arrive as raw HTML strings. A single post might contain paragraphs, headings, YouTube iframes, Spotify embeds, Instagram blockqu...

Source: DEV Community
Part 3 — Parsing WordPress HTML and Enriching Embeds WordPress posts arrive as raw HTML strings. A single post might contain paragraphs, headings, YouTube iframes, Spotify embeds, Instagram blockquotes, image galleries, internal post references, and ordered lists — all mixed together, none of it consistent. You can't just dump that into a WebView and call it a day. Well, you could. But the result looks like a website inside an app, it doesn't respect your theme, dark mode breaks, fonts are wrong, and interactions feel foreign. For a magazine app where the reading experience is the whole point, that's not acceptable. The approach: a custom HTML parser that converts raw WordPress HTML into a typed List<ContentPart> that Compose can render natively. ContentPart — The Typed Model The first thing to build is the sealed interface that represents every possible block of content: sealed interface ContentPart { data class Text(val content: AnnotatedString) : ContentPart data class Heading