Skip to content

Add optional bounded cache for parsed MarkdownState / markdown AST results #583

Description

@0sten

Feature Description

Add an optional bounded cache for parsed markdown state/results, so repeated identical markdown content can reuse an already parsed MarkdownState or parsed AST instead of reparsing every time it re-enters composition.

Problem Statement

rememberMarkdownState(...) improves performance within a composable instance, but it does not share parsed markdown results across list items, screens, or later compositions. In feed-style UIs, the same markdown content can be shown repeatedly as items leave/re-enter lazy lists or appear in multiple places, causing avoidable reparsing.

Proposed Solution

Expose a cache API that can be passed to rememberMarkdownState(...), or provide a built-in rememberMarkdownStateCache(...). Maybe provide Lru cache using LocalMarkdownCache static composition local. This would help apps that render large scrolling feeds, timelines, chats, documentation lists, or any UI where the same markdown content can be rendered repeatedly across compositions/screens, while still letting memory-sensitive apps opt out or configure strict bounds.

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