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

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 01-22-2024, 11:30 PM   #1
Duke5127
Member
Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!
 
Posts: 19
Karma: 5040
Join Date: Mar 2023
Device: Kobo Libra 2
Best way to format epub/kepub CSS (for Kobo Libra 2_?

I previously used KOReader to read my EPUBs/KEPUBs but I've switched back to the default Nickel in Kobo (I use a Libra 2) because it has better text rendering and more CSS support. One issue I've come across is formatting the EPUB CSS to make sure everything looks good. I used to edit the CSS by hand using Calibre's edit book feature, and I do use some features/plugins like:
1. Checking book
2. Removing all fonts
3. Removing unused CSS Styles
4. EpubCheck or ACE

I also use the ModifyEpub plugin to modify some things (I don't add extra CSS or modify margins).

My question is: what could I do to ensure that font sizes and line heights are ignored/reset to sane defaults, and that text is left aligned without editing the CSS manually? Is there a way to automate it? (I already use the justify left setting in Nickel as well as changing the font size in Nickel too)

What do you do to ensure that the CSS/styling of your EPUB book that you're going to read is suitable and ok for you?
Duke5127 is offline   Reply With Quote
Old 01-22-2024, 11:50 PM   #2
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,229
Karma: 145277352
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
No way to really set font sizes and line heights without human intervention. Personally, I edit the CSS and HTML files using a collection of saved searches in Sigil. I remove all line height lines, any text-align: justify lines, dump any dropcaps, etc. It takes about 5 minutes per book for most ePubs.

I tend to like a fairly simple layout. First paragraph in a chapter or after a scene break is non indented, all others are indented as an example. This makes it a bit easier to do the cleanup.
DNSB is offline   Reply With Quote
Old 01-23-2024, 12:11 AM   #3
Duke5127
Member
Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!
 
Posts: 19
Karma: 5040
Join Date: Mar 2023
Device: Kobo Libra 2
Quote:
Originally Posted by DNSB View Post
No way to really set font sizes and line heights without human intervention. Personally, I edit the CSS and HTML files using a collection of saved searches in Sigil. I remove all line height lines, any text-align: justify lines, dump any dropcaps, etc. It takes about 5 minutes per book for most ePubs.

I tend to like a fairly simple layout. First paragraph in a chapter or after a scene break is non indented, all others are indented as an example. This makes it a bit easier to do the cleanup.
Couldn't you reset line height, font size, font family, margins (maybe you'd break it though) through appending CSS? I got AI (GPT-4, Gemini Pro) to generate CSS (I actually got multiple files) that would reset those aforementioned properties. I'm currently in the process of testing and tweaking. If anyone wants to see the CSS, I can paste it in a reply.
Duke5127 is offline   Reply With Quote
Old 01-23-2024, 05:55 AM   #4
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,019
Karma: 85555555
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
The LLM like GPT are parasites copying other's work and often producing plausible rubbish. IMO only suitable for producing Advertising copy that's then checked by a human.

Crazy to generate CSS or code..

Also there are many situations were simply appending CSS won't fix things.

Line-height can be removed entirely by caliber automatically and isn't needed at all in an ebook.

Re: font size, font family, margins
You need to look at the existing HTML and CSS and see why they have done what ever it is. You need to identify which is the body paragraph, first paragraph and headings/chapters as a minimum. One mad looking ebook turned out to have no paragraphs or headings. Everything was <div class="whatever">some text</div>. The actual CSS had unlikely stuff too.

Last edited by Quoth; 01-23-2024 at 05:57 AM.
Quoth is offline   Reply With Quote
Old 01-23-2024, 08:57 AM   #5
Duke5127
Member
Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!
 
Posts: 19
Karma: 5040
Join Date: Mar 2023
Device: Kobo Libra 2
Quote:
Originally Posted by Quoth View Post
The LLM like GPT are parasites copying other's work and often producing plausible rubbish. IMO only suitable for producing Advertising copy that's then checked by a human.

Crazy to generate CSS or code..

Also there are many situations were simply appending CSS won't fix things.

Line-height can be removed entirely by caliber automatically and isn't needed at all in an ebook.

Re: font size, font family, margins
You need to look at the existing HTML and CSS and see why they have done what ever it is. You need to identify which is the body paragraph, first paragraph and headings/chapters as a minimum. One mad looking ebook turned out to have no paragraphs or headings. Everything was <div class="whatever">some text</div>. The actual CSS had unlikely stuff too.
How do I get calibre to automatically remove line height?

Also I know CSS, I was just lazy to write a specific reset stylesheet. Ive double checked everything. Instead of appending it, I prepend it. And yes, I do need to watch out for how the book is marked up in HTML. Could there be a better way to ensure that EPUBs just look good enough without tinkering with the styles manually?

I guess for font size and other similar properties I could check if there are any absolute units/values being used instead of relative units/values. For font family I can already remove them using ModifyEpub and through the edit book settings in Calibre. For Margins/padding/etc... Im not sure about that.
Duke5127 is offline   Reply With Quote
Old 01-23-2024, 11:15 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: 29,763
Karma: 54401244
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by DNSB View Post
No way to really set font sizes and line heights without human intervention. Personally, I edit the CSS and HTML files using a collection of saved searches in Sigil. I remove all line height lines, any text-align: justify lines, dump any dropcaps, etc. It takes about 5 minutes per book for most ePubs.

I tend to like a fairly simple layout. First paragraph in a chapter or after a scene break is non indented, all others are indented as an example. This makes it a bit easier to do the cleanup.
↑ ↑ ↑ ✔
Mostly the same here. I start using Calibre editor to validate and de-fluff (sample chaps and oversized ads, Charis ). I have saved searches to comment out letter-spacing:###; because Kepub mishandles the space (20) and runs words together on my Kobos (I want other Kepub features ) I also remove junk spans that sole purpose is to set font to 1em for the whole P

Then I use Sigil (I find using the clips menu to be more my work style for CSS use. YMMV).

Other uses of each editor vary as to what I see and what I am doing, Not because one is bad, just fits my brain at the time

I stopped trying to make Conversion FIX layout code issues, a long time ago.

A cleanly coded book takes less than 5 min to touch up my way.
theducks is offline   Reply With Quote
Old 01-23-2024, 12:05 PM   #7
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,019
Karma: 85555555
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
I agree with what theducks and DNSB write.

If you do a conversion (and epub to epub works), then select 'Look and Feel' > 'Styling' and rather than Extra CSS, at the bottom there is 'Filter style information', 'Select what style information you want to remove'
add bold text at
'Other CSS Properties:' [white-space, line-height]

There is some validity on web pages and some for fixed layout, but regular ebooks shouldn't have either of those.
Any extra white space should be only by padding or margin properties which this won't touch.
The line-helght is actually automatic from font metrics and if not set, the user can change it on the GUI. If it's set the user can't change it and it may be stupid.

So far those are the only two things I find safe to do on every ebook. I do extra stuff on files from Gutenberg.
It's in my calibre default for every kind of conversion.

Some ebooks will need manually edited and it usually doesn't long with the 'Edit Spans & Divs' plugin (and more) and sometimes regex fine & replace on the pages. Use 'Find' first a few times to be sure!
You can go to a paragraph and 'Control' mouse right click on the class name at the opening tag.

Knowledge of HTML and CSS is needed, but those in reflowable epub2, or awz3 / mobi etc converted to epub2 are not hard to learn.

Last edited by Quoth; 01-23-2024 at 12:13 PM.
Quoth is offline   Reply With Quote
Old 01-23-2024, 01:26 PM   #8
Duke5127
Member
Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!Duke5127 , Klaatu Barada Niktu!
 
Posts: 19
Karma: 5040
Join Date: Mar 2023
Device: Kobo Libra 2
Quote:
Originally Posted by Quoth View Post
I agree with what theducks and DNSB write.

If you do a conversion (and epub to epub works), then select 'Look and Feel' > 'Styling' and rather than Extra CSS, at the bottom there is 'Filter style information', 'Select what style information you want to remove'
add bold text at
'Other CSS Properties:' [white-space, line-height]

There is some validity on web pages and some for fixed layout, but regular ebooks shouldn't have either of those.
Any extra white space should be only by padding or margin properties which this won't touch.
The line-helght is actually automatic from font metrics and if not set, the user can change it on the GUI. If it's set the user can't change it and it may be stupid.

So far those are the only two things I find safe to do on every ebook. I do extra stuff on files from Gutenberg.
It's in my calibre default for every kind of conversion.

Some ebooks will need manually edited and it usually doesn't long with the 'Edit Spans & Divs' plugin (and more) and sometimes regex fine & replace on the pages. Use 'Find' first a few times to be sure!
You can go to a paragraph and 'Control' mouse right click on the class name at the opening tag.

Knowledge of HTML and CSS is needed, but those in reflowable epub2, or awz3 / mobi etc converted to epub2 are not hard to learn.
What other plugins do you recommend (for editing EPUBs)?
Duke5127 is offline   Reply With Quote
Old 01-23-2024, 01:40 PM   #9
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: 29,763
Karma: 54401244
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
I have Diaps toolbag on both (the name is different and slight variation in the UI) (I use this a LOT to clean spans, modify deficient (for my use) code. Most common is to simply change a chapter heading to use a H tag so the auto toc builder can do its thing with a click or 2.


Sigil is all about EPUB, so read the descriptions in the Plugins sub forum.
For Calibre (and Editor), look at the index of plugins.

What you choose depends on how YOU work , and what you work on.
theducks is offline   Reply With Quote
Old 01-24-2024, 08:16 AM   #10
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,019
Karma: 85555555
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by Duke5127 View Post
What other plugins do you recommend (for editing EPUBs)?
There is an epub check. Don't run it on an azw3 file you are editing. Only actual epubs.
Quoth is offline   Reply With Quote
Reply

Tags
css, epub, kepub, kobo

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help. Epub to kfx conversion extract css format from another book. Princess kindle Kindle Formats 7 12-05-2022 02:56 PM
New Kobo, ePub vs Kepub Pjama Kobo Reader 8 04-07-2021 12:26 PM
Convert ePub to KePub (400 books, already on Kobo)? A random blob Kobo Reader 16 10-16-2019 12:39 PM
Conditional CSS epub kepub jiembe Kobo Developer's Corner 16 05-18-2018 07:58 AM
Kobo Adobe Epub is a Kepub instead rashkae Kobo Reader 61 01-13-2012 06:15 AM


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


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