koreader / koreader

An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices
http://koreader.rocks/
GNU Affero General Public License v3.0
16.64k stars 1.26k forks source link

Annotation improvements #11451

Closed Huahddd closed 8 months ago

Huahddd commented 8 months ago

Does your feature request involve difficulty completing a task? Please describe.

After turning on the function of displaying comments in bullet comments, some books still have jump comments, which affects the reading experience.

Describe the solution you'd like

  1. Is it possible to force all comments to pop-up comments to achieve functions similar to kindle and boox readers? I know this function is difficult to implement. Among the global e-paper readers, only Kindle and BOX have implemented the function of pop-up comments for all comments.

  2. Is it possible to realize the function of displaying comments as footnotes, that is, to implement a function similar to alreadyreader. This function of alreader is great. Koreader is currently the best e-book reading software. It has a perfect display function, but unfortunately it cannot convert comments into footnotes. I really hope that this function can be added. I recently came into contact with the software Alreader. It has very poor support for fonts specified by the css of epub files, but its footnote function is amazing.

Huahddd commented 8 months ago

book.zip

This e-book cannot be annotated in koreader

Huahddd commented 8 months ago

Or is it possible to transfer the annotations into the text?

poire-z commented 8 months ago

Possibly automated translations, but I think that with "comments" and "annotations" we should read "footnotes".

We do support both kind of footnote display like you are describing, see the two screenshots at the top of https://github.com/koreader/koreader/issues/6100#issuecomment-620453003 - and look around in the issues or wiki for "popup footnotes" or "inpage footnotes".

But we support all that only when the book is sufficiently well made.

This e-book cannot be annotated in koreader

Indeed, nothing works with this book :/ for one single reason: the footnote link is an image:

image

It's not really that this is bad practice for a book, but all our code fails with such "only an IMG in a link", because nobody ever thought about that case :)

We could fix the code (it's a bug), but this case is so rare (you're the first to report about such a book) that I don't feel like spending time on that... :/

If your links just had a bit of text inside the link near the image, it would work (I added these 123 and 456 myself in the epub):

Inpage footnotes: image

Popup footnote when tap on "456": image

I can't think of any "style tweak" solution to solve the problem with this book. (Adding some pseudo text content with a.duokan-footnote:before{content:'1'} does not help, this text is too pseudo/virtual for the code to trigger...)

The solution to go on reading with this book would be to edit all its html files and prefix all <img alt="" class="calibre13" src="../images/00005.jpeg"/> with an invisible caractere that will be enough to give them some text consistency: ​ &#x200B;<img alt="" class="calibre13" src="../images/00005.jpeg"/>

Huahddd commented 8 months ago

book1.zip

Thank you very much for your reply. That is indeed an automatic translation, my English is not very good, that is the footnote.

First of all, for in-page footnotes, I think this is a great feature. Alreader can turn all comments into in-page footnotes (regardless of whether the epub format specifies in-page footnotes). I very much hope that koreader can also have this function.

Secondly, regarding pop-up footnotes, epub files with pictures as footnote links are very common in China. It originates from the production specifications of an e-book vendor called Duokan. Duokan provides a lot of carefully crafted books, and its footnote links Almost all pictures. These carefully typed and produced books are highly sought after in China, similar to the Standard Ebooks program. The software koreader is very popular in China. Almost every Chinese who uses an ink screen reader has used or heard of this software. I see your reply that you can fix it (I'm not sure if the automatic translation is wrong), and I really hope you can make the link with the image as a footer also pop up.

In addition, another e-book also uses pictures as footnote links, but it can realize the pop-up of footnotes. I have uploaded the file of that e-book, please give me some guidance.

Finally, I really hope you can fix that bug so that links with images as footnotes can pop up.

I've also seen some discussion about in-page footnotes, but I didn't fully understand that discussion due to automatic translation issues. Alreader's forced in-page footnotes are a great feature. Can koreader implement this feature? Is it very difficult to implement this feature? To be honest, this feature amazes me. Unfortunately, alreader is far inferior to koreader in other aspects......QAQ

Finally, I have to say that koreader is a really great software. In China, koreader is recognized as the best ink screen reading software!!! Thank you for your long patient reply, God bless you!!!

poire-z commented 8 months ago

Alreader can turn all comments into in-page footnotes (regardless of whether the epub format specifies in-page footnotes). I very much hope that koreader can also have this function. Alreader's forced in-page footnotes are a great feature. Can koreader implement this feature? Is it very difficult to implement this feature?

Because AIReader's authors are more clever than I am ? :) I have no idea how they do that (or maybe they don't have to render the whole document and cut pages, and can do that dynamically on the fly like we may do with popup footnotes). https://github.com/koreader/koreader/issues/9780#issuecomment-1368715194 More technical answers about why we can't do it automatically in #9780 and in these ones: https://github.com/koreader/koreader/issues/5925#issuecomment-611488700 https://github.com/koreader/koreader/issues/11411#issuecomment-1913228054

Secondly, regarding pop-up footnotes, epub files with pictures as footnote links are very common in China. [...] I see your reply that you can fix it (I'm not sure if the automatic translation is wrong), and I really hope you can make the link with the image as a footer also pop up.

Ok, I'll keep that in my "to think about" list.

In addition, another e-book also uses pictures as footnote links, but it can realize the pop-up of footnotes. I have uploaded the file of that e-book, please give me some guidance.

This one has better hints in their HTML: image this little attribute in yellow (missing in your first book) is enough to make "tap on link show as footnote popup" work. They did that well on the link side, and I thought they would have done it well on the target side, and if they had, you would get inpage-footnotes automatically. But they didn't: image If they had put the yellow attribute on the <li> in green, it would have been 1) the right way to use that attrivute and 2) make inpage-footnote just happen. You could still get them with a bookstyletweak that you would need to write, but many good things depend on the publisher doing the right thing.

Huahddd commented 8 months ago

If your links just had a bit of text inside the link near the image, it would work (I added these 123 and 456 myself in the epub):

Inpage footnotes: image

Popup footnote when tap on "456": image

I can't think of any "style tweak" solution to solve the problem with this book. (Adding some pseudo text content with a.duokan-footnote:before{content:'1'} does not help, this text is too pseudo/virtual for the code to trigger...)

The solution to go on reading with this book would be to edit all its html files and prefix all <img alt="" class="calibre13" src="../images/00005.jpeg"/> with an invisible caractere that will be enough to give them some text consistency: ​&#x200B;<img alt="" class="calibre13" src="../images/00005.jpeg"/>

You are great, thank you very much for your guidance, I used sigil to batch change the <img alt="" class="calibre13" src="../images/00005.jpeg"/> to &#x200B; <img alt="" class="calibre13" src="../images/00005.jpeg"/>, now it can pop up footnotes. However, I still hope that you can fix the bug that pictures cannot be linked as footnotes, which will save a lot of time in modifying files.

But I still can't implement in-page footnotes. How do you achieve in-page footnotes? I'm really looking forward to your guidance.

I still want to thank you for your guidance. I implemented pop-up footnotes, which helped a lot in my reading experience.

poire-z commented 8 months ago

In both your books, looking at the footnotes (select text spanning 3 of them, and View HTML): image each footnote content is inside a <li class="duokan-footnote-item">...</li>

So, you need to Style tweaks > Book style tweak, and input: image

This currently still needs the link to have some "consistency", like your changes to the first book did.

Can you check in a few other such "duokan" books that they all use these <li class="duokan-footnote-item"> to wrap footnotes ? If yes, we could add .duokan-footnote-item in there: https://github.com/koreader/koreader/blob/bdd475f55f9fe0530cbc3fd9825814831bdd86f7/frontend/ui/data/css_tweaks.lua#L953-L975 so you don't have to edit a Book style tweak, and just enable this style tweak. Although it would currently not work when the link is only an image.

Huahddd commented 8 months ago

So, you need to Style tweaks > Book style tweak, and input: image

I added and used this style tweak, but the in-page footer still wasn't implemented. Maybe it's because the automatic translation is wrong and I misunderstood what you meant? Looking forward to your guidance.

Today is the Chinese New Year, I wish you a happy new year! ​

poire-z commented 8 months ago

I added and used this style tweak, but the in-page footer still wasn't implemented. Maybe it's because the automatic translation is wrong and I misunderstood what you meant?

You understood well. If you're doing that on the book where you added these &#x200B;, it should be enough to work. No idea why it doesn't. Sure it is checked: image and no typo when you entered the text I suggested ? li.duokan-footnote-item {-cr-hint: footnote-inpage;}

Huahddd commented 8 months ago

I added and used this style tweak, but the in-page footer still wasn't implemented. Maybe it's because the automatic translation is wrong and I misunderstood what you meant?

You understood well. If you're doing that on the book where you added these &#x200B;, it should be enough to work. No idea why it doesn't. Sure it is checked: image and no typo when you entered the text I suggested ? li.duokan-footnote-item {-cr-hint: footnote-inpage;}

oh! You are wonderful! I don’t know how to describe my mood. Through your code, I successfully implemented in-page comments.

In addition, I would like to know how other books that do not have Dukan typesetting can implement in-page footnotes through style adjustments. I uploaded two books.

book2.zip

You made the two books I uploaded in the past implement in-page footnotes through simple style adjustments. Is it possible to create a style adjustment file so that all e-books can implement in-page footnotes?

Due to the time difference, it is already late at night here. Thank you for your style adjustment file. It gave me a great surprise. ​

poire-z commented 8 months ago

You made the two books I uploaded in the past implement in-page footnotes through simple style adjustments. Is it possible to create a style adjustment file so that all e-books can implement in-page footnotes?

No, it's not possible, to have it automatically working on all e-books. Reasons explained in the linked issues.

We have various existing (non Book-) style tweaks in the Style tweaks menu > In-page footnotes, EPUB or Classic classnames, that you can try on new books When these don't work, you have to investigate the HTML and create such Book style tweak. I won't do that for you on book2.zip, book3.zip, book4.zip... book 43.zip :) It's best if you try, test and learn, and surprise yourself yourself ! - I am that wonderful :) You can read in the various issues I linked, ie. https://github.com/koreader/koreader/issues/9780#issuecomment-1312838063 (really similar to what I did with the screenshots above), how to go at that.

pkb commented 8 months ago

I have no idea how they do that (or maybe they don't have to render the whole document and cut pages, and can do that dynamically on the fly like we may do with popup footnotes).

I guess only crenigne does render the whole document :) Alreader definitely doesn't. Nevertheless, his latest version AlreaderX requires links to be properly formatted in order to display them as footnotes.

Huahddd commented 8 months ago

You can read in the various issues I linked, ie. #9780 (comment) (really similar to what I did with the screenshots above), how to go at that.Style tweaks menu > In-page footnotes

Thank you, based on your experience, I spent half a day successfully writing style adjustment files based on several books with simple styles, and implemented in-page footnotes. But I am still powerless when faced with complex e-books.

I uploaded two pictures, one is a style adjustment file I wrote, and the other picture is a screenshot of a file I don’t know how to adjust the style.

Looking forward to your guidance!!

In addition, I successfully implemented in-page footnotes in basic books. Although this is only the simplest style, it makes me very excited!!!

1 2

Huahddd commented 8 months ago

I guess only crenigne does render the whole document :) Alreader definitely doesn't. Nevertheless, his latest version AlreaderX requires links to be properly formatted in order to display them as footnotes.

Alreader implements in-page footnotes without requiring the correct format of the e-book. This surprised me very much. This feature is great.

poire-z commented 8 months ago

the other picture is a screenshot of a file I don’t know how to adjust the style.

Indeed, on your screenshot, the <p> don't have enough "properties" to distinguish them from other <p> in the book. So, you'd need to look around, at their parents. If you select text spanning 2 or 3 footnotes in KOReader, and hit View HTML, you will see bits about their parents, like in https://github.com/koreader/koreader/issues/5925#issuecomment-596078631.

Ie. if the bits from your screenshots are contained in a <div class=allFootnotes>, you would use: div.allFootnotes > p { -cr-hint: footnote-inpage; } which means "all p direct children of <div class=allFootnotes>". If the container does not have a class, and if by chance all the footnotes are at the end in a single html file, you could use: DocFragment[id=_doc_frament_72] p { -cr-hint: footnote-inpage; } which means "all p descendants of a <DocFragement id="_doc_fragment_72">.

With some books, there won't be any solution to get footnotes, so we have to live without.

Huahddd commented 8 months ago

the other picture is a screenshot of a file I don’t know how to adjust the style.

Indeed, on your screenshot, the don't have enough "properties" to distinguish them from other in the book. So, you'd need to look around, at their parents. If you select text spanning 2 or 3 footnotes in KOReader, and hit View HTML, you will see bits about their parents, like in #5925 (comment).<p>``<p>

Ie. if the bits from your screenshots are contained in a , you would use: which means "all p direct children of ". If the container does not have a class, and if by chance all the footnotes are at the end in a single html file, you could use: which means "all p descendants of a .<div class=allFootnotes>``div.allFootnotes > p { -cr-hint: footnote-inpage; }``<div class=allFootnotes>``DocFragment[id=_doc_frament_72] p { -cr-hint: footnote-inpage; }``<DocFragement id="_doc_fragment_72">

With some books, there won't be any solution to get footnotes, so we have to live without.

Now that all my questions have been answered, I decided to just style the e-book in a simple format (that's all I can do).

Thank you very much for your patient guidance these days, you are great!!!

I hope that the next update of koreader can fix the error that the footnotes that use pictures as links cannot pop up.

I wish you a happy life and thank you again for your patient answers and guidance.

pkb commented 8 months ago

Alreader implements in-page footnotes without requiring the correct format of the e-book. This surprised me very much. This feature is great.

When this feature was implemented in Alreader, there was no correct (standard) way to specify footnotes in EPUB. Now, when there is one, the author gave up on this feature, although I must admit it was quite popular.

poire-z commented 8 months ago

When this feature was implemented in Alreader, there was no correct (standard) way to specify footnotes in EPUB. Now, when there is one, the author gave up on this feature, although I must admit it was quite popular.

Good to know. May be it was doing what we still do for "popup footnotes" (see the link "use heuristics" in https://github.com/koreader/koreader/issues/11411#issuecomment-1913228054). If they don't render the full book, and just have to lay out a page when displaying, they could do that dynamically.

Btw @pkb, are you using KOReader ? or still just CoolReader on Windows/Linux (from what I gathered at the time, or you were just testing with that) ?

pkb commented 8 months ago

If they don't render the full book, and just have to lay out a page when displaying, they could do that dynamically.

The author is one person (Alan) you may find him mentioned in hyphman.cpp. Yes I think some kind of heuristics, in addition the size of the footnote is limited by couple of lines plus link to the actual text.

pkb commented 8 months ago

I use CoolReader on Android/Pocketbook sometimes Windows. I'm thinking about switching to KOReader on pocketbook because CoolReader is outdated there.

poire-z commented 8 months ago
  • for popup footnotes, we somehow try to do text-selection for the link - and images are not part of text selection, so this results in each link in this page having zero-surface, and so not considered a valid link to a footnote

    • for inpage footnotes, the code only work on them when meetings text words

We could fix the code (it's a bug), but this case is so rare (you're the first to report about such a book) that I don't feel like spending time on that... :/

OK, I think I can fix both of the issues, so you'll be able to get both kind of footnotes, without having to edit the book. (If #11460 gets some ok, as it's quite related.) May be not in the next stable release, but in the one after as the changes may cause other issues.

image

image

Can you check a few of your other Duokan books if they all have each footnote properly wrapped in a class="duokan-footnote-item" (your 2 books do). It's fine if some books do not have anything, but if they have it, it should wrap each individual footnote, and NOT more than one. If yes, we can include it in the list of common class name for the In-page classic classname footnotes style tweak present in the menu.

Huahddd commented 8 months ago

Can you check a few of your other Duokan books if they all have each footnote properly wrapped in a (your 2 books do). It's fine if some books do not have anything, but if they have it, it should wrap each individual footnote, and NOT more than one. If yes, we can include it in the list of common class name for the style tweak present in the menu.class="duokan-footnote-item"``In-page classic classname footnotes

oh! You are wonderful! You gave the solution so quickly. Yes, most books in standard format use duokan-footnote-item as footnote links. In addition, I found that there are many books with fnote and fnote1 as footnote links (kindle e-books account for the vast majority). I will upload those books as sample reference for you.

[Uploading duokan.zip…]() fnote.zip

Huahddd commented 8 months ago

1

I found many books with the same footnote style, I'm not sure if this is a typical footnote style, I uploaded three e-books as samples for your reference. style=text-indent.zip