Skip to content

Commit 5a1aa9a

Browse files
committed
Add Markdown example and integration test
Updated Markdown documentation to include a new example image and code snippet. Added an integration test and golden image for Markdown rendering to improve test coverage and documentation clarity.
1 parent f6ceea6 commit 5a1aa9a

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

sdk/python/packages/flet/docs/controls/markdown.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
class_name: flet.Markdown
33
examples: ../../examples/controls/markdown
4-
example_images: ../examples/controls/markdown/media
4+
example_images: ../test-images/examples/core/golden/macos/markdown
5+
example_media: ../examples/controls/markdown/media
56
---
67

7-
{{ class_summary(class_name) }}
8+
{{ class_summary(class_name, example_images + "/image_for_docs.png", image_caption="Basic Markdown") }}
89

910
## Examples
1011

@@ -16,7 +17,7 @@ example_images: ../examples/controls/markdown/media
1617
--8<-- "{{ examples }}/basic.py"
1718
```
1819

19-
{{ image(example_images + "/basic.gif", alt="basic", width="80%") }}
20+
{{ image(example_media + "/basic.gif", alt="basic", width="80%") }}
2021

2122

2223
### Code syntax highlight
12.9 KB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pytest
2+
3+
import flet as ft
4+
import flet.testing as ftt
5+
6+
7+
@pytest.mark.asyncio(loop_scope="function")
8+
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
9+
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
10+
await flet_app_function.assert_control_screenshot(
11+
request.node.name,
12+
ft.Markdown(
13+
value="# Welcome\n\nThis is **Markdown** rendered in Flet.",
14+
width=260,
15+
),
16+
)

sdk/python/packages/flet/src/flet/controls/core/markdown.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ class MarkdownCustomCodeTheme:
233233
class Markdown(LayoutControl):
234234
"""
235235
Renders text in markdown format.
236+
237+
```python
238+
ft.Markdown(
239+
value="# Welcome\\n\\nThis is **Markdown** rendered in Flet.",
240+
width=260,
241+
)
242+
```
236243
"""
237244

238245
value: str = ""

0 commit comments

Comments
 (0)