Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 08-10-2019, 04:16 AM   #1
lumpynose
Wizard
lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.
 
Posts: 1,086
Karma: 4583858
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:
body {
    
background-colorinitial !important;
    
font-family: unset !important;
    
line-height1.2 !important;
}

{
    
font-family: unset !important/* MS Word stuff */
    
line-height1.2 !important;
    
margin0em !important;
    
text-alignleft !important;
    
text-indent!important;
}

{
    
text-indent1.6em !important;


Last edited by lumpynose; 08-10-2019 at 01:04 PM.
lumpynose is offline   Reply With Quote
Old 08-10-2019, 06:24 AM   #2
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19159830
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 10:42 AM. Reason: I just edit each one manually.
GeoffR is offline   Reply With Quote
Advert
Old 08-10-2019, 01:09 PM   #3
lumpynose
Wizard
lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.
 
Posts: 1,086
Karma: 4583858
Join Date: Jul 2012
Device: Palm Pilot M105
Quote:
Originally Posted by GeoffR View Post
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.
I agree, but so far it's fixing a large majority of the books and thus saving me the effort of eyeballing and analyzing the css.
lumpynose is offline   Reply With Quote
Old 08-10-2019, 02:02 PM   #4
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 2,130
Karma: 3250612
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 02:05 PM.
stumped is online now   Reply With Quote
Old 08-10-2019, 05:13 PM   #5
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 1,976
Karma: 12600000
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2 & Air/Surface Pro/Kindle PW
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.
Turtle91 is offline   Reply With Quote
Advert
Old 08-11-2019, 12:19 AM   #6
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19159830
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
Quote:
Originally Posted by stumped View Post
Rather than over ride I remove the worst offenders.
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-11-2019 at 12:26 AM. Reason: Another example
GeoffR is offline   Reply With Quote
Old 08-11-2019, 01:52 AM   #7
lumpynose
Wizard
lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.
 
Posts: 1,086
Karma: 4583858
Join Date: Jul 2012
Device: Palm Pilot M105
Quote:
Originally Posted by GeoffR View Post
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.
I wonder if changing it from just "p" to "body p" would help with that? Bandaids on top of bandaids.
lumpynose is offline   Reply With Quote
Old 08-11-2019, 02:10 AM   #8
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 2,130
Karma: 3250612
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
stumped is online now   Reply With Quote
Old 08-11-2019, 03:38 AM   #9
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19159830
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
Quote:
Originally Posted by stumped View Post
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
I think that is overstating the situation. I would encourage publishers to use line-height in those situations where it improves the book, as long as it doesn't prevent the reader from adjusting line spacing for the main text of the book.

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>
GeoffR is offline   Reply With Quote
Old 08-11-2019, 04:04 AM   #10
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19159830
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
Quote:
Originally Posted by lumpynose View Post
I wonder if changing it from just "p" to "body p" would help with that? Bandaids on top of bandaids.
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.
GeoffR is offline   Reply With Quote
Old 08-11-2019, 04:50 PM   #11
lumpynose
Wizard
lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.
 
Posts: 1,086
Karma: 4583858
Join Date: Jul 2012
Device: Palm Pilot M105
Quote:
Originally Posted by stumped View Post
leave it out - let the readers device/app manage it.
My thoughts exactly. And of course whenever I feel strongly about something I wish more people felt this way.

Quote:
Originally Posted by stumped View Post
if the edits are for books you intend to sell or distribute, please don't specify line heights.
I didn't know that about line heights. I'll investigate that and see what happens when I leave it out.

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.
lumpynose is offline   Reply With Quote
Old 08-11-2019, 04:54 PM   #12
lumpynose
Wizard
lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.
 
Posts: 1,086
Karma: 4583858
Join Date: Jul 2012
Device: Palm Pilot M105
Quote:
Originally Posted by GeoffR View Post
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.
Wouldn't the selector "body p" get only top level paragraphs and not the ones inside blockquotes, divs, etc.?
lumpynose is offline   Reply With Quote
Old 08-13-2019, 10:59 AM   #13
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 55,432
Karma: 51439620
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2O, Sony PRS-650, Sony PRS-T1, nook STR, iPad 4, iPhone 5
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.
JSWolf is offline   Reply With Quote
Old 08-15-2019, 04:19 PM   #14
radius
Lector minore
radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.radius ought to be getting tired of karma fortunes by now.
 
radius's Avatar
 
Posts: 636
Karma: 1738720
Join Date: Jan 2008
Device: Aura One, PRS-T3, PaperWhite 2, Nexus 9
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.
radius is offline   Reply With Quote
Old 08-15-2019, 06:37 PM   #15
lumpynose
Wizard
lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.lumpynose ought to be getting tired of karma fortunes by now.
 
Posts: 1,086
Karma: 4583858
Join Date: Jul 2012
Device: Palm Pilot M105
Quote:
Originally Posted by radius View Post
On a technical level I don't think there are major problems with your "hack", though it is quite inelegant.
It's definitely not meant to be elegant; it's a big sledge hammer to simply fix what drives me nuts.

Quote:
Originally Posted by radius View Post
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.
As for the "typesetting of each book had some thought put into it" that's may be true for purchased books. But this sledge hammer is primarily used for books downloaded from Project Gutenberg, and even books from here. For example, I see no reason for specifying that the body text use a sans-serif font, or a serif font, or any particular font; I always use Caecilia because it's easier for my old eyes.

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.
lumpynose is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Overriding Ebook Stylesheet Archuleta Kobo Reader 3 05-03-2016 11:48 PM
iBooks Night Mode Overriding CSS zephyrmays ePub 23 08-01-2015 12:12 AM
Overriding Proportional Spacing townsend Sigil 6 05-02-2013 11:22 PM
Overriding CSS ".articledescription" miwie Recipes 6 01-18-2011 12:30 PM
Problem Overriding Recipe rozen Calibre 3 12-15-2010 12:52 PM


All times are GMT -4. The time now is 05:08 PM.


MobileRead.com is a privately owned, operated and funded community.