|
|
#1 |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Apr 2026
Device: Calibre
|
Direct annotations through CSS, is it practical?
I'm quite a fan of annotations but the fact that they don't really stay inside EPUB files sort of bugs me.
So how viable and safe is it to simply edit the CSS of the EPUB itself, through the Calibre EPUB Editor for instance, using a class like ``` .highlightgreen { background-color: lightgreen; } ``` Do you think it would be safe and is there a plugin that supports it? The methods most people mention don't involve editing the EPUB directly but using external metadata
|
|
|
|
|
|
#2 |
|
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 191
Karma: 1537710
Join Date: Jul 2021
Device: N/A
|
First of all, I guess you're aware that you can annotate an epub wjhen you're using the calibre's epub reader, annotations are stored inside the epub itself, in the "calibre_bookmarks.txt" file (in the prefs, choose miscellaneous / "Keep a copy of annotations/bookmarks in the e-book file, for easy sharing").
But, of course, they are readable only with the calibre's epub reader itself, not even the editor is understanding the content of the file calibre_bookmarks.txt. If you want to be able to share the annotations with other people that don't use calibre, you're solution is possible, but it needs to write a plugin that, for example with a button on the toolbar, get the current selection and put it inside a span using the css class you've told (the same plugin would create this class at its first call in the current epub). So it's not a trivial solution. Edit: Or another one that — using the code that Kovid already wrote in the ebook-viewer — would get the content of calibre_bookmarks.txt and put it inside the code of the epub. Last edited by lomkiri; 04-04-2026 at 11:18 AM. |
|
|
|
|
|
#3 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,679
Karma: 64144480
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
The CSS is where you create a STYLE that the book can use.
You would the need to add a span class= "highlightgreen"> around the annotation anchor text. |
|
|
|
|
|
#4 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,811
Karma: 9501034
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Quote:
<mark>This is some text I need to highlight/annotate</mark> My CSS mark { background-color: yellow; } https://developer.mozilla.org/en-US/.../Elements/mark Last edited by Karellen; 04-04-2026 at 01:48 PM. |
|
|
|
|
|
|
#5 | |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Apr 2026
Device: Calibre
|
Quote:
|
|
|
|
|
|
|
#6 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,811
Karma: 9501034
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
The <mark> tag is a standard tag, so it won't "break" any ereader or app. If it does, then get rid of it as it is not a compliant reader.
To avoid the accident, run a CheckBook (Calibre) or EPUBCheck to ensure you did not type an extra bracket. |
|
|
|
|
|
#7 |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Apr 2026
Device: Calibre
|
Oh, that's good to know. But that makes me wonder why this function hasn't been implemented in any mainstream ereader. After all, <mark> by itself is yellow by default afaik (I have very little experience with CSS). For a minimalist approach all they'd have to do is add <mark> and a closing tag around the targeted sentence/word. Maybe it's because epubs are compressed and it would be difficult to edit them in that state?
|
|
|
|
|
|
#8 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,811
Karma: 9501034
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Save annotations to a file in ebook viewer, then view these annotations in the browse | Sys_eng | Library Management | 2 | 11-10-2023 09:41 PM |
| Libra 2 "Unable to import annotations as the annotations column has not been configured..." | Liudprand | Kobo Reader | 2 | 07-29-2023 10:56 PM |
| Annotations: Capture/Convert Kobo-Kindle (uses OpenWith and Annotations Plugins) | EnergyLens | Related Tools | 12 | 03-28-2020 01:04 PM |
| Pdf annotations and Kindle annotations | BranMakMorn | Calibre | 0 | 06-25-2011 02:42 PM |
| css pseudo elements and adjacent combinators in extra css? | ldolse | Calibre | 2 | 12-21-2010 05:09 PM |