Skip to content

Add support for HTML blog posts

Sebastian requested to merge html into main

This MR adds support for rendering HTML blog posts. It includes a Composable HtmlText that converts an HTML string to AnnotatedString with formatting by parsing the HTML using JSoup and then traversing the HTML element tree to build the AnnotatedString.

The supported HTML elements are almost all those supported by JSoup's Safelist.basic plus <h1> - <h6>, which are the elements we allow in blog posts while loading them as of HtmlUtils.cleanArticle(). Only "dd", "dl", "dt", "span" are currently unsupported.

It's also possible to click links contained in posts. Doing so opens up the link warning dialog as on Android. Confirming the link opening opens the link with the default web browser. It's also possible to copy the link to the clipboard.

Here's a demo:

blog-post-links

Edited by Sebastian

Merge request reports