01-23-2024, 12:30 AM | #1 |
Member
Posts: 19
Karma: 61498
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? |
01-23-2024, 12:50 AM | #2 |
Bibliophagist
Posts: 40,603
Karma: 157444382
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, 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. |
Advert | |
|
01-23-2024, 01:11 AM | #3 | |
Member
Posts: 19
Karma: 61498
Join Date: Mar 2023
Device: Kobo Libra 2
|
Quote:
|
|
01-23-2024, 06:55 AM | #4 |
the rook, bossing Never.
Posts: 12,379
Karma: 92073397
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 06:57 AM. |
01-23-2024, 09:57 AM | #5 | |
Member
Posts: 19
Karma: 61498
Join Date: Mar 2023
Device: Kobo Libra 2
|
Quote:
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. |
|
Advert | |
|
01-23-2024, 12:15 PM | #6 | |
Well trained by Cats
Posts: 30,454
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
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. |
|
01-23-2024, 01:05 PM | #7 |
the rook, bossing Never.
Posts: 12,379
Karma: 92073397
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 01:13 PM. |
01-23-2024, 02:26 PM | #8 | |
Member
Posts: 19
Karma: 61498
Join Date: Mar 2023
Device: Kobo Libra 2
|
Quote:
|
|
01-23-2024, 02:40 PM | #9 |
Well trained by Cats
Posts: 30,454
Karma: 58055868
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. |
01-24-2024, 09:16 AM | #10 |
the rook, bossing Never.
Posts: 12,379
Karma: 92073397
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
|
Tags |
css, epub, kepub, kobo |
|
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 03:56 PM |
New Kobo, ePub vs Kepub | Pjama | Kobo Reader | 8 | 04-07-2021 01:26 PM |
Convert ePub to KePub (400 books, already on Kobo)? | A random blob | Kobo Reader | 16 | 10-16-2019 01:39 PM |
Conditional CSS epub kepub | jiembe | Kobo Developer's Corner | 16 | 05-18-2018 08:58 AM |
Kobo Adobe Epub is a Kepub instead | rashkae | Kobo Reader | 61 | 01-13-2012 07:15 AM |