jumper047 / fb2-reader

Emacs plugin to read .fb2 and .fb2.zip ebooks.
GNU General Public License v3.0
25 stars 2 forks source link

Failure to render a file #7

Open vlichevsky opened 2 years ago

vlichevsky commented 2 years ago

Some files cannot be rendered by fb2-reader. I get the following error:

Error during redisplay: (eval (list (propertize " " 'display '((space :align-to 0))) (fb2-reader-header-line-text))) signaled (wrong-type-argument number-or-marker-p nil) [4 times]
error in process sentinel: Invalid read syntax: "#" [2 times]
Error during redisplay: (eval (list (propertize " " 'display '((space :align-to 0))) (fb2-reader-header-line-text))) signaled (wrong-type-argument number-or-marker-p nil)

Sample file

jumper047 commented 2 years ago

Interesting! Seems like something wrong with the book - libxml-parse-xml-region returns nil. But for some reason libxml-parse-html-region works fine. It need some research.

jumper047 commented 2 years ago

I found the string which causes an issue - "

юkжэ

". Not sure what this supposed to mean. Also links in the book are not proper fb2 links, which is strange too. I suppose this is because of software used to produce this fb2. Do you have other books which are not rendered by fb2-reader?

vlichevsky commented 2 years ago

Yeah, looks like this file contains a mix of cp-1251 encoding with some other, or even just random garbage. I haven't noticed this before, because the fb2 reader I currently use (FBReader) somehow manages to display it. I am not sure, whether it is worth it to try and render such files. A more clear error message would be nice though. If I find books which are not rendered by fb2-reader and not of trash quality like this one I'll report in this issue.

jumper047 commented 2 years ago

I also noticed another thing - there is no bodies inside that book (as far as I know they should be in correct fb2 document). So I can get xml tree from the book, but my parser can't parse it correctly because of xml structure. Document metadata mentioned software name used to produce it - LibRusEc kit, maybe it produces special fb2 "flavor". So support for such type of files seems doable, but I need more info / book examples. Help is appreciated!:). For now I'll add message in case reader couldn't parse book.

jumper047 commented 2 years ago

Update: adding messages is boring, so I fixed rendering for this type of books - commits already pushed so you'll receive update soon.

vlichevsky commented 2 years ago

Another problematic file: https://transfer.sh/CIvCgs/eko_imya-rozy.8ndkkg.460991.fb2.gz

Fails with the same message as in the first post.

jumper047 commented 2 years ago

Thx, seems like my previous suggestion about how parse-html works was incorrect. Hope I'll fix it soon.

jumper047 commented 2 years ago

Should be fixed now - also added messages when fb2 parsing failed.

vlichevsky commented 2 years ago

Thanks! Broken files can be displayed now. Although Error during redisplay: ... is still shown for some files (but they are rendered OK).

jumper047 commented 2 years ago

Nice! Though I'll leave this issue open until I figure out redisplay error.