-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
syntax highlighting of code blocks only works for default theme #1315
Comments
This is a feature to ensure that the text is legible. I think this is also the behavior in Apple Books and Readium/Thorium. I suppose the easiest way out would be to just add an option to disable this. |
Thank you for your quick response! Just to avoid confusion: Is my assumption correct that the non-default themes don't have a code-block specific stylesheet that would fit their color scheme? (so they are colored as if they are plaintext). |
The syntax highlighting is part of the stylesheet of the EPUB file. Most EPUB files are designed to be displayed on a white background only and look broken when you apply a custom theme. So when using non-white background, Foliate overrides all foreground and background colors so that the theme would be applied consistently and the text would remain readable. See 29eed7e. |
@johnfactotum Thanks for explaining, makes way more sense now 🙂 ! I did not know that the syntax coloring is baked into the EPUB itself. I wonder if it would be feasible to heuristically identify code blocks and then define a custom theme for those section. Anyways, feel free to close the issue if you like. |
Yes, the code should be marked up with the
So automatically applying syntax highlighting would be problematic. |
I see. So, just to entertain the idea: although there is no formal way, auto-detection of the language inside a block could be an option (perhaps as an option that is disabled by default, or more involved, via a button to change the detected language). For example highlight.js does supports auto-detection of languages. |
Yes, that would be possible in theory, but probably too localized and complicated to be ever implemented in Foliate itself. Some alternatives, when the book already has syntax highlighting, which most of them do, are
|
I had a similar styling issue with a theme and a possible solution could be to make:
I don't know what color coordinate system Foliate uses, but HSL would be fine. |
Describe the bug
Code blocks (monospace blocks with syntax highlighting) don't work for most themes, only the default theme.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
When changing the color theme I expect syntax highlight of code blocks to still be visible.
Screenshots
default theme, featuring syntax highlighting and different bg-color:
solarized (or sepia) theme without syntax highlighting and same bg-color:
Version:
The text was updated successfully, but these errors were encountered: