Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 12-28-2016, 09:31 PM   #1
stevenam
Member
stevenam began at the beginning.
 
Posts: 20
Karma: 10
Join Date: Nov 2016
Device: Kobo Aura One
Is there a way to batch edit multiple epub css?

As mentioned in the title, is there a way to do it?

For an instance, I have like 1,000 epub with way various css format, which messed up when being read on my e-reader. The deselection of "internal style" may help, but the parts where words in bold or italic, or arrange center are completely gone.

So, if I find a good css format epub, can I batch edit/copy to the rest of 1,000 epub files?

I tried to search our forum, but resulted in no luck.

Please help if you have any clue.

Thanks a lot.

Steve.

Last edited by stevenam; 12-28-2016 at 09:36 PM.
stevenam is offline   Reply With Quote
Old 12-28-2016, 10:33 PM   #2
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 7,069
Karma: 91577715
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
If you are asking whether you can take the CSS from one book and copy it to another book and have it work properly, the answer is generally "no". Some books by the same publisher may use compatible CSS, but otherwise it is specific to each individual book.
jhowell is offline   Reply With Quote
Advert
Old 12-28-2016, 10:36 PM   #3
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
The only way I can think of to get close to what you want is through a conversion. The conversion can add, remove or change styles. But it will be exactly the same for all books using those conversion options.

As you have a Kobo ereader, you might get some of what you want through the driver. It has an option to append styles to every stylesheet in the book as they are sent. These are read from a file in the root of the device during the send-to-device process.

But, the problem with either of these, or automating a stylesheet replacement, is that the stylesheets in the books are not the same. If you replace the stylesheets in the book with a common one, you will probably still end up with a mess. I tend to edit and fix purchased books as I go. If they look clean on the device, I don't touch them. But, if there are errors of some sort, or weird formatting, I have a look. None of the stylesheets are the same. There are some common things because there are common tools (and you can always see when calibre is one of the), but none are compatible.

For example, for most, the normal paragraph has a class. This class name is different each book. And can be different for each chapter. Then, as you mention italics and bold, half the books use a span with a class for these, the others use the "i" and "b" tags, but usually have a class specified. And then there is whether the chapter headings are done with heading tags or paragraphs with different styles. If you were to replace the stylesheet in all these books with the same stylesheet, you would probably end up with even more of a mess than were you are now.

The conversion is probably the best you will do. But, it is probably depends on exactly the problem in the books. Missing italics on a Kobo ereader usually means there is an error in the stylesheet. But, it could be an error in the tags. I would suggest opening some that are causing problems in the calibre editor and running error check and seeing what it shows. Fixing those errors will probably get it displaying on the device properly. And will give you an idea of what the problems are and maybe a way to fix them all.
davidfor is offline   Reply With Quote
Old 12-28-2016, 10:42 PM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Having written all that, and beaten by the much more succinct jhowell, something else occurred to me.

What font are you using? There are two fonts on the Kobo devices that are intended for use with Japanese and similar languages. When used with epubs in English, they don't display italics or bold text. These are "Kobo Tsukushi Mincho" and "Kobo UD Kakugo". Any of the other supplied fonts should be OK. And if you are sideloading a font, you need to make sure the file names are correct for everything to work correctly.
davidfor is offline   Reply With Quote
Old 12-29-2016, 03:01 AM   #5
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,726
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by stevenam View Post
As mentioned in the title, is there a way to do it?
That depends on your technical skills. Epubs are zip files and it's relatively easy to add/remove CSS files with a batch file or shell script. You could also add a custom CSS file with Calibre during an epub to epub conversion.

However, as davidfor and jhowell have already pointed out, there's no perfect one-size-fits all CSS solution. If the structure of the epubs is relatively simple, you could also replace the default stylesheet with a simple general-purpose CSS file. For example, CSS Boilerplate for eBooks.

Quote:
Originally Posted by stevenam View Post
The deselection of "internal style" may help, but the parts where words in bold or italic, or arrange center are completely gone.
Most likely bold and italic text is formatted via span tags. E.g., you might see something like:

