MarkdownContent

@Composable
fun MarkdownContent(markdown: String, modifier: Modifier = Modifier, citations: List<SourcePart> = emptyList(), streaming: Boolean = false)(source)

Renders GitHub-flavoured Markdown with Material 3 styling.

  • fenced code gets syntax highlighting and a copy action (CodeBlock);

  • ``` ```mermaid ``` fences render as diagrams (MermaidDiagram) once the fence is closed, so half-streamed diagrams never flash parse errors;

  • LaTeX: $$…$$ / \[…\] render with KaTeX (MathBlock), inline $…$ becomes Unicode math (see LatexPreprocessor).

  • [n] references become InlineCitation-style links into citations (the message's sources), opening a sheet with the cited sources.

Streaming (streaming = true): the text is split into top-level blocks (MarkdownStreaming.split); finished blocks keep identical strings, so their composables are skipped and only the block being written re-parses — cost stays linear in the answer's length. The tail block has unfinished markup closed (MarkdownStreaming.repairTail) so raw ** never flashes.