12

I use eww to read online articles in Emacs instead of in a browser because it is less distracting and I can take notes in an org-mode quickly without switching applications.

I wonder how feasible it is to read an e-books in epub, or pdf format in Emacs? I found the epubmode.el on emacswiki.org but it is broken and haven't been updated since 2011.

  • 3
    Opening PDF should work out of the box. – Malabarba Mar 27 '15 at 9:53
  • 3
    And the pdf-tools package makes them look and behave even better. At this point I'm frustrated using anything else. – wdkrnls Mar 27 '15 at 15:35
7

Try nov (installable via melpa). It is a reasonable start for reading ePUBs in Emacs.

| improve this answer | |
4

.epub are in fact .zip file with .xhtml file inside. You can just open them, find the .xhtml file that has the content (often content.html), and open it. Then you can call shr-render-buffer to display the html.

This do not solve several problem:

  • finding automatically the correct .xhtml
  • use the table of content,
  • bigger epub have several .xhtml (say, one by chapter), one need a way to go from one to the next.
  • 1
    shr-render-buffer is great! I can go though all the xhtml files and convert all to a single org file, based on the table of content. thanks! – yi.tang.uni Mar 27 '15 at 14:47
  • I don't seem to have shr-render-buffer in emacs 24.3? It also looks like someone started to make an epub-mode, but I was unable to get that working either: emacswiki.org/emacs/EpubMode – Brian Z Nov 8 '15 at 6:42
  • Ah... I had to load shr with load-library. Still not working very well though! A real, working epub-mode would be nice. – Brian Z Nov 8 '15 at 6:49
  • The emacspeak package has a mode for reading epub files in eww. I use it all the time. You won't want the whole emacspeak package, but you should be able to use how it does this as a way to roll your own solution. – Tim X Feb 25 '17 at 23:40
2

I recommend emacs-ereader. My experience is that it errs out less often while parsing an epub than nov and it too is installable as a package. Further, it supports annotations, integrates decent with Org, in a slightly more primitive way than the awesome pdf-tools does for PDFs.

| improve this answer | |
  • FYI, invalid EPUBs are not supported in nov.el. If you run into a valid EPUB still triggering errors, please report a bug and send me the file via email or so. – wasamasa Mar 3 '19 at 7:44
1

EDIT
Actually this answer seems more useful than presumed initially. I only tried this method on one book, and that book's conversion looked bad. I have tried multiple other books now, and most look reasonably well after conversion. Still, it might be possible to make the conversion look even better using mutool its epub/css config options.
END EDIT

Although maybe not a very useful answer here, I still like to inform about the following possibility.

Emacs comes with doc-view-mode already. If you have the mutool command available on your system then Emacs doc-view-mode will use it to convert pdf's to png. Now mutool is also able to convert epub to png. So by making doc-view to recognize an epub as a pdf, i.e. add ("epub" pdf) to the pdf options in the doc-view-set-doc-type function, you can read an epub by opening your epub file and then switch to doc-view-mode. The conversion takes some time, and it takes a while (~30sec) before the png image will appear.

Now I tried this succesfully myself, but the converted document did not look great. However, the mutool draw command offers some configuration options for epub conversion. Unfortunately I do not understand these options well yet, as mutool tells me the following when using a very simple css stylesheet.

error: css syntax error: expected keyword in property (content/stylesheet.css:3)

Maybe someone who understands mupdf or css or epub could comment on this answer for how to get a nice epub conversion with mutool. Then doc-view-mode might be another nice option for reading epubs (and a feature request could be opened for official epub support in doc-view-mode).

| improve this answer | |
  • That's a clever idea! Perhaps you should ask about the problem with css styling with mutool, as a separate question, though? – aplaice Jul 19 at 9:14
  • @aplaice Thanks! I agree that the css styling question might be better asked separately, but also I figured that many people here know css or epub well and someone here might be able to answer it. I am not very familiar with css nor with epub. I have edited the answer btw, because most books look much better than the one I tried first. – dalanicolai Jul 19 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.