reddit / emacs
Setup of epub reader nov-mode: "Invalid token detected: Map"
doomvox · 2022-08-09 22:42
I'm trying to set up nov.el, and I'm stuck now that I'm getting an "Invalid token" error when I try to open epub files.
My system-configuration-features includes
LIBXML2
My load-path includes
"/usr/share/emacs/site-lisp/elpa/nov-0.3.0"
Which contains nov.el, nov-pkg.el, nov-autoloads.el and debian-autoloads.el.
My auto-mode-alist includes:
("\\.epub\\'" . nov-mode)
The error comes up even with epubs that pass epubcheck.
Any ideas for what else I might look at?
Running with debug-on-error, the stack backtrace looks like:
Debugger entered--Lisp error: (error "Invalid token detected: Map")
signal(error ("Invalid token detected: Map"))
error("Invalid token detected: %s" "Map")
esxml--tokenize-css-selector("navMap")
esxml-parse-css-selector("navMap")
esxml-query-all("navMap" (ncx ((version ...
esxml-query("navMap" (ncx ...
nov-ncx-to-html("/tmp/nov-fDuIEH.epub/9504/toc.ncx")
nov-render-document()
nov-mode()
...
flexibeast · 2022-08-10 00:21
Superficially, it looks like an issue with malformed markup in the EPUB, though i'm not familiar enough with the EPUB format to know. Does it happen with multiple EPUBs?
doomvox · 2022-08-10 07:32
Yes, I've seen the same error message on several of them-- most of them show minor error messages when examined with epubcheck, but at least one was completely clean, and still had the same behavior.
flexibeast · 2022-08-10 08:16
Are any of them legitimately available for free download? i use nov.el myself, and i've not encountered this issue, so i'd like to explore it locally with one of the problematic EPUBs.
wasamasa · 2022-08-10 14:04
If I'm reading the backtrace correctly, then the bug can be minimized to evaluating the following:
(require 'esxml-query)
(esxml--tokenize-css-selector "navMap")
What Emacs version are you using? Which OS and OS version are you on?
edit: I failed to reproduce this with Docker and Debian 11 (which has nov 0.3.0):
docker run --rm -i -t debian:11 bash
apt update -y
apt install -y curl unzip elpa-nov
curl -LO https://www.gutenberg.org/ebooks/345.epub.images
emacs 345.epub.images
# M-x nov-mode renders the EPUB just fine
Looking closer at the backtrace it does seem nonsensical. Why would it change from processing "navMap" to "Map"? Did you paraphrase or edit the backtrace?
wasamasa · 2022-08-10 14:11
The backtrace suggests it's not the fault of the EPUB because it fails in the esxml-query package parsing the CSS selector.
flexibeast · 2022-08-11 00:56
\*nod\* i guess what i was hoping was to be able to let the OP know that the issue was something specific to their system, if i was able to locally use nov.el to read one of their EPUBs without problems.
doomvox · 2022-08-11 06:36
wasamasa:
> If I'm reading the backtrace correctly, then the bug can be minimized to evaluating the following:
>
> (require 'esxml-query)
> (esxml--tokenize-css-selector "navMap")
Yes, evaluating those expressions duplicates the error:
esxml--tokenize-css-selector: Invalid token detected: Map
> What Emacs version are you using? Which OS and OS version are you on?
emacs-version
GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-03-27, modified by Debian
cat /etc/debian_version
11.4
uname -a
Linux flamenco 5.10.0-16-amd64 #1 SMP Debian 5.10.127-2 (2022-07-23) x86_64 GNU/Linux
> edit: I failed to reproduce this with Docker and Debian 11 (which has nov 0.3.0):
Hm...
> Looking closer at the backtrace it does seem
> nonsensical. Why would it change from processing "navMap"
> to "Map"? Did you paraphrase or edit the backtrace?
I trimmed the long lines where you see " ... ", but that's all.
I'm getting the sense that I must have something peculiar
going on in my own set-up... I was just wondering if I
might have some load-path weirdness, maybe bringing in the
wrong version of something like esxml-query... but that
doesn't seem to be it.
I'm going to have to put this aside for now, but I'll look
it over again when I get a chance... thanks for taking the
report seriously.
doomvox · 2022-08-11 06:38
Sure, this one passes epubcheck:
https://archive.org/download/middlemarch00145gut/pg145.epub
doomvox · 2022-08-11 06:39
> ii was hoping was to be able to let the OP know that the issue was something specific to their system
Yes, I'm getting that sense, too.
flexibeast · 2022-08-11 06:46
Yeah, that opened without issues here. My own setup: Gentoo, Emacs 28.1. nov.el 20220805.2031 and esxml 20220506.759 from MELPA.