flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.61k stars 455 forks source link

Issue with code colors in dark mode in Markdown #3969

Closed InesaFitsner closed 2 months ago

InesaFitsner commented 2 months ago

Duplicate Check

Describe the bug

In the Controls Gallery app (https://flet-controls-gallery.fly.dev/displays/markdown), Flet version 0.21.2, code is displayed normally.

In 0.24.1, colors in the code displayed differently and some of them are not visible on the dark background.

Code sample

Code import flet as ft def main(page: ft.Page): table = """ ### Create Python program Create a new Python program using Flet which will be driving the content of `FletApp` widget. Let's do a simple `counter.py` app similar to a Flutter new project template: ```python import flet from flet import IconButton, Page, Row, TextField, icons def main(page: Page): page.title = "Flet counter example" page.vertical_alignment = "center" txt_number = TextField(value="0", text_align="right", width=100) def minus_click(e): txt_number.value = int(txt_number.value) - 1 page.update() def plus_click(e): txt_number.value = int(txt_number.value) + 1 page.update() page.add( Row( [ IconButton(icons.REMOVE, on_click=minus_click), txt_number, IconButton(icons.ADD, on_click=plus_click), ], alignment="center", ) ) flet.app(target=main, port=8550) ``` """ page.add( ft.Markdown( table, selectable=True, extension_set=ft.MarkdownExtensionSet.GITHUB_WEB, code_theme=ft.MarkdownCodeTheme.ATOM_ONE_DARK, code_style_sheet=ft.MarkdownStyleSheet( code_text_style=ft.TextStyle(font_family="Roboto Mono") ), # on_tap_link=lambda e: ft.page.launch_url(e.data), ) ) ft.app(target=main)

To reproduce

  1. Run https://flet-controls-gallery.fly.dev/displays/markdown and see how code looks in 0.21.2:

    Screenshot 2024-09-11 at 10 40 46 AM
  2. Run example code with 0.24.1 and result is this:

    Screenshot 2024-09-11 at 10 38 14 AM

Expected behavior

Expected to look in 0.24.1 same as in 0.21.2.

Screenshots / Videos

Captures [Upload media here]

Operating System

macOS

Operating system details

macOS

Flet version

0.24.1

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Logs

Logs ```console [Paste your logs here] ```

Additional details

No response

ndonkoHenri commented 2 months ago

Seems like I am getting a different output.

Data

md = """
import flet
from flet import IconButton, Page, Row, TextField, icons

def main(page: Page):
    page.title = "Flet counter example"
    page.vertical_alignment = "center"

    txt_number = TextField(value="0", text_align="right", width=100)

    def minus_click(e):
        txt_number.value = int(txt_number.value) - 1
        page.update()

    def plus_click(e):
        txt_number.value = int(txt_number.value) + 1
        page.update()

    page.add(
        Row(
            [
                IconButton(icons.REMOVE, on_click=minus_click),
                txt_number,
                IconButton(icons.ADD, on_click=plus_click),
            ],
            alignment="center",
        )
    )

flet.app(target=main, port=8550)
"""

Code

def main(page):
    page.scroll = True
    page.window.always_on_top = True
    page.add(
        ft.Markdown(
            value=md,
            selectable=True,
            extension_set=ft.MarkdownExtensionSet.GITHUB_WEB,
            code_theme=ft.MarkdownCodeTheme.ATOM_ONE_DARK,
            code_style_sheet=ft.MarkdownStyleSheet(
                code_text_style=ft.TextStyle(font_family="Roboto Mono"),
            ),
        )
    )

ft.app(main)

Output

image

InesaFitsner commented 2 months ago

Was issue with my environment