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

Possibility of extracting a TextSpan out of a text-only HTML? #1334

Open
kekland opened this issue Sep 6, 2024 · 3 comments
Open

Possibility of extracting a TextSpan out of a text-only HTML? #1334

kekland opened this issue Sep 6, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@kekland
Copy link

kekland commented Sep 6, 2024

Use case

Hi! Thanks for this amazing project, really saved us from a hassle of building an HTML parser :)

We have a use-case where we need to render a HTML text coming from the server as a TextSpan, so that we can insert it in a Text.rich() alongside other TextSpans. It's guaranteed from the server that the HTML text is a single paragraph containing only <b>, <i>, and <u> tags.

After looking through the library, I couldn't find an easy way to achieve this.

Proposal

Add an easy way to create a TextSpan from a BuildTree, instead of a full widget

@kekland kekland added the enhancement New feature or request label Sep 6, 2024
@daohoangson
Copy link
Owner

The internal logic will build the TextSpan as needed. Can't you use HtmlWidget directly?

@kekland
Copy link
Author

kekland commented Sep 13, 2024

We're currently building a UI where it's important to know the per-line metrics for the text. Currently I'm doing this via TextPainter and passing the TextSpan to it. Now we want to add HTML support for the text that comes from the backend, which is guaranteed to be a single paragraph. We also add some other children to this textspan.

I can't use HtmlWidget directly since it'll build the text internally, so I can't attach to its text painter. I wanted to somehow be able to use the internal logic so that I can build just the TextSpan.

@daohoangson
Copy link
Owner

With enough inputs, I think it's possible to make the TextSpan builder logic independent. Maybe.

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

No branches or pull requests

2 participants