Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 05-08-2018, 10:40 AM   #1
jiembe
Zealot
jiembe began at the beginning.
 
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
Conditional CSS epub kepub

Is it possible to create CSS witch act conditionally to the format of the ebook: if ePub do this; if kepub do that?
jiembe is offline   Reply With Quote
Old 05-08-2018, 11:45 AM   #2
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
No, not in the same way that Kindle books can have alternative CSS for MOBI and KF8 formats.

However, there is a trick you can use to make sure selected CSS will only be applied to kepub but not epub.

Can you give an example of what CSS you're trying to use for each?

How are you creating your kepubs? Do you use calibre to transfer books to your Kobo?
jackie_w is offline   Reply With Quote
Advert
Old 05-08-2018, 12:39 PM   #3
jiembe
Zealot
jiembe began at the beginning.
 
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
[QUOTE=No, not in the same way that Kindle books can have alternative CSS for MOBI and KF8 formats.
However, there is a trick you can use to make sure selected CSS will only be applied to kepub but not epub.
Can you give an example of what CSS you're trying to use for each?
How are you creating your kepubs? Do you use calibre to transfer books to your Kobo?[/QUOTE]

I'm editing my epub books through Calibre and then transform them as kepub. But the epub and kepub format don't act the same in my Kobo. For example, my preference is to hide the footnotes (display: hidden) in the normal reading. There is no problem to view the footnotes in .kepub since it appears in a popup window, but the epub format won't display the footnote at all.
jiembe is offline   Reply With Quote
Old 05-08-2018, 03:39 PM   #4
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Calibre's Check Book tool shows display:hidden as an error, perhaps it appeared in a later version of CSS than is typically supported by ADE-style renderers on eink devices, such Kobo's renderer for standard epubs.

I must admit I don't use any special CSS or markup for footnotes, I just use simple anchors which seem to work as expected on the Kobo, i.e.
- kepub: choice of pop-up or link-to-endnotes page
- epub: link-to-endnotes page only

They work no matter whether the book is epub/kepub and no matter whether the kepub was created from an EPUB2 or an EPUB3. For example:

Chapter HTML file:
Code:
<p>... a rule instituted hundreds of years ago to prevent this branch of the Church becoming too big for its boots.<sup><a id="back02" href="endnotes.xhtml#fn02">[2]</a></sup> But ...</p>
Endnotes HTML file:
Code:
<p class="footnote"><a id="fn02" href="chapter1.xhtml#back02">[2]</a><br/>Which were of the one-size-fits-all, tighten-the-screws variety.</p>
CSS is very simple:
Code:
.footnote {
    margin: 0 0 0 2em;
    padding-top: 3em;
    text-indent: -1em;
}
sup {
    font-size: 0.9em;
    line-height: 0;
    vertical-align: super;
}
ETA: I'm not saying that the above is the best way or the right way of doing footnotes, just that it is a way which seems to work trouble-free on a Kobo.

Last edited by jackie_w; 05-08-2018 at 04:07 PM. Reason: ETA
jackie_w is offline   Reply With Quote
Old 05-08-2018, 04:44 PM   #5
jiembe
Zealot
jiembe began at the beginning.
 
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
Quote:
ETA: I'm not saying that the above is the best way or the right way of doing footnotes, just that it is a way which seems to work trouble-free on a Kobo.
Your code is similar to mine. That's not the point. I don't want to see the footnote if I don't need or want it, even if they are at the end of a chapter or at the end of the book. So I simply put the footnotes inside a <div> with a display:hidden style. The only way to see the footnotes is to click on the renvoi. That's work fine in the kepub format but disallowed the possibility to see those notes in the epub format.

And this was 1 example of divergence code between epub and kepub. That's why I'm searching a way to toggle the CSS code between the 2.
jiembe is offline   Reply With Quote
Advert
Old 05-08-2018, 05:20 PM   #6
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
I'm not really sure what display:hidden is supposed to do, did you mean visibility:hidden? What happens if you try display:none instead for your footnote CSS? I think this is supported by the Kobo epub renderer.

If you want to exclude a whole file of endnotes you could try adding linear=no as an attribute in the spine <itemref> entry for the endnotes.xhtml file in the OPF file.
jackie_w is offline   Reply With Quote
Old 05-08-2018, 05:29 PM   #7
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: 36,424
Karma: 145748708
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by jiembe View Post
Your code is similar to mine. That's not the point. I don't want to see the footnote if I don't need or want it, even if they are at the end of a chapter or at the end of the book. So I simply put the footnotes inside a <div> with a display:hidden style. The only way to see the footnotes is to click on the renvoi. That's work fine in the kepub format but disallowed the possibility to see those notes in the epub format.
I suspect you wanted display: none as the style. I use the following when I don't want the text to display (chapter heading where an image is used as the chapter heading but I want to have Chapter IV in the TOC.

Code:
.hidden {
    display : none;
}
DNSB is offline   Reply With Quote
Old 05-08-2018, 08:38 PM   #8
jiembe
Zealot
jiembe began at the beginning.
 
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
Quote:
Originally Posted by DNSB View Post
I suspect you wanted display: none as the style. I use the following when I don't want the text to display (chapter heading where an image is used as the chapter heading but I want to have Chapter IV in the TOC.

Code:
.hidden {
    display : none;
}
Yes. Sorry. My mistake. My problem is not causing by a wrong CSS rule as display: hidden . I use display: none.

To come back to my initial question: is it possible to toggle active/non-active a part of code specifically differentiated when the file is a epub or a kepub?
jiembe is offline   Reply With Quote
Old 05-08-2018, 11:02 PM   #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: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
KePubs created by Calibre have a wrapper <div> with id="book-columns" inside <body>, so you should be able to use this to add KePub-specific CSS. E.g.:

Code:
/* ePub default */
span.mystyle { color: green; }

/* KePub override */
div#book-columns span.mystyle { color: blue; }
GeoffR is offline   Reply With Quote
Old 05-09-2018, 01:27 PM   #10
jiembe
Zealot
jiembe began at the beginning.
 
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
Quote:
Originally Posted by GeoffR View Post

Code:
/* ePub default */
span.mystyle { color: green; }

/* KePub override */
div#book-columns span.mystyle { color: blue; }
How do you implement it? I try this:

.note {
display: block;
}
div#book-columns .note {
display: none;
}

