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

Cannot use Markdown in a Container #359

Closed
B3J4y opened this issue Sep 20, 2022 · 4 comments
Closed

Cannot use Markdown in a Container #359

B3J4y opened this issue Sep 20, 2022 · 4 comments
Milestone

Comments

@B3J4y
Copy link

B3J4y commented Sep 20, 2022

Description

I try to render md files in my app and thought it would be good to put them into a container. Especially because I need to show multiple md files in one page. But after putting them into a container, flet didn't display anything.

Code example to reproduce the issue:

random_markdown_element = Markdown(random_md, selectable=True, extension_set="commonMark",
                        on_tap_link=lambda e: page.launch_url(e.data), expand=True)
page.add(Container(content=random_markdown_element))

Is there a way to containerize Markdown, or is this not provided for?

@hololeo
Copy link

hololeo commented Sep 20, 2022

container needs width or height
@FeodorFitsner improve flet user warning error here?

@B3J4y
Copy link
Author

B3J4y commented Sep 20, 2022

Height is needed. If I just use width, then nothing happens. It would be helpful to document it in https://flet.dev/docs/controls/container/ that height is mandatory.

Now I have to measure the height of the component in absolute units or is there also a possibility to set a relative value dependent on the window size.

Thank you for your help.

@modaye
Copy link
Contributor

modaye commented Sep 20, 2022

#331 There are similar problems here

@FeodorFitsner
Copy link
Contributor

So, the problem is that to implement markdown Flet uses Markdown widget which is MarkdownBody wrapped into ListView. That's why it requires either fixed height or expand.

I've just fixed Markdown control to use MarkdownBody. It's going to be responsibility of Flet developer to put it into a scrollable container.

Markdown in container:

image

        Container(
            Markdown(
                md2,
                extension_set="gitHubWeb",
                on_tap_link=lambda e: page.launch_url(e.data),
            ),
            width=200,
            bgcolor="#f5f5f5",
            border=border.all(2, "blue"),
            border_radius=10,
            padding=10,
            clip_behavior="antiAlias",
        )

FeodorFitsner added a commit that referenced this issue Sep 20, 2022
@FeodorFitsner FeodorFitsner added this to the Controls-S2 milestone Sep 20, 2022
@FeodorFitsner FeodorFitsner added the status: working on it Working on a fix for the issue label Sep 28, 2022
@FeodorFitsner FeodorFitsner removed the status: working on it Working on a fix for the issue label Sep 28, 2022
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

4 participants