Markdown
Renders the provided markdown content string using Jetpack Compose.
This is the primary entry point for rendering markdown content in your application. It handles parsing the markdown string, applying styling, and rendering the content with appropriate components.
The rendering process follows these steps:
Parse the markdown content using the provided parser
Create a state object to manage the rendering process
Apply styling and customization options
Render the content using the appropriate components
Example usage:
Markdown(
content = "# Hello World\n\nThis is a **bold** statement.",
colors = markdownColor(),
typography = markdownTypography()
)Parameters
The markdown content string to be rendered.
The color scheme to be used for rendering different markdown elements.
The typography settings to be used for text rendering.
The modifier to be applied to the container. Defaults to Modifier.fillMaxSize.
The padding configuration to be applied to different markdown elements.
The dimension settings for spacing and sizing of markdown elements.
The markdown flavor descriptor for parsing. By default uses GitHub Flavored Markdown (GFM).
The parser instance to be used for parsing the markdown. By default creates a new parser with the provided flavor.
The transformer for handling and loading images within markdown content.
The annotator for adding custom annotations to the rendered content.
The configuration for extended text spans beyond standard markdown.
The configuration for inline custom content within markdown.
The custom components to be used for rendering different markdown elements.
The handler for resolving reference-style links in markdown.
The animation configurations for interactive elements.
A composable function to be displayed while the content is being parsed and prepared.
A composable function to be displayed with the successfully parsed markdown content. It receives the state, components, and modifier as parameters. By default, this renders the content in a Column.
A composable function to be displayed in case of parsing errors. This is only triggered if assertions are enabled on the parser.
Renders markdown content using a pre-created MarkdownState object.
This overload is useful when you need more control over the state management of your markdown content, such as when you want to:
Pre-parse markdown content
Share the same state across multiple composables
Implement custom state handling logic
The state object manages the parsing and preparation of the markdown content, while this function handles the rendering with appropriate styling and components.
Example usage:
val markdownState = rememberMarkdownState(content = "# Hello World")
Markdown(
markdownState = markdownState,
colors = markdownColor(),
typography = markdownTypography()
)Parameters
A MarkdownState object that manages the parsing and state of the markdown content.
The color scheme to be used for rendering different markdown elements.
The typography settings to be used for text rendering.
The modifier to be applied to the container. Defaults to Modifier.fillMaxSize.
The padding configuration to be applied to different markdown elements.
The dimension settings for spacing and sizing of markdown elements.
The transformer for handling and loading images within markdown content.
The annotator for adding custom annotations to the rendered content.
The configuration for extended text spans beyond standard markdown.
The configuration for inline custom content within markdown.
The custom components to be used for rendering different markdown elements.
The animation configurations for interactive elements.
A composable function to be displayed while the content is being parsed and prepared.
A composable function to be displayed with the successfully parsed markdown content. It receives the state, components, and modifier as parameters. By default, this renders the content in a Column.
A composable function to be displayed in case of parsing errors. This is only triggered if assertions are enabled on the parser.
See also
Renders markdown content using a State object directly.
This is the lowest-level overload of the Markdown composable, providing direct control over the rendering state. It's primarily used internally by the other overloads but can be useful for advanced use cases where you need to:
Implement custom state transitions
Handle specific loading/error states manually
Integrate with custom state management systems
The function handles different states (Loading, Success, Error) and provides appropriate UI for each state.
Example usage:
val state: State = ... // Your custom state implementation
Markdown(
state = state,
colors = markdownColor(),
typography = markdownTypography(),
loading = { LoadingIndicator() },
error = { ErrorMessage() }
)Parameters
A State object representing the current state of the markdown content (loading, success, or error).
The color scheme to be used for rendering different markdown elements.
The typography settings to be used for text rendering.
The modifier to be applied to the container. Defaults to Modifier.fillMaxSize.
The padding configuration to be applied to different markdown elements.
The dimension settings for spacing and sizing of markdown elements.
The transformer for handling and loading images within markdown content.
The annotator for adding custom annotations to the rendered content.
The configuration for extended text spans beyond standard markdown.
The configuration for inline custom content within markdown.
The custom components to be used for rendering different markdown elements.
The animation configurations for interactive elements.
A composable function to be displayed when the state is State.Loading.
A composable function to be displayed when the state is State.Success. It receives the state, components, and modifier as parameters. By default, this renders the content in a Column.
A composable function to be displayed when the state is State.Error.