-
Notifications
You must be signed in to change notification settings - Fork 6
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
Applying hard coded stylesheet #4
Comments
Hi @antontkv ! Thanks for your thorough research and awesome explanation of the issue. I remember seeing these same issues while reading the downloaded books but I never had time and motivation to dig any deeper. This looks so much better. This would still require some more investigation (is this Thanks again! |
Hi.
I noticed some visual issues with the downloaded books. No background-color for code blocks, squashed calloutlists, etc. Not to mention that styles in the downloaded book looks different from web site.
I found out that there is stylesheet that not mentioned in API response. I will use Fluent Python, 2nd Edition as an example. If you look at compiled page source, there will be two styleshees for the book:
Second one comes from the API response, but first one
override_v1.css
actually hard coded in.js
file. In the book page there is script file https://learning.oreilly.com/library/view/dist/main.6c3d155559e48f978143.js and there you can find this code:injectStyles
styles function creates an array with first element hard coded${window.location.origin}/files/public/epub-reader/override_v1.css
and the rest stylesheets from the API response.I took this styleesheet and added it to already downloaded book. Removing any mention of
#book-content
from it, since the book don't have this id. I removed this block:And used this regex
(\s+|)#book-content(\s+|)
to remove any other mention.Here are comparison shots from the Calibre viewer:
Left: without override_v1.css, Right: with override_v1.css. Notice background-color for inline code and code blocks. Also fixed squashed list elements.
Also I added this css rule for better aligning of calloutlists:
Left before adding css rule, right after.
Do you think that it possible to add this css improvements for downloaded books? It could be done by adding https://learning.oreilly.com/files/public/epub-reader/override_v1.css to every book, since O'Reilly is doing it anyway. Or to be save, the
main\..*\.js
file from book page could be parsed to look for any hard coded css file.The text was updated successfully, but these errors were encountered: