wasamasa / nov.el

Major mode for reading EPUBs in Emacs
GNU General Public License v3.0
654 stars 34 forks source link

Prevents image rendering in terminal-based Emacs. #56

Closed jonbakke closed 5 years ago

jonbakke commented 5 years ago

Bug: nov.el fails to render any content within a chapter after the first image on a Raspberry Pi 3 running Raspbian Buster in terminal-based Emacs. Emacs reports an "Invalid image type 'jpeg'" error with a backtrace from shr-descend through nov-render-img, nov-insert-image, create-image, and image-type before generating that error.

Making the body of nov-render-img conditional on display-graphic-p appears to fix this.

I suspect the bug of image handling in a terminal environment is actually located in shr, but the backtrace includes several copies of a lisp-ified version of the html file, which I found unfriendly to debug. So this is a bit of a hack. :-\

This problem did not arise on Debian Buster (amd64; non-graphic) or macOS (10.14, running emacs-plus from Homebrew; graphic and non-graphic). This change was tested in each and does not appear to create any problems in any of these environments.

wasamasa commented 5 years ago

I've fixed the issue in a more systematic way by adjusting the custom image rendering function to handle textual mode and unsupported image types. Let me know if you find any other way to break it.

jonbakke commented 5 years ago

This comment is to confirm that your fix solves my issue. Adding alt tag or path appears sensible and useful, too.

Thank you! I rather appreciate being able to read epub files so easily and cleanly in Emacs.