without success. The footnote is still visible at the end of the chapter in the kepub file.

My html code (using a footnote class "nbp") look like this:

<div class="note">
<br/><hr width="33%"/>
<p class="nbp">...
jiembe is offline   Reply With Quote
Old 05-09-2018, 04:51 PM   #11
jiembe
Zealot
jiembe began at the beginning.
 
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
I tried also :

book-columns .note {
display: none;
}
and

div.book-columns .note {
display: none;
}

Same result.
jiembe is offline   Reply With Quote
Old 05-09-2018, 07:24 PM   #12
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Deleted

Last edited by jackie_w; 05-10-2018 at 04:28 AM.
jackie_w is offline   Reply With Quote
Old 05-10-2018, 12:25 AM   #13
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: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
Quote:
Originally Posted by jiembe View Post
How do you implement it? I try this:

.note {
display: block;
}
div#book-columns .note {
display: none;
}

without success. The footnote is still visible at the end of the chapter in the kepub file.
That works on my Glo. How are you creating the KePub? You might try examining the .kepub.epub file after it has been sent to the device to check that Calibre has added the <div id="book-columns"> after <body>, older versions of the KoboTouchExtended driver didn't do this.

Last edited by GeoffR; 05-10-2018 at 12:30 AM. Reason: added closing "
GeoffR is offline   Reply With Quote
Old 05-10-2018, 07:29 AM   #14
jiembe
Zealot
jiembe began at the beginning.
 
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
Quote:
Originally Posted by GeoffR View Post
That works on my Glo. How are you creating the KePub? You might try examining the .kepub.epub file after it has been sent to the device to check that Calibre has added the <div id="book-columns"> after <body>, older versions of the KoboTouchExtended driver didn't do this.
I let Calibre creating the kepub. I have no way to inspect the resulting file.
jiembe is offline   Reply With Quote
Old 05-12-2018, 09:29 AM   #15
cramoisi
Librarian
cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.cramoisi did not drink the Kool Aid.
 
Posts: 346
Karma: 72225
Join Date: Apr 2015
Location: Liège - Belgium
Device: kobo gloHD - KA1
Quote:
Originally Posted by jiembe View Post
I let Calibre creating the kepub. I have no way to inspect the resulting file.
Perhaps you could use the plugin which creates a kepub in calibre in place of the pluging which convert epub to kepub upon sending it on the device ; same author, iirc.

Or you can navigate your plugged kobo like a usb key, find your book within it open the book (a kepub since it's on kobo) with ebook-edit and change the css there.
cramoisi is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
kepub, (x)html and css Sam Sahara Kobo Reader 2 12-23-2017 03:39 PM
Loading a custom CSS on kepub opening met67 Kobo Developer's Corner 51 02-11-2017 02:13 AM
Creating epub/kepub books (docx→epub/kepub via MS Word→Calibre) SJC-Caron ePub 18 04-21-2016 11:10 AM
Conditional CSS for ADE readers democrite ePub 4 09-23-2013 09:10 PM
Conditional CSS rules Jellby ePub 10 01-20-2009 08:32 AM


All times are GMT -4. The time now is 02:54 AM.


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