Markdown Text
Lightweight inline Markdown renderer for Jetpack Compose.
Efficiently parses and renders basic inline formatting styles:
Bold text:
**bold**rendered with FontWeight.SemiBoldItalic text:
*italic*rendered with FontStyle.ItalicMonospace code:` `code` `rendered with FontFamily.MonospaceHyperlinks:
[title](url)styled with TextDecoration.Underline and tinted with primary accent
Block Flattening & Line Clamping
Headings (#), bullet lists (- , * ), and numbered items (1. ) are flattened onto continuous lines to guarantee that parent layout line clamping (maxLines with TextOverflow.Ellipsis) works deterministically.
This matches the rendering behavior used across CupThread iOS/macOS SDKs and web dashboards for ChangelogEntry.body and FeatureRequestItem.description.
Example Usage
@Composable
fun ChangelogSnippet(entry: ChangelogEntry) {
MarkdownText(
content = entry.body,
maxLines = 3,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface
)
}Parameters
Raw Markdown string to parse and format.
Optional Modifier for the text layout.
Base TextStyle for the rendered text; defaults to bodySmall.
Text color for regular text; links are styled in MaterialTheme.colorScheme.primary.
Maximum number of lines before truncating with an ellipsis.