From 08da6ebe6a46b15d3508059de75d79076d443965 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Wed, 6 Apr 2022 19:26:19 +0200 Subject: Bump version requirements to use dom.el --- nov.el | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/nov.el b/nov.el index 9ab75b1..5f38137 100644 --- a/nov.el +++ b/nov.el @@ -5,7 +5,7 @@ ;; Author: Vasilij Schneidermann ;; URL: https://depp.brause.cc/nov.el ;; Version: 0.3.4 -;; Package-Requires: ((dash "2.12.0") (esxml "0.3.6") (emacs "24.4")) +;; Package-Requires: ((dash "2.12.0") (esxml "0.3.6") (emacs "25.1")) ;; Keywords: hypermedia, multimedia, epub ;; This file is NOT part of GNU Emacs. @@ -44,6 +44,7 @@ ;;; Code: (require 'cl-lib) +(require 'dom) (require 'dash) (require 'esxml-query) (require 'image) @@ -223,7 +224,7 @@ If PARSE-XML-P is t, return the contents as parsed by libxml." "Return the content filename for CONTENT." (let* ((query "container>rootfiles>rootfile[media-type='application/oebps-package+xml']") (node (esxml-query query content))) - (esxml-node-attribute 'full-path node))) + (dom-attr node 'full-path))) (defun nov-container-valid-p (directory) "Return t if DIRECTORY holds a valid EPUB container." @@ -248,7 +249,7 @@ If PARSE-XML-P is t, return the contents as parsed by libxml." (defun nov-content-version (content) "Return the EPUB version for CONTENT." (let* ((node (esxml-query "package" content)) - (version (esxml-node-attribute 'version node))) + (version (dom-attr node 'version))) (when (not version) (error "Version not specified")) version)) @@ -258,7 +259,7 @@ If PARSE-XML-P is t, return the contents as parsed by libxml." This is used in `nov-content-unique-identifier' to retrieve the the specific type of unique identifier." (let* ((node (esxml-query "package[unique-identifier]" content)) - (name (esxml-node-attribute 'unique-identifier node))) + (name (dom-attr node 'unique-identifier))) (when (not name) (error "Unique identifier name not specified")) name)) @@ -268,7 +269,7 @@ the specific type of unique identifier." (let* ((name (nov-content-unique-identifier-name content)) (selector (format "package>metadata>identifier[id='%s']" (esxml-query-css-escape name))) - (id (car (esxml-node-children (esxml-query selector content))))) + (id (car (dom-children (esxml-query selector content))))) (when (not id) (error "Unique identifier not found by its name: %s" name)) (intern id))) @@ -290,8 +291,7 @@ Required keys are 'identifier and everything in `nov-optional-metadata-tags'." (let* ((identifier (nov-content-unique-identifier content)) (candidates (mapcar (lambda (node) - (cons (esxml-node-tag node) - (car (esxml-node-children node)))) + (cons (dom-tag node) (car (dom-children node)))) (esxml-query-all "package>metadata>*" content))) (required (mapcar (lambda (tag) (let ((candidate (cdr (assq tag candidates)))) @@ -309,19 +309,19 @@ Required keys are 'identifier and everything in "Extract an alist of manifest files for CONTENT in DIRECTORY. Each alist item consists of the identifier and full path." (mapcar (lambda (node) - (-let [(&alist 'id id 'href href) (esxml-node-attributes node)] + (-let [(&alist 'id id 'href href) (dom-attributes node)] (cons (intern id) (nov-make-path directory (nov-urldecode href))))) (esxml-query-all "package>manifest>item" content))) (defun nov-content-spine (content) "Extract a list of spine identifiers for CONTENT." - (mapcar (lambda (node) (intern (esxml-node-attribute 'idref node))) + (mapcar (lambda (node) (intern (dom-attr node 'idref))) (esxml-query-all "package>spine>itemref" content))) (defun nov--content-epub2-files (content manifest files) (let* ((node (esxml-query "package>spine[toc]" content)) - (id (esxml-node-attribute 'toc node))) + (id (dom-attr node 'toc))) (when (not id) (error "EPUB 2 NCX ID not found")) (setq nov-toc-id (intern id)) @@ -332,7 +332,7 @@ Each alist item consists of the identifier and full path." (defun nov--content-epub3-files (content manifest files) (let* ((node (esxml-query "package>manifest>item[properties~=nav]" content)) - (id (esxml-node-attribute 'id node))) + (id (dom-attr node 'id))) (when (not id) (error "EPUB 3