08-10-2019, 03:16 AM | #1 |
Wizard
Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
overriding someone else's css
I'm looking for feedback on my quick and dirty hack to override the css in downloaded books; removing fonts, "fixing" things like line height, justification, paragraph indentation, etc. I simply append it to the end of the existing css files. (I would use it as kobo_extra.css but the !important gizmo hoses things on the Kobo.)
Here's what I'm using so far. I'm wondering if you have other things you've needed or what your take is on this. PHP Code:
Last edited by lumpynose; 08-10-2019 at 12:04 PM. |
08-10-2019, 05:24 AM | #2 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
That will really mess up books where the publisher uses <p> for headings etc., and won't have much effect on books where the publish
Edit: One specific problem likely to be caused by margin: 0em !important; is the loss of scene breaks of the sort where the new scene is indicated by a top margin on the opening paragraph. Edit: My experience is that each ebook is constructed differently, there is nothing even close to a standard even with books produced by the same publisher, and so any attempt to apply a one-size-fits-all algorithm is a waste of time. I just edit each one manually, and if that sounds like a lot of work then think of it in terms of the time spent reading the book: a few minutes editing (for 98% of books, a small minority take longer) vs. many hours reading and re-reading. Last edited by GeoffR; 08-10-2019 at 09:42 AM. Reason: I just edit each one manually. |
Advert | |
|
08-10-2019, 12:09 PM | #3 | |
Wizard
Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
Quote:
|
|
08-10-2019, 01:02 PM | #4 |
Wizard
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
|
Rather than over ride I remove the worst offenders.
After importing any book I do an epub to epub conversion in calibre with filters set to e.g. strip out all line heights. those were my pet peeve, seeing lines too close together.. I do add widows , Orphans 1 as extra css. But this is just for personal reading. I don't need to please anyone except me. I like a line spacing of 1.9, no dropcaps, no hyphens, no silly fonts, no short pages due to widows... Last edited by stumped; 08-10-2019 at 01:05 PM. |
08-10-2019, 04:13 PM | #5 |
A Hairy Wizard
Posts: 3,095
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Just appending CSS at the bottom will work with those devices apps that don't ignore the publisher's CSS in the first place. However, this technique could slow down the reading process as the device has to figure out how to render the page, then re-figure it out, then re-figure, etc. depending on how many conflicting styles are on the css sheet. Obviously this is a greater problem on older, slower, devices.
|
Advert | |
|
08-10-2019, 11:19 PM | #6 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
That is the approach I take too, but I am selective in what I remove, I check each case to see what it is being used for before removing it.
E.g. I don't remove all line-height styles, I only remove the ones that affect the main body text. Sometimes a specific line-height is necessary and removing it would spoil the layout, such as a reduced or zero line height used to prevent a raise-cap from increasing the space between the first and second line of the opening paragraph. Edit: Another example from the OP: text-align: left !important; will (on some ereaders) force all paragraphs to be left-aligned. Better to just remove the instances of text-align:justify; and leave text-align:center; and text-align:right; intact. Last edited by GeoffR; 08-10-2019 at 11:26 PM. Reason: Another example |
08-11-2019, 12:52 AM | #7 |
Wizard
Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
I wonder if changing it from just "p" to "body p" would help with that? Bandaids on top of bandaids.
|
08-11-2019, 01:10 AM | #8 |
Wizard
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
|
if the edits are for books you intend to sell or distribute, please don't specify line heights
That stops the on-device sliders working on kobo readers, and stops some apps from applying defined themes e.g. mantano/Bookari the reason I originally had to figure out how to strip all height 1.2 stuff was because it looked so awful on my tablets in Montano and it blocked Montano from applying my set preference similarly with fonts. if you include declarations like font: serif or font: times... in CSS ,that messes with some apps/readers applying the font that the reader wants to see and with justification - you yourself may prefer "left" , I and other readers may hate it and want " justified" leave it out - let the readers device/app manage it |
08-11-2019, 02:38 AM | #9 | |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Quote:
line-height can be used in a way that doesn't interfere with the device's ability to adjust the line spacing. For example you can use a specific line spacing on the title page and that won't intefere with the rest of the book. Or you can set the line-height at the span level without interering with the device's ability to adjust the line spacing of the paragraph, such as for raise-caps: Code:
<p style="text-indent:0;padding-top:1em;"> <span style="line-height:0;font-size:2em;">T</span>his use of line-height avoids the extra space between the first and second lines of this pararaph, caused by the 2em raise-cap (on devices which honour the style), but doesn't prevent the device from adjusting the line spacing of the paragraph.</p> |
|
08-11-2019, 03:04 AM | #10 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
I can't see how that would help. What you can achieve with CSS overrides is extremely limited. I don't know any way to selectively override text-align:justify; without also overriding text-align:center; (assuming that is what you are aiming for) if you restrict yourself to CSS overrides.
|
08-11-2019, 03:50 PM | #11 | |
Wizard
Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
My thoughts exactly. And of course whenever I feel strongly about something I wish more people felt this way.
Quote:
For books that I upload here I do all that you say except for the line heights. If leaving that out works on what I can test on then that will get the axe as well. |
|
08-11-2019, 03:54 PM | #12 | |
Wizard
Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
Quote:
|
|
08-13-2019, 09:59 AM | #13 |
Resident Curmudgeon
Posts: 73,983
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
I use the Calibre editor most of the time.
There is no way in heck I would replace the entire publisher CSS. What I do is delete all HTML files that I have no use for like the internal ToC, any reviews, list of other books, previews, adverts, piracy notices, etc. Then I remove all unused CSS. From there I add/replace my own body and p styles. Then from there I check if I need to add indents of 0 to the classes that use center. Then I remove all line-height where appropriate and I remove all left align. I also remove most <p class="tx"> for most paragraphs. I replace with just a p. Then I go through the classes in the html and fix as needed like the overly hugh wasted space used for chapter headers. I also rmeove any smallish find sizes where appropriate. Basically, by the time i'm done, the CSS is clean and the formatting is very nice. |
08-15-2019, 03:19 PM | #14 |
Lector minore
Posts: 649
Karma: 1738720
Join Date: Jan 2008
Device: Aura One, Samsung Galaxy Tab S5e, Google Pixel Slate
|
On a technical level I don't think there are major problems with your "hack", though it is quite inelegant.
But... I personally only go in to change specific items that annoy me (like too small line spacing, too small font size for regular text, mega-large margins etc) because I want to preserve as much of the existing formatting as possible. I want to believe that the "type-setting" of each book had some thought put into it to match the subject and mood etc. I don't want the responsibility of being the one who decides that, and I don't want ever book I read to look the same. |
08-15-2019, 05:37 PM | #15 | ||
Wizard
Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
Quote:
Quote:
As for books looking the same, for me its about the story. The typesetting isn't important as long as it isn't distracting or annoying. |
||
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Overriding Ebook Stylesheet | Archuleta | Kobo Reader | 3 | 05-03-2016 10:48 PM |
iBooks Night Mode Overriding CSS | zephyrmays | ePub | 23 | 07-31-2015 11:12 PM |
Overriding Proportional Spacing | townsend | Sigil | 6 | 05-02-2013 10:22 PM |
Overriding CSS ".articledescription" | miwie | Recipes | 6 | 01-18-2011 11:30 AM |
Problem Overriding Recipe | rozen | Calibre | 3 | 12-15-2010 11:52 AM |