feat: add LaTeX support in ft.Markdown#6069
Conversation
|
Great PR! Replacing deprecated package and LaTeX support is a great plus. |
|
Awesome, I have been waiting for LaTex support. An can this LaTex mark down can be integrated with Canvas Text too? It would be great for making educational apps. |
You can use math_text = r"$P + \frac{1}{2} \rho v^2 + \rho g h = \text{constant}$"
canvas = cv.Canvas(
expand=False,
shapes=[
cv.Fill(ft.Paint(color=ft.Colors.YELLOW)),
],
content=ft.Column(
controls=[
ft.Markdown(math_text),
]
)
) |
|
@7576457 would you like to add an integration test for Markdown with LaTeX here: There is readme on how to run/make-golden-images integration tests: |
|
yes, sure! |
|
Oh, I haven't realized if you are not on macOS you won't be able to generate "golden" image. We are running integration tests on macOS for now. OK, you write a test and do a golden image for your platform and I'll upload updated one once PR is merged. |
|
I added the test. Please let me know if something is missing. I also had trouble running the tests because flet couldn't find flutter. Until I made this change: (.venv) PS C:\Users\Jesuh\dev\flet\sdk\python> git diff packages/flet/src/flet/testing/flet_test_app.py
diff --git a/sdk/python/packages/flet/src/flet/testing/flet_test_app.py b/sdk/python/packages/flet/src/flet/testing/flet_test_app.py
index 16c6b921..3b41b8e4 100644
--- a/sdk/python/packages/flet/src/flet/testing/flet_test_app.py
+++ b/sdk/python/packages/flet/src/flet/testing/flet_test_app.py
@@ -223,7 +223,7 @@ class FletTestApp:
stdout = None
stderr = None
- flutter_args = ["fvm", "flutter", "test", "integration_test"]
+ flutter_args = ["fvm", "flutter.bat", "test", "integration_test"]
if self.__disable_fvm:
flutter_args.pop(0)
(.venv) PS C:\Users\Jesuh\dev\flet\sdk\python> |
|
In the terminal do you run |
Updated several Flutter dependencies in pubspec.lock, including file_picker, path_provider_foundation, and others. Removed path_provider_foundation from macOS plugin registrant. Added a new golden image for markdown integration tests on macOS.
|
I didn’t actually try to use FVM. I was just trying to create a golden test and run a test to verify it. Here’s what I did for that (having pre-set $env:FLET_TEST_GOLDEN = "1"
$env:FLET_TEST_DISABLE_FVM = "True"
uv run pytest .\packages\flet\integration_tests\controls\material\test_markdown.pyThen I simply ran the test to check that it worked: $env:FLET_TEST_GOLDEN = "0"
uv run pytest .\packages\flet\integration_tests\controls\material\test_markdown.pyEverything worked fine in this case |
|
Right, I see. Can you install |
|
You need fvm anyway as Flutter is progressing fast and we keep it fresh in |
Description
The
flutter_markdownpackage is officially deprecated and has been replaced byflutter_markdown_plus. In this PR, I updated the old package and also addedflutter_markdown_plus_latex.For the
ft.Markdowncomponent, two new attributes are now available:latex_style: accepts anft.TextStyleobject.latex_scale_factor: accepts a floating-point number.Rendering mathematical equations #6066
Rendering of mathematical expressions (Latex, Mathjax) #5499
LaTex rendering in flet #3955
Test Code
Type of change
Checklist
Screenshots
Summary by Sourcery
Add LaTeX rendering support to the Markdown control and migrate to the new markdown packages.
New Features:
Enhancements: