Git Product home page Git Product logo

nov.el's Introduction

nov.el

https://raw.github.com/wasamasa/nov.el/master/img/novels.gif

About

nov.el provides a major mode for reading EPUB documents.

Features:

  • Basic navigation (jump to TOC, previous/next chapter)
  • Remembering and restoring the last read position
  • Jump to next chapter when scrolling beyond end
  • Renders EPUB2 (.ncx) and EPUB3 (<nav>) TOCs
  • Hyperlinks to internal and external targets
  • Supports textual and image documents
  • View source of document files
  • Metadata display
  • Image rescaling

Screenshot

https://raw.github.com/wasamasa/nov.el/master/img/scrot.png

Installation

Set up the MELPA or MELPA Stable repository if you haven't already and install with M-x package-install RET nov RET.

Setup

Make sure you have an unzip executable on PATH, otherwise the extraction of EPUB files will fail. If you for some reason have unzip in a non-standard location, customize nov-unzip-program to its path. You'll also need an Emacs compiled with libxml2 support, otherwise rendering will fail.

Put the following in your init file:

(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))

Customization

While the defaults make for an acceptable reading experience, it can be improved with any of the following changes:

Default font

To change the default font, use M-x customize-face RET variable-pitch, pick a different family, save and apply. If you dislike globally customizing that face, add the following to your init file:

(defun my-nov-font-setup ()
  (face-remap-add-relative 'variable-pitch :family "Liberation Serif"
                                           :height 1.0))
(add-hook 'nov-mode-hook 'my-nov-font-setup)

To completely disable the variable pitch font, customize nov-variable-pitch to nil. Text will be displayed with the default face instead which should be using a monospace font.

Text width

By default text is filled by the window width. You can customize nov-text-width to a number of columns to change that:

(setq nov-text-width 80)

It's also possible to set it to a huge number to inhibit text filling, this can be used in combination with visual-line-mode and packages such as visual-fill-column to implement more flexible filling:

(setq nov-text-width most-positive-fixnum)
(setq visual-fill-column-center-text t)
(add-hook 'nov-mode-hook 'visual-line-mode)
(add-hook 'nov-mode-hook 'visual-fill-column-mode)

Rendering

In case you're not happy with the rendering at all, you can either use nov-pre-html-render-hook and nov-post-html-render-hook to adjust the HTML before and after rendering or use your own rendering function by customizing nov-render-html-function to one that replaces HTML in a buffer with something nicer than the default output.

Here's an advanced example of text justification with the justify-kp package:

(require 'justify-kp)
(setq nov-text-width most-positive-fixnum)

(defun my-nov-window-configuration-change-hook ()
  (my-nov-post-html-render-hook)
  (remove-hook 'window-configuration-change-hook
               'my-nov-window-configuration-change-hook
               t))

(defun my-nov-post-html-render-hook ()
  (if (get-buffer-window)
      (let ((max-width (pj-line-width))
            buffer-read-only)
        (save-excursion
          (goto-char (point-min))
          (while (not (eobp))
            (when (not (looking-at "^[[:space:]]*$"))
              (goto-char (line-end-position))
              (when (> (shr-pixel-column) max-width)
                (goto-char (line-beginning-position))
                (pj-justify)))
            (forward-line 1))))
    (add-hook 'window-configuration-change-hook
              'my-nov-window-configuration-change-hook
              nil t)))

(add-hook 'nov-post-html-render-hook 'my-nov-post-html-render-hook)

This customization yields the following look:

https://raw.github.com/wasamasa/nov.el/master/img/justify-kp.png

Usage

Open the EPUB file with C-x C-f ~/novels/novel.epub, scroll with SPC and switch chapters with n and p. More keybinds can be looked up with F1 m.

Contributing

See CONTRIBUTING.rst.

Alternatives

The first one I've heard of is epubmode.el which is, well, see for yourself. You might find ereader more useful, especially if you're after Org integration and annotation support.

nov.el's People

Contributors

aplaice avatar hasimir avatar wasamasa avatar xiongtx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.