Skip to content

Text in code blocks hardly visible in custom dark themes #18317

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

Closed
PeterCxy opened this issue Aug 1, 2021 · 2 comments
Closed

Text in code blocks hardly visible in custom dark themes #18317

PeterCxy opened this issue Aug 1, 2021 · 2 comments
Labels
A-Themes-Custom Custom theme variables or support T-Defect

Comments

@PeterCxy
Copy link

PeterCxy commented Aug 1, 2021

Description

Text in code blocks while using custom dark themes is hardly visible. It seems that the highlight.js theme is applied incorrectly (in the default dark theme, atom-one-dark is used for highlight.js, but it seems that it is not applied while using custom themes).

Steps to reproduce

  • Apply a custom dark theme
  • Notice that text in all code blocks look weird

Version information

  • Platform: browser

For the web app:

  • Browser: Firefox 90
  • OS: Arch Linux
  • Element Version: v1.7.33

Notes

Comparison between official dark theme and custom ones:

2021-08-01_10-12_1
2021-08-01_10-12_2
2021-08-01_10-12

From top to bottom: default dark theme, Discord Dark Theme, Nord Dark.

After checking the generated theme-dark-custom.css (bundles/1bb29ac412a6c33a90c2/theme-dark-custom.css in my case), it seems that the hljs styles are simply not present there, but in theme-dark.css they are. Manually enabling theme-dark.css (by removing the disabled flag for the <link> element) while a custom theme is used seems to fix the code blocks, but this is probably the wrong way to do it.

@robintown robintown added the A-Themes-Custom Custom theme variables or support label Aug 1, 2021
@Oha-you
Copy link

Oha-you commented Dec 2, 2021

I think the initial issue (as shown on the screenshots) has been fixed in v1.9.4 by matrix-org/matrix-react-sdk/pull/6384
However, another bug stays: hljs styles do not persist in code blocks when custom themes are used.

My observations:

  • When you send a code block when using a custom theme (like Discord Dark), hljs styles are applied normally
  • When you restart Element Desktop and you have a custom theme enabled by default (using "default_theme": "custom-Discord Dark" in config.json), code is not highlighted:
    2021-12-02_183635
  • If you switch to the default Dark theme and then back once, the code becomes highlighted:
    2021-12-02_183743
  • But if you repeat this step one more time, the text is grey again (no styles are applied, on restart too)

It looks like a hljs refresh event is not firing correctly for custom themes.

@SimonBrandner
Copy link
Contributor

SimonBrandner commented Dec 2, 2021

@Oha-you, could you please file a separate issue for that?

I am going to close this issue as it seems to be fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Themes-Custom Custom theme variables or support T-Defect
Projects
None yet
Development

No branches or pull requests

4 participants