Skip to content

Inline images incorrectly overlap text #541

@DaniBartDomyn

Description

@DaniBartDomyn

Bug Description

First of all, thank you for your great work.

Inline images behave incorrectly when their height exceeds the text line height.

Steps to Reproduce

Add the following code and run it (a preview in the Android emulator is sufficient):

@Composable
private fun BrokenInlineImage() {
    val text = """
        ## Working inline
        ${inlineImage(width = 20)} and ${inlineImage(width = 100)} and ${inlineImage(width = 2000)}
        
        ## Broken inline
        This is a multiline text which breaks inline image rendering because the height of the entire container is considered instead of the text line height.
        ${inlineImage(width = 100, height = 300)}
    """.trimIndent()

    ComposeMarkdown(
        content = text,
        colors = markdownColor(),
        typography = markdownTypography(),
        padding = markdownPadding(),
        imageTransformer = Coil3ImageTransformerImpl,
    )
}

private fun inlineImage(width: Int = 60, height: Int = 60): String =
    "![image](https://dummyimage.com/${width}x${height}/000/fff)"

Expected Behavior

At minimum, images should not overlap with text.

Possible fallback behaviors could be:
• Rendering the image as a block element (non-inline), or
• Scaling the image to match the text line height.

Screenshots

Multiplatform Markdown Renderer

Image

Other Renderers

Other Markdown renderers handle this scenario differently (there doesn’t seem to be a strict standard):

Image Image Image

Environment

  • Library Version: 0.40.2
  • Platform: Android
  • Device: Emulator Resizable API 35, Redmi Pad API 34
  • Kotlin Version: 2.3.20
  • Compose Version: 2026.03.01

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions