GithubHelp home page GithubHelp logo

Comments (7)

johnfactotum avatar johnfactotum commented on July 4, 2024 1

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

  • Allow disabling color overrides
  • Use other methods such as filters to change the colors
  • Bring back support for __ibooks_internal_theme, and then the book itself can use -webkit-text-fill-color to force the text color

from foliate.

johnfactotum avatar johnfactotum commented on July 4, 2024

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.

from foliate.

nylki avatar nylki commented on July 4, 2024

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).

from foliate.

johnfactotum avatar johnfactotum commented on July 4, 2024

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.

from foliate.

nylki avatar nylki commented on July 4, 2024

@johnfactotum Thanks for explaining, makes way more sense now 🙂 ! I did not know that the syntax coloring is baked into the EPUB itself.
I was hoping that code blocks were somehow defined in a more generic way in EPUB (like a <code></code>-block), so that applying a syntax theme would be relatively easy.

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.

from foliate.

johnfactotum avatar johnfactotum commented on July 4, 2024

Yes, the code should be marked up with the <code> element. However, to quote the HTML Standard:

There is no formal way to indicate the language of computer code being marked up.

So automatically applying syntax highlighting would be problematic.

from foliate.

nylki avatar nylki commented on July 4, 2024

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.

from foliate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.