From 39d335679c8476b1d7eb9a6f5435b1aa8b412e9e Mon Sep 17 00:00:00 2001 From: Julien Chaumond Date: Sat, 22 Mar 2014 16:51:04 +0100 Subject: [PATCH 1/2] Add EPUB version --- epub.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/epub.js b/epub.js index 90c7b7e..af6d971 100644 --- a/epub.js +++ b/epub.js @@ -248,6 +248,8 @@ EPub.prototype.handleRootFile = function () { **/ EPub.prototype.parseRootFile = function (rootfile) { + this.version = rootfile['@'].version || '2.0'; + var i, len, keys, keyparts, key; keys = Object.keys(rootfile); for (i = 0, len = keys.length; i < len; i++) { From 12b38e31ef9887fb9576122b5d0c3f6dc3deb68d Mon Sep 17 00:00:00 2001 From: Julien Chaumond Date: Sat, 22 Mar 2014 17:17:05 +0100 Subject: [PATCH 2/2] Support for meta elements in metadata (EPUB 3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-meta-elem A bit more liberal than what’s in the spec to account for non-compliant EPUBs found in the wild. --- epub.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/epub.js b/epub.js index af6d971..c43264a 100644 --- a/epub.js +++ b/epub.js @@ -361,6 +361,18 @@ EPub.prototype.parseMetadata = function (metadata) { break; } } + + var metas = metadata['meta'] || {}; + Object.keys(metas).forEach(function(key) { + var meta = metas[key]; + if (meta['@'] && meta['@'].name) { + var name = meta['@'].name; + this.metadata[name] = meta['@'].content; + } + if (meta['#'] && meta['@'].property) { + this.metadata[meta['@'].property] = meta['#']; + } + }, this); }; /**