johnfactotum / foliate

Read e-books in style
https://johnfactotum.github.io/foliate/
GNU General Public License v3.0
6.38k stars 293 forks source link

FR: Use paragraph number for citation #1364

Open DominiqueSite opened 3 months ago

DominiqueSite commented 3 months ago

Is your feature request related to a problem? Please describe. There is currently no usable citation feature, which is an essential feature for academic usage.

Describe the solution you'd like The common recommendation for citing EPUBs is to use paragraph numbering; i.e. counting the paragraphs from the beginning of the section/chapter:

It would also be great to have an option in the Layout>Paragraph settings to enable "Show paragraph numbers" for adding paragraph numbers next to the text.

Describe alternatives you've considered Location numbers are not usable for citation as they can only be referenced by a reader with access to the same EPUB and may be inconsistent (depending on the EPUB viewer and the layout settings). CFIs are usable only in EPUBs, which suffices for hyperlinking but is inadequate for citation purposes (e.g. the reader of an academic paper might only have the paperback edition of a cited book).

Additional context "Authored pages" would be best for citation purposes, but are often not available.

johnfactotum commented 3 months ago

Paragraph counts can be problematic both because of the lack of a precise definition (e.g., how would you count lists?) and because books are often poorly marked up (e.g. many use <p> for headings, or <div> for paragraphs). So the count can be ambiguous and may not match how one would count in the print edition. (It's worth noting that, you can use the CFI as a paragraph count of sorts, as it basically shows an element count.)

Practically, I suppose it should just do whatever Calibre does in its "Reference Mode", which simply enumerates all the <p> elements: https://github.com/kovidgoyal/calibre/blob/6d4114f4738d5b8807ce726337156607c7ff7fed/src/pyj/read_book/referencing.pyj#L15-L16