Markdown

fun Markdown(text: String, modifier: Modifier = Modifier, styles: MarkdownStyles = MarkdownStyles(), localImageMap: Map<String, Painter> = emptyMap(), loadAsync: Boolean = false, onLoaded: () -> Unit = {}, onLinkClick: (it: String, uriHandler: UriHandler) -> Unit = ::defaultOnLickClickHandler)

Markdown

A Simple markdown renderer for basic rich text. This composable does not support HTML or links navigating to internal references.

Images in Markdown can either be URLs or local resources. Local resources are designated by a user-provided id string and a Painter passed via localImageMap. All images are loaded asynchronously automatically. To prevent content reflow and/or shifting when loading images specify both height and width parameters.

Images also have the option of adding sizing, alignment, and scaling info: width (in dp) height (in dp) hAlign (start|center|end) (only affects block images) vAlign (top|center|bottom) (only affects inline images) scale (none|crop|fillBounds|fit|fillWidth|fillHeight|inside)

example:

Note: Android and iOS do not support svg images

loadAsync If true Markdown will parse the content string on the IO thread. onLoaded called after the markdown has been parsed if passing in a string

TODO: Wrap with SelectionContainer when SelectionContainer does not block clicking of links


fun Markdown(source: MarkdownSource, context: MarkdownContext, modifier: Modifier = Modifier, loadAsync: Boolean = false, onLoaded: () -> Unit = {})

Markdown

Allows passing in a MarkdownSource and a MarkdownContext. Reusing a MarkdownContext will allow Markdown to reuse cached images. Using MarkdownSource.Blocks will prevent Markdown from having to parse the string which will improve performance.