Code:
<p>This is <span class="calibre999">bold</span> and this <span class="calibre666">italic</span>.</p>
If the books are all from the same publisher/book designer and the classes were consistently used, you could use the Saved Searches feature in Calibre Editor or Sigil to replace them with the usual tags. E.g.,

Code:
<p>This is <b>bold</b> and this <i>italic</i>.</p>
This would allow you to disable the default stylesheet.
Doitsu is offline   Reply With Quote
Advert
Old 12-29-2016, 10:58 AM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Calibre offers a method to ADD additions to a CSS

CSS use the LAST definition, so additions of the same tag will essentially replace previous definitions IN USAGE (the old tag still exists, earlier in the CSS)

The Modify e-pub plugin can insert extra CSS for a selected group
theducks is offline   Reply With Quote
Old 12-29-2016, 10:59 AM   #7
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
BTW I assumed you were using Calibre
theducks is offline   Reply With Quote
Old 12-29-2016, 02:14 PM   #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: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
it should be doable - because if you look into how the Bookari epub reader app works: when you create a custom theme it is applied to each book you open as additional CSS. that is what they say.
Their Theme CSS forces your choice of margins, line space, font, colour, justification, hyphenation onto each book that you open. So a theme is simply some CSS that is added to each opedned file on the fly, and it works very well. I don't know of any simple way to expose the actual code though, as the epubs are unchanged, it's an "only while it is in memory" overlay. I guess it works because of post #6 & I think Moon reader app uses a similar technique
stumped is offline   Reply With Quote
Old 12-29-2016, 09:33 PM   #9
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by stumped View Post
it should be doable - because if you look into how the Bookari epub reader app works: when you create a custom theme it is applied to each book you open as additional CSS. that is what they say.
Their Theme CSS forces your choice of margins, line space, font, colour, justification, hyphenation onto each book that you open. So a theme is simply some CSS that is added to each opedned file on the fly, and it works very well. I don't know of any simple way to expose the actual code though, as the epubs are unchanged, it's an "only while it is in memory" overlay. I guess it works because of post #6 & I think Moon reader app uses a similar technique
Odds are what they are doing is ignoring the built-in stylesheets and applying the custom theme. Or maybe add "!important" to the styles in the them to override everything in the book. But, it requires the ereader device or app to support this. The OP has a Kobo device. They are very strict on the use of the books stylesheet. You can change some things, but they don't always work depending on how the book is coded. e.g. If the book has line heights coded as pixels, changing the line heights using the device does not work.

And all that is why the Kobo driver can append some styles to the stylesheet. With this you can achieve some of the changes, but it can be a hard to get it right.
davidfor is offline   Reply With Quote
Old 12-30-2016, 01:05 AM   #10
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: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
Bookari for sure is not ignoring the books original stylesheet, it renders very faithfully to that, for paragraphs, headings etc. but adds its theme. This is with android tablets.
I do have to pre-strip explicit line heights from book CSS, like i used to have to do for my kobo reader, so that it can work its magic properly.
I learnt from kobo days to always strip explicit line heights and font family , i have a handy regex for the former and calibre can do the latter
so the OP can probably get close via a calibre epub to epub conversion that also removes stuff as ticked in css options and appends extra important css also. the Line heights may be trickiest unless a standard !important override to a preferred value is used
stumped is offline   Reply With Quote
Old 12-30-2016, 03:40 AM   #11
stevenam
Member
stevenam began at the beginning.
 
Posts: 20
Karma: 10
Join Date: Nov 2016
Device: Kobo Aura One
Hi guys,

Thanks a lot for replying to my thread. I actually very much appreciated all the replies, especially from jhowell and davidfor.

I will try and err some of the suggestions, and may gods of e-pub show me a proper tool/workflow to solve my myth.
stevenam is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch remove multiple covers? johnb0647 Library Management 2 12-08-2018 01:44 AM
How to batch add books stored in multiple zip files? atkach Library Management 3 10-12-2014 01:39 PM
ebook-edit fails to merge css files Ahmad Samir Editor 2 04-29-2014 01:57 AM
Batch css replace RJA Calibre 1 03-22-2014 04:28 PM
Multiple CSS Gray Eminence ePub 8 01-13-2011 10:10 AM


All times are GMT -4. The time now is 07:13 PM.


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