Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: hoist observable state #158

Closed
6 tasks done
ZacSweers opened this issue Jun 2, 2024 · 5 comments
Closed
6 tasks done

Feature request: hoist observable state #158

ZacSweers opened this issue Jun 2, 2024 · 5 comments

Comments

@ZacSweers
Copy link

About this issue

Currently, Markdown composables are fairly black-box. While this convenient, I'd like to suggest a feature request to extract a MarkdownState class that exposes observable State properties for parsed markdown components.

My example use case for this is being able to get a list of URLs.

interface MarkdownState {
  val parsedUrls: List<String>

  // Allow eager parsing, unlocking pre-computing and possibly multithreading
  suspend fun parse()
}

val state = rememberMarkdownState(text)
Markdown(state) // Alternative overload to Markdown(String)

if (state.parsedUrls.isNotEmpty()) {
  LaunchedEffect(Unit) {
    preWarmUrls(state.parsedUrls)
  }
}

Checklist

@mikepenz
Copy link
Owner

mikepenz commented Jun 3, 2024

I really think that's an amazing proposal. Thank you! I might not have the bandwidth this week to look into it. In case you had more bandwidth happy to take a PR.

@ZacSweers
Copy link
Author

Let me see if I can take a crack at it 👍

@mikepenz
Copy link
Owner

mikepenz commented Mar 28, 2025

While this PR does not yet introduce state like proposed, it's one step closer to this goal.

It will now allow you to pass over your own ReferenceLinkHandler implementation, so you can customize the behavior for found links more easily.

It will now also preloadLinks from the parsed markdown prior rendering (can be disabled) - this was done to add support for reference links.


Still working on refining that API to actually provide hopefully a solution to what you have suggested.

@mikepenz
Copy link
Owner

Ok, a new observable state API has been introduced here: #348

@mikepenz
Copy link
Owner

Additional notes in the beta release notes: https://github.com/mikepenz/multiplatform-markdown-renderer/releases/tag/v0.33.0-b02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants