summaryrefslogtreecommitdiff
path: root/lib/epub.js/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/epub.js/test')
-rw-r--r--lib/epub.js/test/book.js66
-rw-r--r--lib/epub.js/test/core.js199
-rw-r--r--lib/epub.js/test/epub.js52
-rw-r--r--lib/epub.js/test/epubcfi.js425
-rw-r--r--lib/epub.js/test/fixtures/alice.epubbin0 -> 536540 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/META-INF/container.xml5
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_001.xhtml139
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_002.xhtml141
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_003.xhtml177
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_004.xhtml159
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_005.xhtml149
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_006.xhtml122
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_007.xhtml98
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_008.xhtml151
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_009.xhtml100
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/chapter_010.xhtml104
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/cover.xhtml12
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/css/stylesheet.css105
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/cover_th.jpgbin0 -> 36192 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i001_th.jpgbin0 -> 7606 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i002_th.jpgbin0 -> 6100 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i003_th.jpgbin0 -> 13746 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i004_th.jpgbin0 -> 11550 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i005_th.jpgbin0 -> 15846 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i006_th.jpgbin0 -> 18305 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i007_th.jpgbin0 -> 6636 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i008_th.jpgbin0 -> 14681 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i009_th.jpgbin0 -> 21200 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i010_th.jpgbin0 -> 3448 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i011_th.jpgbin0 -> 17046 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i012_th.jpgbin0 -> 19514 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i013_th.jpgbin0 -> 17064 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i014_th.jpgbin0 -> 15247 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i015_th.jpgbin0 -> 14489 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i016_th.jpgbin0 -> 14909 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i017_th.jpgbin0 -> 18503 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i018_th.jpgbin0 -> 14143 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i019_th.jpgbin0 -> 7215 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i020_th.jpgbin0 -> 13649 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/i022_th.jpgbin0 -> 14295 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/ii021_th.jpgbin0 -> 10233 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/plate01_th.jpgbin0 -> 42546 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/plate02_th.jpgbin0 -> 42694 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/plate03_th.jpgbin0 -> 42230 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/plate04_th.jpgbin0 -> 44618 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/images/title.jpgbin0 -> 1667 bytes
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/package.opf84
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/titlepage.xhtml42
-rw-r--r--lib/epub.js/test/fixtures/alice/OPS/toc.xhtml33
-rw-r--r--lib/epub.js/test/fixtures/alice/mimetype1
-rw-r--r--lib/epub.js/test/fixtures/alice_without_cover.epubbin0 -> 2981 bytes
-rw-r--r--lib/epub.js/test/fixtures/chapter1-highlights.xhtml36
-rw-r--r--lib/epub.js/test/fixtures/chapter1.xhtml36
-rw-r--r--lib/epub.js/test/fixtures/highlight.xhtml28
-rw-r--r--lib/epub.js/test/fixtures/locations.xhtml28
-rw-r--r--lib/epub.js/test/index.html12
-rw-r--r--lib/epub.js/test/locations.js31
-rw-r--r--lib/epub.js/test/old/epub.js371
-rw-r--r--lib/epub.js/test/old/rendering.js16
-rw-r--r--lib/epub.js/test/section.js77
60 files changed, 2999 insertions, 0 deletions
diff --git a/lib/epub.js/test/book.js b/lib/epub.js/test/book.js
new file mode 100644
index 0000000..4575fb2
--- /dev/null
+++ b/lib/epub.js/test/book.js
@@ -0,0 +1,66 @@
+import Book from '../src/book';
+import assert from 'assert';
+
+describe('Book', function() {
+
+ describe('Unarchived', function() {
+ var book = new Book("/fixtures/alice/OPS/package.opf");
+ it('should open a epub', async function() {
+ await book.opened
+ assert.equal(book.isOpen, true, "book is opened");
+ assert.equal( book.url.toString(), "http://localhost:9876/fixtures/alice/OPS/package.opf", "book url is passed to new Book" );
+ });
+ it('should have a local coverUrl', async function() {
+ assert.equal( await book.coverUrl(), "http://localhost:9876/fixtures/alice/OPS/images/cover_th.jpg", "cover url is available" );
+ });
+ });
+
+ describe('Archived epub', function() {
+ var book = new Book("/fixtures/alice.epub");
+
+ it('should open a archived epub', async function() {
+ await book.opened
+ assert.equal(book.isOpen, true, "book is opened");
+ assert(book.archive, "book is unarchived");
+ });
+ it('should have a blob coverUrl', async function() {
+ let coverUrl = await book.coverUrl()
+ assert( /^blob:http:\/\/localhost:9876\/[^\/]+$/.test(coverUrl), "cover url is available and a blob: url" );
+ });
+ });
+
+ describe('Archived epub in array buffer without options', function() {
+ let book;
+
+ before(async function() {
+ const response = await fetch("/fixtures/alice.epub");
+ const buffer = await response.arrayBuffer()
+ book = new Book(buffer)
+ })
+
+ it('should open a archived epub', async function() {
+ await book.opened
+ assert.equal(book.isOpen, true, "book is opened");
+ assert(book.archive, "book is unarchived");
+ });
+
+ it('should have a blob coverUrl', async function() {
+ let coverUrl = await book.coverUrl()
+ assert( /^blob:http:\/\/localhost:9876\/[^\/]+$/.test(coverUrl), "cover url is available and a blob: url" );
+ });
+ });
+
+ describe('Archived epub without cover', function() {
+ var book = new Book("/fixtures/alice_without_cover.epub");
+
+ it('should open a archived epub', async function() {
+ await book.opened
+ assert.equal(book.isOpen, true, "book is opened");
+ assert(book.archive, "book is unarchived");
+ });
+ it('should have a empty coverUrl', async function() {
+ let coverUrl = await book.coverUrl()
+ assert.equal(coverUrl, null, "cover url should be null" );
+ });
+ });
+});
diff --git a/lib/epub.js/test/core.js b/lib/epub.js/test/core.js
new file mode 100644
index 0000000..5f0839b
--- /dev/null
+++ b/lib/epub.js/test/core.js
@@ -0,0 +1,199 @@
+import assert from 'assert';
+import Url from '../src/utils/url';
+import Path from '../src/utils/path';
+
+describe('Core', function() {
+
+
+ before(function(){
+
+ });
+
+
+ describe('Url', function () {
+
+ it("Url()", function() {
+ var url = new Url("http://example.com/fred/chasen/derf.html");
+
+ assert.equal( url.href, "http://example.com/fred/chasen/derf.html" );
+ assert.equal( url.directory, "/fred/chasen/" );
+ assert.equal( url.extension, "html" );
+ assert.equal( url.filename, "derf.html" );
+ assert.equal( url.origin, "http://example.com" );
+ assert.equal( url.protocol, "http:" );
+ assert.equal( url.search, "" );
+ });
+
+ describe('#resolve()', function () {
+ it("should join subfolders", function() {
+ var a = "http://example.com/fred/chasen/";
+ var b = "ops/derf.html";
+
+ var resolved = new Url(a).resolve(b);
+ assert.equal( resolved, "http://example.com/fred/chasen/ops/derf.html" );
+ });
+
+ it("should resolve up a level", function() {
+ var a = "http://example.com/fred/chasen/index.html";
+ var b = "../derf.html";
+
+ var resolved = new Url(a).resolve(b);
+ assert.equal( resolved, "http://example.com/fred/derf.html" );
+ });
+
+ it("should resolve absolute", function() {
+ var a = "http://example.com/fred/chasen/index.html";
+ var b = "/derf.html";
+
+ var resolved = new Url(a).resolve(b);
+ assert.equal( resolved, "http://example.com/derf.html" );
+ });
+
+ it("should resolve with search strings", function() {
+ var a = "http://example.com/fred/chasen/index.html?debug=true";
+ var b = "/derf.html";
+
+ var resolved = new Url(a).resolve(b);
+ assert.equal( resolved, "http://example.com/derf.html" );
+ });
+
+ // Doesn't work with path.parse
+ xit("should handle directory with a dot", function() {
+ var a = "http://example.com/fred/chasen/index.epub/";
+
+ var url = new Url(a);
+ assert.equal( url.directory, "/fred/chasen/index.epub/" );
+ assert.equal( url.extension, "" );
+ });
+
+ it("should handle file urls", function() {
+ var url = new Url("file:///var/mobile/Containers/Data/Application/F47E4434-9B98-4654-93F1-702336B08EE6/Documents/books/moby-dick/derf.html");
+
+ assert.equal( url.href, "file:///var/mobile/Containers/Data/Application/F47E4434-9B98-4654-93F1-702336B08EE6/Documents/books/moby-dick/derf.html" );
+ assert.equal( url.directory, "/var/mobile/Containers/Data/Application/F47E4434-9B98-4654-93F1-702336B08EE6/Documents/books/moby-dick/" );
+ assert.equal( url.extension, "html" );
+ assert.equal( url.filename, "derf.html" );
+ assert.equal( url.origin, "file://" ); // origin should be blank
+ assert.equal( url.protocol, "file:" );
+ assert.equal( url.search, "" );
+ });
+
+ it("should resolve with file urls", function() {
+ var a = "file:///var/mobile/Containers/Data/Application/books/";
+ var b = "derf.html";
+
+ var resolved = new Url(a).resolve(b);
+ assert.equal( resolved, "file:///var/mobile/Containers/Data/Application/books/derf.html" );
+ });
+
+ });
+ });
+
+ describe('Path', function () {
+
+ it("Path()", function() {
+ var path = new Path("/fred/chasen/derf.html");
+
+ assert.equal( path.path, "/fred/chasen/derf.html" );
+ assert.equal( path.directory, "/fred/chasen/" );
+ assert.equal( path.extension, "html" );
+ assert.equal( path.filename, "derf.html" );
+ });
+
+ it("Strip out url", function() {
+ var path = new Path("http://example.com/fred/chasen/derf.html");
+
+ assert.equal( path.path, "/fred/chasen/derf.html" );
+ assert.equal( path.directory, "/fred/chasen/" );
+ assert.equal( path.extension, "html" );
+ assert.equal( path.filename, "derf.html" );
+ });
+
+ describe('#parse()', function () {
+ it("should parse a path", function() {
+ var path = Path.prototype.parse("/fred/chasen/derf.html");
+
+ assert.equal( path.dir, "/fred/chasen" );
+ assert.equal( path.base, "derf.html" );
+ assert.equal( path.ext, ".html" );
+ });
+
+ it("should parse a relative path", function() {
+ var path = Path.prototype.parse("fred/chasen/derf.html");
+
+ assert.equal( path.dir, "fred/chasen" );
+ assert.equal( path.base, "derf.html" );
+ assert.equal( path.ext, ".html" );
+ });
+ });
+
+ describe('#isDirectory()', function () {
+ it("should recognize a directory", function() {
+ var directory = Path.prototype.isDirectory("/fred/chasen/");
+ var notDirectory = Path.prototype.isDirectory("/fred/chasen/derf.html");
+
+ assert(directory, "/fred/chasen/ is a directory" );
+ assert(!notDirectory, "/fred/chasen/derf.html is not directory" );
+ });
+ });
+
+ describe('#resolve()', function () {
+
+ it("should resolve a path", function() {
+ var a = "/fred/chasen/index.html";
+ var b = "derf.html";
+
+ var resolved = new Path(a).resolve(b);
+ assert.equal(resolved, "/fred/chasen/derf.html" );
+ });
+
+ it("should resolve a relative path", function() {
+ var a = "fred/chasen/index.html";
+ var b = "derf.html";
+
+ var resolved = new Path(a).resolve(b);
+ assert.equal(resolved, "/fred/chasen/derf.html" );
+ });
+
+ it("should resolve a level up", function() {
+ var a = "/fred/chasen/index.html";
+ var b = "../derf.html";
+
+ var resolved = new Path(a).resolve(b);
+ assert.equal(resolved, "/fred/derf.html" );
+ });
+
+ });
+
+ describe('#relative()', function () {
+
+ it("should find a relative path at the same level", function() {
+ var a = "/fred/chasen/index.html";
+ var b = "/fred/chasen/derf.html";
+
+ var relative = new Path(a).relative(b);
+ assert.equal(relative, "derf.html" );
+ });
+
+ it("should find a relative path down a level", function() {
+ var a = "/fred/chasen/index.html";
+ var b = "/fred/chasen/ops/derf.html";
+
+ var relative = new Path(a).relative(b);
+ assert.equal(relative, "ops/derf.html" );
+ });
+
+ it("should resolve a level up", function() {
+ var a = "/fred/chasen/index.html";
+ var b = "/fred/derf.html";
+
+ var relative = new Path(a).relative(b);
+ assert.equal(relative, "../derf.html" );
+ });
+
+ });
+
+
+ });
+
+});
diff --git a/lib/epub.js/test/epub.js b/lib/epub.js/test/epub.js
new file mode 100644
index 0000000..d5d2516
--- /dev/null
+++ b/lib/epub.js/test/epub.js
@@ -0,0 +1,52 @@
+import assert from 'assert';
+import ePub from '../src/epub';
+// var sinon = require('sinon');
+
+
+describe('ePub', function() {
+ var server;
+ before(function(){
+ /*
+ // var packageContents = fs.readFileSync(__dirname + '/../books/moby-dick/OPS/package.opf', 'utf8');
+ // var tocContents = fs.readFileSync(__dirname + '/../books/moby-dick/OPS/toc.xhtml', 'utf8');
+ var packageContents = require('./fixtures/moby-dick/OPS/package.opf');
+ var tocContents = require('./fixtures/moby-dick/OPS/toc.xhtml');
+
+ server = sinon.fakeServer.create();
+ server.autoRespond = true;
+
+ server.respondWith("moby-dick/OPS/package.opf", [200, {
+ "Content-Type": "text/xml"
+ }, packageContents]);
+
+ server.respondWith("moby-dick/OPS/toc.xhtml", [200, {
+ "Content-Type": "application/xhtml+xml"
+ }, tocContents]);
+ */
+
+ });
+ after(function(){
+ // server.restore();
+ });
+
+ it('should open a epub', function() {
+ var book = ePub("/fixtures/alice/OPS/package.opf");
+
+ return book.opened.then(function(){
+ assert.equal( book.isOpen, true, "book is opened" );
+ assert.equal( book.url.toString(), "http://localhost:9876/fixtures/alice/OPS/package.opf", "book url is passed to new Book" );
+ });
+ });
+
+ it('should open a archived epub', function() {
+ var book = ePub("/fixtures/alice.epub");
+
+ // assert(typeof (JSZip) !== "undefined", "JSZip is present" );
+
+ return book.opened.then(function(){
+ assert.equal( book.isOpen, true, "book is opened" );
+ assert( book.archive, "book is unarchived" );
+ });
+ });
+
+});
diff --git a/lib/epub.js/test/epubcfi.js b/lib/epub.js/test/epubcfi.js
new file mode 100644
index 0000000..232f9ab
--- /dev/null
+++ b/lib/epub.js/test/epubcfi.js
@@ -0,0 +1,425 @@
+import assert from 'assert';
+import EpubCFI from '../src/epubcfi.js';
+// var fs = require('fs');
+if (typeof DOMParser === "undefined") {
+ global.DOMParser = require('xmldom').DOMParser;
+}
+
+describe('EpubCFI', function() {
+
+ it('parse a cfi on init', function() {
+ var cfi = new EpubCFI("epubcfi(/6/2[cover]!/6)");
+
+ assert.equal( cfi.spinePos, 0, "spinePos is parsed as the first item" );
+ });
+
+ it('parse a cfi and ignore the base if present', function() {
+ var cfi = new EpubCFI("epubcfi(/6/2[cover]!/6)", "/6/6[end]");
+
+ assert.equal( cfi.spinePos, 0, "base is ignored and spinePos is parsed as the first item" );
+ });
+
+ describe('#parse()', function() {
+ var cfi = new EpubCFI();
+
+ it('parse a cfi on init', function() {
+ var parsed = cfi.parse("epubcfi(/6/2[cover]!/6)");
+
+ assert.equal( parsed.spinePos, 0, "spinePos is parsed as the first item" );
+ });
+
+ it('parse a cfi and ignore the base if present', function() {
+ var parsed = cfi.parse("epubcfi(/6/2[cover]!/6)", "/6/6[end]");
+
+ assert.equal( parsed.spinePos, 0, "base is ignored and spinePos is parsed as the first item" );
+ });
+
+ it('parse a cfi with a charecter offset', function() {
+ var parsed = cfi.parse("epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/2/1:3)");
+
+ assert.equal( parsed.path.terminal.offset, 3, "Path has a terminal offset of 3" );
+ });
+
+ it('parse a cfi with a range', function() {
+ var parsed = cfi.parse("epubcfi(/6/4[chap01ref]!/4[body01]/10[para05],/2/1:1,/3:4)");
+
+ assert.equal( parsed.range, true, "Range is true" );
+ assert.equal( parsed.start.steps.length, 2, "Start steps are present" );
+ assert.equal( parsed.end.steps.length, 1, "End steps are present" );
+ assert.equal( parsed.start.terminal.offset, 1, "Start has a terminal offset of 1" );
+ assert.equal( parsed.end.terminal.offset, 4, "End has a terminal offset of 4" );
+
+ });
+
+ });
+
+ describe('#toString()', function() {
+ it('parse a cfi and write it back', function() {
+
+ assert.equal(new EpubCFI("epubcfi(/6/2[cover]!/6)").toString(), "epubcfi(/6/2[cover]!/6)", "output cfi string is same as input" );
+ assert.equal(new EpubCFI("epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/2/1:3)").toString(), "epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/2/1:3)", "output cfi string is same as input" );
+ assert.equal(new EpubCFI("epubcfi(/6/4[chap01ref]!/4[body01]/10[para05],/2/1:1,/3:4)").toString(), "epubcfi(/6/4[chap01ref]!/4[body01]/10[para05],/2/1:1,/3:4)", "output cfi string is same as input" );
+
+ });
+ });
+
+ describe('#checkType()', function() {
+ it('determine the type of a cfi string', function() {
+ var cfi = new EpubCFI();
+
+ assert.equal( cfi.checkType('epubcfi(/6/2[cover]!/6)'), 'string' );
+ assert.equal( cfi.checkType('/6/2[cover]!/6'), false );
+
+ });
+
+ it('determine the type of a cfi', function() {
+ var ogcfi = new EpubCFI("epubcfi(/6/4[chap01ref]!/4[body01]/10[para05]/2/1:3)");
+ var cfi = new EpubCFI();
+
+ assert.equal( cfi.checkType(ogcfi), 'EpubCFI' );
+
+ });
+
+ it('determine the type of a node', function() {
+ var cfi = new EpubCFI();
+ var el = document.createElement('div');
+
+ assert.equal( cfi.checkType(el), 'node' );
+
+ });
+
+ it('determine the type of a range', function() {
+ var cfi = new EpubCFI();
+ var range = document.createRange();
+
+ assert.equal( cfi.checkType(range), 'range' );
+
+ });
+
+ });
+
+ describe('#compare()', function() {
+ it('compare CFIs', function() {
+ var epubcfi = new EpubCFI();
+
+ // Spines
+ assert.equal(epubcfi.compare("epubcfi(/6/4[cover]!/4)", "epubcfi(/6/2[cover]!/4)"), 1, "First spine is greater");
+ assert.equal(epubcfi.compare("epubcfi(/6/4[cover]!/4)", "epubcfi(/6/6[cover]!/4)"), -1, "Second spine is greater");
+
+ // First is deeper
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/8/2)", "epubcfi(/6/2[cover]!/6)"), 1, "First Element is after Second");
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/2)", "epubcfi(/6/2[cover]!/6)"), -1, "First Element is before Second");
+
+ // Second is deeper
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/8/2)", "epubcfi(/6/2[cover]!/6/4/2/2)"), 1, "First Element is after Second");
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/4)", "epubcfi(/6/2[cover]!/6/4/2/2)"), -1, "First Element is before Second");
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/6)", "epubcfi(/6/2[cover]!/4/6/8/1:0)"), -1, "First is less specific, so is before Second");
+
+ // Same Depth
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/6/8)", "epubcfi(/6/2[cover]!/6/2)"), 1, "First Element is after Second");
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/20)", "epubcfi(/6/2[cover]!/6/10)"), -1, "First Element is before Second");
+
+ // Text nodes
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/5)", "epubcfi(/6/2[cover]!/4/3)"), 1, "First TextNode is after Second");
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/7)", "epubcfi(/6/2[cover]!/4/13)"), -1, "First TextNode is before Second");
+
+ // Char offset
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/5:1)", "epubcfi(/6/2[cover]!/4/5:0)"), 1, "First Char Offset after Second");
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/5:2)", "epubcfi(/6/2[cover]!/4/5:30)"), -1, "Second Char Offset before Second");
+
+ // Normal example
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/8/5:1)", "epubcfi(/6/2[cover]!/4/6/15:2)"), 1, "First Element after Second");
+ assert.equal(epubcfi.compare("epubcfi(/6/2[cover]!/4/8/1:0)", "epubcfi(/6/2[cover]!/4/8/1:0)"), 0, "All Equal");
+
+ // Different Lengths
+ assert.equal(epubcfi.compare(
+ 'epubcfi(/6/16[id42]!/4[5N3C0-8c483216e03a4ff49927fc1a97dc7b2c]/10/1:317)',
+ 'epubcfi(/6/16[id42]!/4[5N3C0-8c483216e03a4ff49927fc1a97dc7b2c]/10/2[page18]/1:0)'
+ ), -1, "First CFI is before Second");
+ assert.equal(epubcfi.compare(
+ 'epubcfi(/6/16[id42]!/4[5N3C0-8c483216e03a4ff49927fc1a97dc7b2c]/12/1:0)',
+ 'epubcfi(/6/16[id42]!/4[5N3C0-8c483216e03a4ff49927fc1a97dc7b2c]/12/2/1:9)'
+ ), -1, "First CFI is before Second");
+ assert.equal(epubcfi.compare(
+ 'epubcfi(/6/16!/4/12/1:0)',
+ 'epubcfi(/6/16!/4/12/2/1:9)'
+ ), -1, "First CFI is before Second");
+
+
+ });
+ });
+
+ describe('#fromNode()', function() {
+ var base = "/6/4[chap01ref]";
+ // var contents = fs.readFileSync(__dirname + '/fixtures/chapter1-highlights.xhtml', 'utf8');
+ var contents = require('./fixtures/chapter1-highlights.xhtml').default;
+
+ // var serializer = new XMLSerializer();
+ // var doc = serializer.serializeToString(contents);
+ var doc = new DOMParser().parseFromString(contents, "application/xhtml+xml");
+
+ it('get a cfi from a p node', function() {
+ var span = doc.getElementById('c001p0004');
+ var cfi = new EpubCFI(span, base);
+
+ assert.equal(span.nodeType, Node.ELEMENT_NODE, "provided a element node");
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/10/2[c001p0004])" );
+
+ });
+
+ it('get a cfi from a text node', function() {
+ var t = doc.getElementById('c001p0004').childNodes[0];
+ var cfi = new EpubCFI(t, base);
+
+ assert.equal(t.nodeType, Node.TEXT_NODE, "provided a text node");
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/10/2[c001p0004]/1)" );
+
+
+ });
+
+ it('get a cfi from a text node inside a highlight', function() {
+ var t = doc.getElementById('highlight-1').childNodes[0];
+ var cfi = new EpubCFI(t, base, 'annotator-hl');
+
+ assert.equal(t.nodeType, Node.TEXT_NODE, "provided a text node");
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/32/2[c001p0017]/1)" );
+
+ });
+
+ it('get a cfi from a highlight node', function() {
+ var t = doc.getElementById('highlight-1');
+ var cfi = new EpubCFI(t, base, 'annotator-hl');
+
+ assert.equal(t.nodeType, Node.ELEMENT_NODE, "provided a highlight node");
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/32/2[c001p0017])" );
+
+ });
+
+ });
+
+ describe('#fromRange()', function() {
+ var base = "/6/4[chap01ref]";
+
+ // var contentsClean = fs.readFileSync(__dirname + '/fixtures/chapter1.xhtml', 'utf8');
+ var contentsClean = require('./fixtures/chapter1.xhtml').default;
+
+ var doc = new DOMParser().parseFromString(contentsClean, "application/xhtml+xml");
+
+ // var contentsHighlights = fs.readFileSync(__dirname + '/fixtures/chapter1-highlights.xhtml', 'utf8');
+ var contentsHighlights = require('./fixtures/chapter1-highlights.xhtml').default;
+ var docHighlights = new DOMParser().parseFromString(contentsHighlights, "application/xhtml+xml");
+
+ // var highlightContents = fs.readFileSync(__dirname + '/fixtures/highlight.xhtml', 'utf8');
+ var highlightContents = require('./fixtures/highlight.xhtml').default;
+ var docHighlightsAlice = new DOMParser().parseFromString(highlightContents, "application/xhtml+xml");
+
+ it('get a cfi from a collapsed range', function() {
+ var t1 = doc.getElementById('c001p0004').childNodes[0];
+ var t2 = doc.getElementById('c001p0007').childNodes[0];
+ var range = doc.createRange();
+ var cfi;
+
+ range.setStart(t1, 6);
+
+ cfi = new EpubCFI(range, base);
+
+ assert.equal( cfi.range, false);
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/10/2[c001p0004]/1:6)" );
+
+ });
+
+ it('get a cfi from a range', function() {
+ var t1 = doc.getElementById('c001p0004').childNodes[0];
+ var t2 = doc.getElementById('c001p0007').childNodes[0];
+ var range = doc.createRange();
+ var cfi;
+
+ range.setStart(t1, 6);
+ range.setEnd(t2, 27);
+
+ cfi = new EpubCFI(range, base);
+
+ assert.equal( cfi.range, true);
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2,/10/2[c001p0004]/1:6,/16/2[c001p0007]/1:27)" );
+
+ });
+
+ it('get a cfi from a range with offset 0', function() {
+ var t1 = doc.getElementById('c001p0004').childNodes[0];
+ var range = doc.createRange();
+ var cfi;
+
+ range.setStart(t1, 0);
+ range.setEnd(t1, 1);
+
+ cfi = new EpubCFI(range, base);
+
+ assert.equal( cfi.range, true);
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/10/2[c001p0004],/1:0,/1:1)" );
+
+ });
+
+ it('get a cfi from a range inside a highlight', function() {
+ var t1 = docHighlights.getElementById('highlight-1').childNodes[0];
+ var range = docHighlights.createRange();
+ var cfi;
+
+ range.setStart(t1, 6);
+
+ cfi = new EpubCFI(range, base, 'annotator-hl');
+
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/32/2[c001p0017]/1:43)" );
+
+ });
+ // TODO: might need to have double ranges in front
+ it('get a cfi from a range past a highlight', function() {
+ var t1 = docHighlights.getElementById('c001s0001').childNodes[1];
+ var range = docHighlights.createRange();
+ var cfi;
+
+ range.setStart(t1, 25);
+
+ cfi = new EpubCFI(range, base, 'annotator-hl');
+
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/4/2[c001s0001]/1:41)" );
+
+ });
+
+ it('get a cfi from a range inbetween two highlights', function() {
+ var t1 = docHighlightsAlice.getElementById('p2').childNodes[1];
+ var range = docHighlightsAlice.createRange();
+ var cfi;
+
+ range.setStart(t1, 4);
+
+ cfi = new EpubCFI(range, base, 'annotator-hl');
+
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/4[p2]/1:123)" );
+
+ });
+
+ it('correctly count text nodes, independent of any elements present inbetween', function() {
+ var t1 = docHighlightsAlice.getElementById('p3').childNodes[2];
+ var range = docHighlightsAlice.createRange();
+ var cfi;
+
+ range.setStart(t1, 4);
+
+ cfi = new EpubCFI(range, base);
+
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/6[p3]/3:4)" );
+
+ });
+
+ });
+
+
+ describe('#toRange()', function() {
+ var base = "/6/4[chap01ref]";
+ // var contents = fs.readFileSync(__dirname + '/fixtures/chapter1-highlights.xhtml', 'utf8');
+ var contents = require('./fixtures/chapter1-highlights.xhtml').default;
+
+ var doc = new DOMParser().parseFromString(contents, "application/xhtml+xml");
+
+ // var serializer = new XMLSerializer();
+ // console.log(serializer.serializeToString(doc));
+
+ it('get a range from a cfi', function() {
+ var t1 = doc.getElementById('c001p0004').childNodes[0];
+ var t2 = doc.getElementById('c001p0007').childNodes[0];
+ var ogRange = doc.createRange();
+ var cfi;
+ var newRange;
+
+ ogRange.setStart(t1, 6);
+
+ cfi = new EpubCFI(ogRange, base);
+
+ // Check it was parse correctly
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/10/2[c001p0004]/1:6)" );
+
+ // Check the range
+ newRange = cfi.toRange(doc);
+
+ assert.equal( newRange.startContainer, t1);
+ assert.equal( newRange.startOffset, 6);
+ assert.equal( newRange.collapsed, true);
+
+ });
+
+ it('get a range from a cfi with a range', function() {
+ var t1 = doc.getElementById('c001p0004').childNodes[0];
+ var t2 = doc.getElementById('c001p0007').childNodes[0];
+ var ogRange = doc.createRange();
+ var cfi;
+ var newRange;
+
+ ogRange.setStart(t1, 6);
+ ogRange.setEnd(t2, 27);
+
+ cfi = new EpubCFI(ogRange, base);
+
+ // Check it was parse correctly
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2,/10/2[c001p0004]/1:6,/16/2[c001p0007]/1:27)" );
+
+ // Check the range
+ newRange = cfi.toRange(doc);
+
+ assert.equal( newRange.startContainer, t1);
+ assert.equal( newRange.startOffset, 6);
+
+ assert.equal( newRange.endContainer, t2);
+ assert.equal( newRange.endOffset, 27);
+
+ assert.equal( newRange.collapsed, false);
+
+ });
+
+ it('get a cfi from a range inside a highlight', function() {
+ var t1 = doc.getElementById('highlight-1').childNodes[0];
+ var ogRange = doc.createRange();
+ var cfi;
+ var newRange;
+
+ ogRange.setStart(t1, 6);
+
+ cfi = new EpubCFI(ogRange, base, 'annotator-hl');
+
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/32/2[c001p0017]/1:43)" );
+
+ // Check the range
+ newRange = cfi.toRange(doc, 'annotator-hl');
+
+ assert.ok(newRange.startContainer);
+
+ assert.equal( newRange.startContainer, t1);
+ assert.equal( newRange.startOffset, 6);
+
+ });
+
+ it('get a cfi from a range inside a highlight range', function() {
+ var t1 = doc.getElementById('highlight-2').childNodes[0];
+ var t2 = doc.getElementById('c001s0001').childNodes[1];
+ var ogRange = doc.createRange();
+ var cfi;
+ var newRange;
+
+ ogRange.setStart(t1, 5);
+ ogRange.setEnd(t2, 25);
+
+ cfi = new EpubCFI(ogRange, base, 'annotator-hl');
+
+ assert.equal( cfi.toString(), "epubcfi(/6/4[chap01ref]!/4/2/4/2[c001s0001],/1:5,/1:41)" );
+
+ // Check the range
+ newRange = cfi.toRange(doc, 'annotator-hl');
+
+ assert.strictEqual( newRange.startContainer.textContent, t1.textContent);
+ // assert.strictEqual( newRange.startContainer, t1);
+ // assert.equal( newRange.startOffset, 5);
+
+ });
+
+ });
+
+});
diff --git a/lib/epub.js/test/fixtures/alice.epub b/lib/epub.js/test/fixtures/alice.epub
new file mode 100644
index 0000000..9ac6ba3
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice.epub
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/META-INF/container.xml b/lib/epub.js/test/fixtures/alice/META-INF/container.xml
new file mode 100644
index 0000000..f9a37a7
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/META-INF/container.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
+<rootfiles>
+<rootfile full-path="OPS/package.opf" media-type="application/oebps-package+xml"/>
+</rootfiles>
+</container> \ No newline at end of file
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_001.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_001.xhtml
new file mode 100644
index 0000000..26ac098
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_001.xhtml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00004"><a id="I_DOWN_THE_RABBIT-HOLE"></a>Down The Rabbit-Hole</h2>
+
+ <figure class="small">
+ <img src= "images/i001_th.jpg" alt="Illo1" />
+ </figure>
+
+ <p>Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do. Once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, "and what is the use of a book," thought Alice, "without pictures or conversations?"</p>
+
+ <p>So she was considering in her own mind (as well as she could, for the day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.</p>
+
+ <figure class="small">
+ <img src="images/i002_th.jpg" alt="Illo2" />
+ </figure>
+
+ <p>There was nothing so very remarkable in that, nor did Alice think it so
+ <a id="Page_4" class="pageno" title="[Pg 4]"></a>very much out of the way to hear the Rabbit
+ say to itself, "Oh dear! Oh dear! I shall be too late!" But when the Rabbit actually
+ took a watch out of its waistcoat-pocket and looked at it and then hurried on, Alice
+ started to her feet, for it flashed across her mind that she had never before seen a
+ rabbit with either a waistcoat-pocket, or a watch to take out of it, and, burning with
+ curiosity, she ran across the field after it and was just in time to see it pop down a
+ large rabbit-hole, under the hedge. In another moment, down went Alice after it!</p>
+
+ <p>The rabbit-hole went straight on like a tunnel for some way and then dipped suddenly
+ down, so suddenly that Alice had not a moment to think about stopping herself before
+ she found herself falling down what seemed to be a very deep well.</p>
+
+ <p>Either the well was very deep, or she fell very slowly, for she had plenty of time,
+ as she went down, to look about her. First, she tried to make out what she was coming
+ to, but it was too dark to see anything; then she looked at the sides of the well and
+ noticed that they were filled with cupboards and book-shelves; here and there she saw
+ maps and <a id="Page_5" class="pageno" title="[Pg 5]"></a>pictures hung upon pegs. She
+ took down a jar from one of the shelves as she passed. It was labeled "ORANGE
+ MARMALADE," but, to her great disappointment, it was empty; she did not like to drop
+ the jar, so managed to put it into one of the cupboards as she fell past it.</p>
+
+ <p>Down, down, down! Would the fall never come to an end? There was nothing else to do,
+ so Alice soon began talking to herself. "Dinah'll miss me very much to-night, I should
+ think!" (Dinah was the cat.) "I hope they'll remember her saucer of milk at tea-time.
+ Dinah, my dear, I wish you were down here with me!" Alice felt that she was dozing off,
+ when suddenly, thump! thump! down she came upon a heap of sticks and dry leaves, and
+ the fall was over.</p>
+
+ <p>Alice was not a bit hurt, and she jumped up in a moment. She looked up, but it was
+ all dark overhead; before her was another long passage and the White Rabbit was still
+ in sight, hurrying down it. There was not a moment to be lost. Away went Alice like the
+ wind and was just in time to hear it say, as it turned a corner, "Oh, my ears and
+ whiskers, how late it's getting!" She was close behind it when she turned the corner,
+ but the Rabbit was no longer to be seen.</p>
+
+ <p>She found herself in a long, low hall, which was lit up by a row of lamps hanging
+ from the roof. There were doors all 'round the hall, but they were all locked; and when
+ Alice had been all the way down one side and up the other, trying every door, she
+ walked sadly down the middle, <a id="Page_6" class="pageno" title=
+ "[Pg 6]"></a>wondering how she was ever to get out again.</p>
+
+ <figure class="small">
+ <img src="images/i003_th.jpg" alt="Illo3" />
+ </figure>
+
+ <p>Suddenly she came upon a little table, all made of solid glass. There was nothing on
+ it but a tiny golden key, and Alice's first idea was that this might belong to one of
+ the doors of the hall; but, alas! either the locks were too large, or the key was too
+ small, but, at any rate, it would not open any of them. However, on the second time
+ 'round, she came upon a low curtain she had not noticed before, and behind it was a
+ little door about fifteen inches high. She tried the little golden key in the lock, and
+ to her great delight, it fitted!</p>
+
+ <p>Alice opened the door and found that it led into a small passage, not much larger
+ than a rat-hole; she knelt down and looked along the passage into the loveliest garden
+ you ever saw. How she longed to get out of that dark hall and wander about among those
+ beds of bright flowers and those cool fountains, but she could not even get her head
+ through the doorway. "Oh," said Alice, "how I wish I could shut up like a telescope! I
+ think I could, if I only knew how to begin."</p>
+
+ <p>Alice went back to the table, half hoping she might find another key on it, or at
+ any rate, a book of rules for shutting people up like telescopes. This time she<a id=
+ "Page_7" class="pageno" title="[Pg 7]"></a> found a little bottle on it ("which
+ certainly was not here before," said Alice), and tied 'round the neck of the bottle was
+ a paper label, with the words "DRINK ME" beautifully printed on it in large
+ letters.</p>
+
+ <p>"No, I'll look first," she said, "and see whether it's marked '<i>poison</i>' or
+ not," for she had never forgotten that, if you drink from a bottle marked "poison," it
+ is almost certain to disagree with you, sooner or later. However, this bottle was
+ <i>not</i> marked "poison," so Alice ventured to taste it, and, finding it very nice
+ (it had a sort of mixed flavor of cherry-tart, custard, pineapple, roast turkey, toffy
+ and hot buttered toast), she very soon finished it off.</p>
+
+ <p>"What a curious feeling!" said Alice. "I must be shutting up like a telescope!"</p>
+
+ <p>And so it was indeed! She was now only ten inches high, and her face brightened up
+ at the thought that she was now the right size for going through the little door into
+ that lovely garden.</p>
+
+ <p>After awhile, finding that nothing more happened, she decided on going into the
+ garden at once; but, alas for poor Alice! When she got to the door, she found she had
+ forgotten the little golden key, and when she went back to the table for it, she found
+ she could not possibly reach it: she could see it quite plainly through the glass and
+ she tried her best to climb up one of the legs of the table, but it was too slippery,
+ and when she had tired herself out with trying, the poor little thing sat down and
+ cried.</p>
+
+ <p>"Come, there's no use in crying like that!" said Alice to herself rather sharply. "I
+ advise you to<a id="Page_8" class="pageno" title="[Pg 8]"></a> leave off this minute!"
+ She generally gave herself very good advice (though she very seldom followed it), and
+ sometimes she scolded herself so severely as to bring tears into her eyes.</p>
+
+ <p>Soon her eye fell on a little glass box that was lying under the table: she opened
+ it and found in it a very small cake, on which the words "EAT ME" were beautifully
+ marked in currants. "Well, I'll eat it," said Alice, "and if it makes me grow larger, I
+ can reach the key; and if it makes me grow smaller, I can creep under the door: so
+ either way I'll get into the garden, and I don't care which happens!"</p>
+
+ <p>She ate a little bit and said anxiously to herself, "Which way? Which way?" holding
+ her hand on the top of her head to feel which way she was growing; and she was quite
+ surprised to find that she remained the same size. So she set to work and very soon
+ finished off the cake.</p>
+
+ <figure class="small">
+ <img src="images/i004_th.jpg" alt="Illo4" />
+ </figure>
+
+ <p><a id="Page_9" class="pageno" title="[Pg 9]"></a></p>
+
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_002.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_002.xhtml
new file mode 100644
index 0000000..3babe69
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_002.xhtml
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00005"><a id="II_THE_POOL_OF_TEARS"></a>The Pool Of Tears</h2>
+
+ <p>Curiouser and curiouser!" cried Alice (she was so much
+ surprised that for the moment she quite forgot how to speak good English). "Now I'm
+ opening out like the largest telescope that ever was! Good-by, feet! Oh, my poor little
+ feet, I wonder who will put on your shoes and stockings for you now, dears? I shall be
+ a great deal too far off to trouble myself about you."</p>
+
+ <p>Just at this moment her head struck against the roof of the hall; in fact, she was
+ now rather more than nine feet high, and she at once took up the little golden key and
+ hurried off to the garden door.</p>
+
+ <p>Poor Alice! It was as much as she could do, lying down on one side, to look through
+ into the garden with one eye; but to get through was more hopeless than ever. She sat
+ down and began to cry again.</p>
+
+ <p>She went on shedding gallons of tears, until there was a large pool all 'round her
+ and reaching half down the hall.</p>
+
+ <p>After a time, she heard a little pattering of feet in the distance and she hastily
+ dried her eyes to see what was coming. It was the White Rabbit returning, splendidly
+ dressed, with a pair of white kid-gloves in one hand and a large fan in the other.
+ He<a id="Page_10" class="pageno" title="[Pg 10]"></a> came trotting along in a great
+ hurry, muttering to himself, "Oh! the Duchess, the Duchess! Oh! <i>won't</i> she be
+ savage if I've kept her waiting!"</p>
+
+ <figure class="small">
+ <img src="images/i005_th.jpg" alt="Illo5" />
+ </figure>
+
+ <p>When the Rabbit came near her, Alice began, in a low, timid voice, "If you please,
+ sir&#8212;" The Rabbit started violently, dropped the white kid-gloves and the fan and
+ skurried away into the darkness as hard as he could go.</p>
+
+ <p>Alice took up the fan and gloves and she kept fanning herself all the time she went
+ on talking. "Dear, dear! How queer everything is to-day! And yesterday things went on
+ just as usual. <i>Was</i> I the same when I got up this morning? But if I'm not the
+ same, the next question is, 'Who in the world am I?' Ah, <i>that's</i> the great
+ puzzle!"</p>
+
+ <p>As she said this, she looked down at her hands and was surprised to see that she had
+ put on one of the Rabbit's little white kid-gloves while she was talking. "How
+ <i>can</i> I have done that?" she thought. "I must be growing small again." She got up
+ and went to the table to measure herself by it and found that she was now about two
+ feet high and was going on<a id="Page_11" class="pageno" title="[Pg 11]"></a> shrinking
+ rapidly. She soon found out that the cause of this was the fan she was holding and she
+ dropped it hastily, just in time to save herself from shrinking away altogether.</p>
+
+ <p>"That <i>was</i> a narrow escape!" said Alice, a good deal frightened at the sudden
+ change, but very glad to find herself still in existence. "And now for the garden!" And
+ she ran with all speed back to the little door; but, alas! the little door was shut
+ again and the little golden key was lying on the glass table as before. "Things are
+ worse than ever," thought the poor child, "for I never was so small as this before,
+ never!"</p>
+
+ <p>As she said these words, her foot slipped, and in another moment, splash! she was up
+ to her chin in salt-water. Her first idea was that she had somehow fallen into the sea.
+ However, she soon made out that she was in the pool of tears which she had wept when
+ she was nine feet high.</p>
+
+ <figure class="small">
+ <img src="images/i006_th.jpg" alt="Illo6" />
+ </figure>
+
+ <p>Just then she heard something splashing about in the pool a little way off, and she
+ swam nearer to see what it was: she soon made out that it was only a mouse that had
+ slipped in like herself.<a id="Page_12" class="pageno" title="[Pg 12]"></a></p>
+
+ <p>"Would it be of any use, now," thought Alice, "to speak to this mouse? Everything is
+ so out-of-the-way down here that I should think very likely it can talk; at any rate,
+ there's no harm in trying." So she began, "O Mouse, do you know the way out of this
+ pool? I am very tired of swimming about here, O Mouse!" The Mouse looked at her rather
+ inquisitively and seemed to her to wink with one of its little eyes, but it said
+ nothing.</p>
+
+ <p>"Perhaps it doesn't understand English," thought Alice. "I dare say it's a French
+ mouse, come over with William the Conqueror." So she began again: "O&#249; est ma
+ chatte?" which was the first sentence in her French lesson-book. The Mouse gave a
+ sudden leap out of the water and seemed to quiver all over with fright. "Oh, I beg your
+ pardon!" cried Alice hastily, afraid that she had hurt the poor animal's feelings. "I
+ quite forgot you didn't like cats."</p>
+
+ <p>"Not like cats!" cried the Mouse in a shrill, passionate voice. "Would <i>you</i>
+ like cats, if you were me?"</p>
+
+ <p>"Well, perhaps not," said Alice in a soothing tone; "don't be angry about it. And
+ yet I wish I could show you our cat Dinah. I think you'd take a fancy to cats, if you
+ could only see her. She is such a dear, quiet thing." The Mouse was bristling all over
+ and she felt certain it must be really offended. "We won't talk about her any more, if
+ you'd rather not."</p>
+
+ <p>"We, indeed!" cried the Mouse, who was trembling down to the end of its tail. "As if
+ <i>I</i> would talk on such a subject! Our family always <i>hated</i> cats<a id=
+ "Page_13" class="pageno" title="[Pg 13]"></a>&#8212;nasty, low, vulgar things! Don't
+ let me hear the name again!"</p>
+
+ <figure class="full">
+ <img src= "images/plate02_th.jpg" alt="Alice at the Mad Tea Party." title="Alice at the Mad Tea Party." />
+ <figcaption>
+ <p>Alice at the Mad Tea Party.</p>
+ </figcaption>
+ </figure>
+
+ <p>"I won't indeed!" said Alice, in a great hurry to change the subject of
+ conversation. "Are you&#8212;are you fond&#8212;of&#8212;of dogs? There is such a nice
+ little dog near our house, I should like to show you! It kills all the rats
+ and&#8212;oh, dear!" cried Alice in a sorrowful tone. "I'm afraid I've offended it
+ again!" For the Mouse was swimming away from her as hard as it could go, and making
+ quite a commotion in the pool as it went.</p>
+
+ <p>So she called softly after it, "Mouse dear! Do come back again, and we won't talk
+ about cats, or dogs either, if you don't like them!" When the Mouse heard this, it
+ turned 'round and swam slowly back to her; its face was quite pale, and it said, in a
+ low, trembling voice, "Let us get to the shore and then I'll tell you my history and
+ you'll understand why it is I hate cats and dogs."</p>
+
+ <p>It was high time to go, for the pool was getting quite crowded with the birds and
+ animals that had fallen into it; there were a Duck and a Dodo, a Lory and an Eaglet,
+ and several other curious creatures. Alice led the way and the whole party swam to the
+ shore.</p>
+
+ <figure class="small">
+ <img src="images/i007_th.jpg" alt="Illo7" />
+ </figure>
+
+ <p><a id="Page_14" class="pageno" title="[Pg 14]"></a></p>
+
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_003.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_003.xhtml
new file mode 100644
index 0000000..6b80493
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_003.xhtml
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00006">
+ <a id="III_A_CAUCUS-RACE_AND_A_LONG_TALE"></a>
+ A Caucus-Race And A Long Tale
+ </h2>
+
+ <p>They were indeed a queer-looking party that assembled on the
+ bank&#8212;the birds with draggled feathers, the animals with their fur clinging close
+ to them, and all dripping wet, cross and uncomfortable.</p>
+
+ <figure class="small">
+ <img src="images/i008_th.jpg" alt="Illo8" />
+ </figure>
+
+ <p>The first question, of course, was how to get dry again. They had a consultation
+ about this and after a few minutes, it seemed quite natural to Alice to find herself
+ talking familiarly with them, as if she had known them all her life.</p>
+
+ <p>At last the Mouse, who seemed to be a person of<a id="Page_15" class="pageno" title=
+ "[Pg 15]"></a> some authority among them, called out, "Sit down, all of you, and listen
+ to me! <i>I'll</i> soon make you dry enough!" They all sat down at once, in a large
+ ring, with the Mouse in the middle.</p>
+
+ <p>"Ahem!" said the Mouse with an important air. "Are you all ready? This is the driest
+ thing I know. Silence all 'round, if you please! 'William the Conqueror, whose cause
+ was favored by the pope, was soon submitted to by the English, who wanted leaders, and
+ had been of late much accustomed to usurpation and conquest. Edwin and Morcar, the
+ Earls of Mercia and Northumbria'&#8212;"</p>
+
+ <p>"Ugh!" said the Lory, with a shiver.</p>
+
+ <p>"&#8212;'And even Stigand, the patriotic archbishop of Canterbury, found it
+ advisable'&#8212;"</p>
+
+ <p>"Found <i>what</i>?" said the Duck.</p>
+
+ <p>"Found <i>it</i>," the Mouse replied rather crossly; "of course, you know what 'it'
+ means."</p>
+
+ <p>"I know what 'it' means well enough, when <i>I</i> find a thing," said the Duck;
+ "it's generally a frog or a worm. The question is, what did the archbishop find?"</p>
+
+ <p>The Mouse did not notice this question, but hurriedly went on, "'&#8212;found it
+ advisable to go with Edgar Atheling to meet William and offer him the crown.'&#8212;How
+ are you getting on now, my dear?" it continued, turning to Alice as it spoke.</p>
+
+ <p>"As wet as ever," said Alice in a melancholy tone; "it doesn't seem to dry me at
+ all."</p>
+
+ <p>"In that case," said the Dodo solemnly, rising to its feet, "I move that the meeting
+ adjourn, for the immediate adoption of more energetic remedies&#8212;"<a id="Page_16"
+ class="pageno" title="[Pg 16]"></a></p>
+
+ <p>"Speak English!" said the Eaglet. "I don't know the meaning of half those long
+ words, and, what's more, I don't believe you do either!"</p>
+
+ <p>"What I was going to say," said the Dodo in an offended tone, "is that the best
+ thing to get us dry would be a Caucus-race."</p>
+
+ <p>"What <i>is</i> a Caucus-race?" said Alice.</p>
+
+ <figure class="small">
+ <img src="images/i009_th.jpg" alt="Illo9" />
+ </figure>
+
+ <p>"Why," said the Dodo, "the best way to explain it is to do it." First it marked out
+ a race-course, in a sort of circle, and then all the party were placed along the
+ course, here and there. There was no "One, two, three and away!" but they began running
+ when they liked and left off when they liked, so that it was not easy to know when the
+ race was over. However, when they had been running half an hour or so and were quite
+ dry again, the Dodo suddenly called out, "The race is over!" and they all crowded
+ 'round it, panting and asking, "But who has won?"<a id="Page_17" class="pageno" title=
+ "[Pg 17]"></a></p>
+
+ <p>This question the Dodo could not answer without a great deal of thought. At last it
+ said, "<i>Everybody</i> has won, and <i>all</i> must have prizes."</p>
+
+ <p>"But who is to give the prizes?" quite a chorus of voices asked.</p>
+
+ <p>"Why, <i>she</i>, of course," said the Dodo, pointing to Alice with one finger; and
+ the whole party at once crowded 'round her, calling out, in a confused way, "Prizes!
+ Prizes!"</p>
+
+ <p>Alice had no idea what to do, and in despair she put her hand into her pocket and
+ pulled out a box of comfits (luckily the salt-water had not got into it) and handed
+ them 'round as prizes. There was exactly one a-piece, all 'round.</p>
+
+ <p>The next thing was to eat the comfits; this caused some noise and confusion, as the
+ large birds complained that they could not taste theirs, and the small ones choked and
+ had to be patted on the back. However, it was over at last and they sat down again in a
+ ring and begged the Mouse to tell them something more.</p>
+
+ <p>"You promised to tell me your history, you know," said Alice, "and why it is you
+ hate&#8212;C and D," she added in a whisper, half afraid that it would be offended
+ again.</p>
+
+ <p>"Mine is a long and a sad tale!" said the Mouse, turning to Alice and sighing.</p>
+
+ <p>"It <i>is</i> a long tail, certainly," said Alice, looking down with wonder at the
+ Mouse's tail, "but why do you call it sad?" And she kept on puzzling about it while the
+ Mouse was speaking, so that her idea of the tale was something like this:<a id=
+ "Page_18" class="pageno" title="[Pg 18]"></a>&#8212;</p>
+
+ <div class="poem stanza">
+ <span class="i1">"Fury said to<br /></span> <span class="i2">a mouse,
+ That<br /></span> <span class="i3">he met in the<br /></span> <span class="i4">house,
+ 'Let<br /></span> <span class="i5">us both go<br /></span> <span class="i6">to law:
+ <i>I</i><br /></span> <span class="i6 c9">will prosecute<br /></span> <span class=
+ "i6 c9"><i>you</i>.&#8212;<br /></span> <span class="i6 c9">Come, I'll<br /></span>
+ <span class="i5 c9">take no denial:<br /></span> <span class="c20"><span class=
+ "i4 c9">We must have<br /></span> <span class="i3 c10">the trial;<br /></span>
+ <span class="i2 c10">For really<br /></span> <span class="i1 c10">this
+ morning<br /></span> <span class="i0 c10">I've<br /></span> <span class=
+ "i0 c10">nothing<br /></span> <span class="i0 c11">to do.'<br /></span> <span class=
+ "i1 c11">Said the<br /></span> <span class="i2 c11">mouse to<br /></span>
+ <span class="c19"><span class="i3 c11">the cur,<br /></span> <span class=
+ "i4 c11">'Such a<br /></span> <span class="i5 c12">trial, dear<br /></span>
+ <span class="i6 c12">sir, With<br /></span> <span class="i8 c12">no jury<br /></span>
+ <span class="i9 c12">or judge,<br /></span> <span class="i9 c12">would<br /></span>
+ <span class="i8 c13">be wasting<br /></span> <span class="i7 c13">our<br /></span>
+ <span class="c18"><span class="i5 c13">breath.'<br /></span> <span class=
+ "i4 c13">'I'll be<br /></span> <span class="i3 c13">judge,<br /></span> <span class=
+ "i2 c14">I'll be<br /></span> <span class="i1 c14">jury,'<br /></span> <span class=
+ "i0 c14">said<br /></span> <span class="i0 c14">cunning<br /></span> <span class=
+ "i1 c14">old<br /></span> <span class="i2 c15">Fury;<br /></span> <span class=
+ "c17"><span class="i3 c15">'I'll<br /></span> <span class="i4 c15">try<br /></span>
+ <span class="i5 c15">the<br /></span> <span class="i6 c15">whole<br /></span>
+ <span class="i7 c16">cause,<br /></span> <span class="i7 c16">and<br /></span>
+ <span class="i6 c16">condemn<br /></span> <span class="i5 c16">you to<br /></span>
+ <span class="i3 c16">death.'"<br /></span></span></span></span></span>
+ </div>
+
+ <p><a id="Page_19" class="pageno" title="[Pg 19]"></a>"You are not attending!" said the
+ Mouse to Alice, severely. "What are you thinking of?"</p>
+
+ <p>"I beg your pardon," said Alice very humbly, "you had got to the fifth bend, I
+ think?"</p>
+
+ <p>"You insult me by talking such nonsense!" said the Mouse, getting up and walking
+ away.</p>
+
+ <p>"Please come back and finish your story!" Alice called after it. And the others all
+ joined in chorus, "Yes, please do!" But the Mouse only shook its head impatiently and
+ walked a little quicker.</p>
+
+ <p>"I wish I had Dinah, our cat, here!" said Alice. This caused a remarkable sensation
+ among the party. Some of the birds hurried off at once, and a Canary called out in a
+ trembling voice, to its children, "Come away, my dears! It's high time you were all in
+ bed!" On various pretexts they all moved off and Alice was soon left alone.</p>
+
+ <p>"I wish I hadn't mentioned Dinah! Nobody seems to like her down here and I'm sure
+ she's the best cat in the world!" Poor Alice began to cry again, for she felt very
+ lonely and low-spirited. In a little while, however, she again heard a little pattering
+ of footsteps in the distance and she looked up eagerly.</p>
+
+ <figure class="small">
+ <img src="images/i010_th.jpg" alt="Illo10" />
+ </figure>
+ <p><a id="Page_20" class="pageno" title="[Pg 20]"></a></p>
+
+ <figure class="small">
+ <img src="images/i011_th.jpg" alt="Illo11" />
+ </figure>
+
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_004.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_004.xhtml
new file mode 100644
index 0000000..babbb4e
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_004.xhtml
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00007"><a id="IV_THE_RABBIT_SENDS_IN_A_LITTLE_BILL"></a>
+ The Rabbit Sends In A Little Bill</h2>
+
+ <p>It was the White Rabbit, trotting slowly back again and
+ looking anxiously about as it went, as if it had lost something; Alice heard it
+ muttering to itself, "The Duchess! The Duchess! Oh, my dear paws! Oh, my fur and
+ whiskers! She'll get me executed, as sure as ferrets are ferrets! Where <i>can</i> I
+ have dropped them, I wonder?" Alice guessed in a moment that it was looking for the fan
+ and the pair of white kid-gloves and she very good-naturedly began hunting about for
+ them, but they were nowhere to be seen&#8212;everything seemed to have changed since
+ her swim in the pool, and the great hall, with the glass table and the little door, had
+ vanished completely.<a id="Page_21" class="pageno" title="[Pg 21]"></a></p>
+
+ <p>Very soon the Rabbit noticed Alice, and called to her, in an angry tone, "Why, Mary
+ Ann, what <i>are</i> you doing out here? Run home this moment and fetch me a pair of
+ gloves and a fan! Quick, now!"</p>
+
+ <p>"He took me for his housemaid!" said Alice, as she ran off. "How surprised he'll be
+ when he finds out who I am!" As she said this, she came upon a neat little house, on
+ the door of which was a bright brass plate with the name "W. RABBIT" engraved upon it.
+ She went in without knocking and hurried upstairs, in great fear lest she should meet
+ the real Mary Ann and be turned out of the house before she had found the fan and
+ gloves.</p>
+
+ <p>By this time, Alice had found her way into a tidy little room with a table in the
+ window, and on it a fan and two or three pairs of tiny white kid-gloves; she took up
+ the fan and a pair of the gloves and was just going to leave the room, when her eyes
+ fell upon a little bottle that stood near the looking-glass. She uncorked it and put it
+ to her lips, saying to herself, "I do hope it'll make me grow large again, for, really,
+ I'm quite tired of being such a tiny little thing!"</p>
+
+ <p>Before she had drunk half the bottle, she found her head pressing against the
+ ceiling, and had to stoop to save her neck from being broken. She hastily put down the
+ bottle, remarking, "That's quite enough&#8212;I hope I sha'n't grow any more."</p>
+
+ <p>Alas! It was too late to wish that! She went on growing and growing and very soon
+ she had to kneel down on the floor. Still she went on growing, and, as a last resource,
+ she put one arm out of the window and one foot up the chimney, and said to
+ herself,<a id="Page_22" class="pageno" title="[Pg 22]"></a> "Now I can do no more,
+ wha tev er happens. What <i>will</i> become of me?"</p>
+
+ <figure class="small">
+ <img src="images/i012_th.jpg" alt="Illo12" />
+ </figure>
+
+ <p>Luckily for Alice, the little mag ic b ottle had now had its full effect and she grew
+ no larger. After a few minutes she hear d a voice outside and stopped to listen.</p>
+
+ <p>"Mary Ann! Mary Ann!" said the voice . "Fetch me my gloves this moment!" Thencame a
+ little pattering of feet on the stairs. Alice knew it was the Rabbit coming to look for
+ her and she trembled till she shoo k th e house, quite forgetting that she was now about
+ a thousand times as large as the Rabbit and had no reason to be afraid of it.</p>
+
+ <p>Presently the Rabbit came up to the door and tried to open it; but as the door
+ opened inwards and Alice's elbow was press ed h ard against it, that attempt proved a
+ failure. Alice heard it sayto itself, "Then I'll g o 'round and get in at the
+ window."</p>
+
+ <p>"<i>That</i> you won't!" thought Ali ce; and after waiting till she fancied she heard
+ the Rabbit just under the window, sh e suddenly spread out her hand and<a id="Page_23"
+ class="pageno" title="[Pg 23]"></a > made asnatch in the air. She did not get hold of
+ anything, but she heard a little s hriek and a fall and a crash of bro ken glass, from
+ which she concluded that it was just possible it had fallen into a c ucumber-frame or
+ something of that sort.</p>
+
+ <p>Next came an angry voice&#8212;the Rabbit's&#8212;" Pat!Pat! Where are you?" And
+ then a voice she had never heard before, "Sure t hen, I'm here! D iggi ng for apples, yer
+ honor!"</p>
+
+ <p>"Here! Come and help me out of this! Now tell me, Pat, what's that in the
+ windo w?"</p>
+
+ <p>"Sure, it's an arm, yer honor!"</p>
+
+ <p>"Well, it's got no business the re, at any rate; go and take it away!"</p>
+
+ <p>There was a long silence after this an d Alice could only hear whispers now and then,
+ and at last she spread out her hand ag ain and made another snatch in the air. This time
+ there were <i>two</i> little shrieks a nd more sounds of brok en g lass. "I wonder what
+ they'll do next!" thought Alice. "As for pulling me out of the wi ndow, I only wish they
+ <i>could</i>!"</p>
+
+ <p>She waited for some time without h earing anything more. At last came a rumbling of
+ little cart-wheels and the sound of a good many voices all talking together. She made
+ out the words: "Where's the other lad der? Bill's got the other&#8212;Bill! Here, Bill!
+ Will the roof bear?&#8212;Who's to g o do wn the chimney?&#8212;Nay, <i>I</i> sha'n't!
+ <i>You</i> do it! Here, Bill! The master s ays you've got to go down the chimney!"</p>
+
+ <p>Alice drew her foot as far down the c himney as she couldand waited till she heard a
+ little animal scratching and scrambling a bout in the chimney close above
+ <a id="Page_24" class="pageno" title="[Pg 24]"></a> her; then she gave one sharp kick and waited to see
+ what would happen next.</p>
+
+ <p>The first thing she heard was a general chorus of "There goes Bill!" then the
+ Rabbit's voice alone&#8212;"Catc h him, you by the hedge!" Then silence a nd t hen another
+ confusion of voices&#8212;"Hold up his head&#8212;Brandy now&#8212;Don 't choke
+ him&#8212;What happened to you?"</p>
+
+ <p>Lastcame a little f eeble, squeaking voice, "Well, I hardly know&#8212;No mor e,
+ thank ye. I'm better now&#8212;all I know is, something comes at me like a
+ Jack-in-the -box and up I goes like a sky-rocket!"</p>
+
+ <p>Afte r a minute or two of silence, they began moving about again, and Alice heard the
+ Rabbit say , "A barrowful will do, to begin with."</p>
+
+ <p>"A barrowful of <i>what</i>?" though t Alice. But she had not long to doubt, for the
+ next moment a shower of little pe bbles came rattling in at the window and some of them
+ hither in the face. Alice no ticed, with some surprise, that the pebbles were all
+ turning into little cakes as they lay on the floor and abr ight idea came into her
+ head. "If Ieat one of these cakes," she thought, "it's sure to m ake <i>some</i> change
+ in my size."</p>
+
+ <p>So she swallowed one of the cakes an d was delighted to find that she began shrinking
+ directly. As soon as she was small enough to get through the door, she ran out of the
+ house and found quite a crowd of lit tle animals and birds waiting outside. They all
+ m ade a rush at Alice the moment she ap peared, but she ran off as hard as she could and
+ soon found herself safe in a thick wood.</p>
+
+ <figure class="full">
+ <img src="images/plate03_th.jpg" alt="The Duchess tucked her arm affectionately into Alice's." title=
+ "The Duchess tucked her arm affectionately into Alice's." />
+ <figcaption>
+ <p>"The Duchess tucked her arm affectionately into Alice's."</p>
+ </figcaption>
+ </figure>
+
+ <p>"The first thing I've got to do," said Alice to herself, <a id="Page_25" class=
+ "pageno" title="[Pg 25]"></a>as she wande red about in the wood, "is to grow to my right
+ size again; and the second thing i s to find my way into that lovely garden. I suppose I
+ ought to eat or drink something or other, but the great question is 'What?'"</p>
+
+ <p>Alice looked all arou nd her at the flowers and the blades of grass, but she could
+ notsee anything that loo kedlike the right thing to eat or drink under the
+ circumstances. There was a large mushroom growing near her, about the same height as
+ herself. She stretched herself u p on tiptoe and peeped over the edge and her eyes
+ immediately met those of a large blue caterpillar, that was sitting on the top, with
+ its armsfolded, quietly smoking a long hookah a nd taking not the smallest notice of
+ her or of anything else.</p>
+
+ <figure class="small">
+ <img src="images/i013_th.jpg" alt="Illo13" />
+ </figure>
+
+ <p><a id="Page_26" class="pageno" title="[Pg 26]"></a></p>
+
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_005.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_005.xhtml
new file mode 100644
index 0000000..25d3522
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_005.xhtml
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00008"><a id="V_ADVICE_FROM_A_CATERPILLAR"></a>
+ Advice From A Caterpillar</h2>
+
+ <p>At last the Caterpillar took the hookah out of its mouth and
+ addressed Alice in alanguid, sleepy voice.</p>
+
+ <p>"Who are <i>you</i>?" said the Caterpillar.</p>
+
+ <figure class="small">
+ <img src="images/i014_th.jpg" alt="Illo14" />
+ </figure>
+
+ <p>Alice replied, rather shyly, "I&#8212;I hardly know, sir, just at present&#8212;at
+ least I know who I <i>was</i> when I got up this morning, but I think I must have
+ changed several times since then."</p>
+
+ <p> "Wha t do you mean by that?" said the Caterpillar, sternly. "Explain yourself!"<a id=
+ "Page_27" class="pageno" title="[Pg 27]"></a></p>
+
+ <p>"I can't explain<i>myself</i>, I'm afraid, sir," said Alice,"because I'm not
+ myself, you see&#8212;being so ma nydifferent sizes in a day is very confusing." She
+ drew hers elf up and said very gravely, "I think you ought to tell me who <i>you</i>
+ are, first."</p>
+
+ <p>"Why?" said the Caterpillar.</p>
+
+ <p>As Alice could not think of any good reason and the Caterpillar seemed to be in a
+ <i>very</i> u npleasant state of mind, she turned away.</p>
+
+ <p>"Come back!" the Caterpillar called after her. "I've something important to say!"
+ Alice turned and came back again.</p>
+
+ <p>"Keep your temper," said the Caterpillar.</p>
+
+ <p>"Is that all?" said Alice, swallowing down her anger as well as she could.</p>
+
+ <p>"No," said the Caterpillar.</p>
+
+ <p>It unfolded its arms, took the hookah out of its mouth again, and said, " So you
+ think you're changed, do you?"</p>
+
+ <p>"I'm afr aid, I am, sir," said Alice. "I can't remember things as I used&#8212;and I
+ don't keep the same size for ten minutes together!"</p>
+
+ <p>"What size d o you want to be?" asked the Caterpillar.</p>
+
+ <p>"Oh, I'mnot particular as to si ze," Alice hastily replied, "only one doesn't like
+ changing sooften, you know. I should like to be a <i>little</i> larger, sir, if you
+ wouldn't mind," said Alice. "Three inches is such a wretched height to be."</p>
+
+ <p>"It is a very good height indeed!" said the Caterpillar an grily, rearing itself
+ upright as it spoke (it was exactly three inches high).<a id="Page_28" class="pageno"
+ title="[Pg 28]"></a></p>
+
+ <p>In a minute or two, the Caterpillar got down off the mushroom and crawled away in to
+ the grass,merely remarking, as it went, "One side will make you grow taller, and the
+ other side will make you grow shorter."</p>
+
+ <p>"One side of <i>what</i>? The other side of <i >what</i>?" thought Alice to
+ herself.</p>
+
+ <p>"Of the mushroom," said the Caterpillar, just as if she had asked it aloud; and in
+ another moment, it was out of sight.</p>
+
+ <p>Alice remained looking thoughtfully at the mushroom for a minute, trying to make out
+ whichwere the two sides of it. At last she stretched her arms 'round it as far as they
+ would go, and broke off a bit of the edge with each hand.</p>
+
+ <p>"And now which is which?" she said to herself, and nibbled a little of the
+ right-hand bit to trythe effect. The next moment she felt a violent blow underneath
+ her chin&#8212;it had struck her foot!</p>
+
+ <p>She was a gooddeal frightened b y this very sudden change, as she was shrinking
+ rapidly; so she set to work at once to eat some of the other bit. Her chin was pressed
+ so closely against her foo tthat there was hardly room to open her mouth; but she did
+ it at last and managed to s wallow a morsel of the left-hand bit....</p>
+
+ <p>"Come, my head's free at last!" said Alice; but all she could see, when she loo ked
+ down, was an immense length of neck, which seemed to rise like a stalk out of a sea of
+ green leaves that lay far below her.</p>
+
+ <p>"Where <i>have</i> my shoulders got to? And oh, mypoor hands, how is it I can't see
+ you?"Shewas de<a id="Page_29" class="pageno" title="[Pg 29]"></a>lighted to find that
+ her neck would bend about easily in any direction, like a serpent. She had just
+ succeeded in curving it down into a gr aceful zigzag and was going to dive inamong the
+ leaves, when a s harp hiss made her draw back in a hurry &#8212;a large pigeon had flo wn
+ into her face and was beating her violently with its wings.</p>
+
+ <figure class="small">
+ <img src="images/i015_th.jpg" alt="Illo15" />
+ </figure>
+
+ <p>"Serpent!" cried the Pigeon.</p>
+
+ <p>"I'm <i>not</i> a serpent!" said Alice indignantly. "Let me alone!"</p>
+
+ <p>"I've tried the roo ts of trees, and I've tried banks, and I've tri ed hedges," the
+ Pigeon went on, "but those serpents! There's no pleasing them!"</p>
+
+ <p>Alice was more and more puzzled.</p>
+
+ <p>"As if it wasn't trouble enough hatching the eggs," said the Pigeon, "but I must be
+ on the look-out for serpents, night and day! And just as I'd taken the highest tree in
+ the wood," continued the Pigeon, raising its voice to a shriek, "and just as I was
+ thinkingI should be free of them at last, they must needs come wriggling down from the
+ sky! Ugh, Serpent!"</p>
+
+ <p>"But I'm <i>not</i> a serpent, I tell you!" said Alice. "I'm a&#8212;I'm a&#8212;I'm
+ a little girl," she added rather<a id="Page_30" class="pageno" title="[Pg 30]"></a>
+ doubtfully, as she remembered the numbe r of changes she had gone through that day.</p>
+
+ <p>"You're looking for eggs, I know <i>that</i> well enough," said the Pigeon; "and
+ what does it matter to me whether you're a little girl or a serpent?"</p>
+
+ <p>"It matters a good deal to <i>me</i>," said Alice h astily; "but I'm not looking for
+ eggs, as it happens, and if I was, I shouldn't want <i>yours</i>&#8212;I don't like
+ them raw."</p>
+
+ <p>"Well, be off, then!" said the Pige on in a sulky tone, as it settled down again into
+ its nest. Alice crouched down a mong the trees as well as she could, for her neck kept
+ getting entangled among the bra nches, and every now and then she had to stop and
+ untwist it. After awhile she rememb ered that she still held the pieces of mushroom in
+ her hands, and she set to work very carefully, nibbling first at one and then at the
+ other, and growing sometimes taller and sometimes shorter, until she had succeeded in
+ bringing herself down to her usual height.</p>
+
+ <p>It was so long since she had been anything near the right size that it felt quite
+ strange at first. "The next thing is to get into that beautiful garden&#8212;how
+ <i>is</i> that to be done, I wonder?" As she said this, she came suddenly upon an open
+ place, with a little house in it about four feet high. "Whoever lives there," thought
+ Alice, "it'll never do to come upon them <i>this</i> size;why, I should frighten them
+ out of their wits!" She did not venture to go near the house till she had brought
+ herself down to nine inches high.</p>
+
+ <p><a id="Page_31" class="pageno" title="[Pg 31]"></a></p>
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_006.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_006.xhtml
new file mode 100644
index 0000000..b36f41e
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_006.xhtml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00009"><a id="VI_PIG_AND_PEPPER"></a>Pig And Pepper</h2>
+
+ <p>For a minute or twoshe stood looking at the house, when
+ suddenly a footman in livery came running out of the wood (judging by his face only,
+ she would have called him a fish)&#8212;and rapped loudly at the door with his
+ knuckles. It was opened by another footman in livery,with a round face and large eyes
+ like a frog.</p>
+
+ <figure class="small">
+ <img src="images/i015_th.jpg" alt="Illo15" />
+ </figure>
+
+ <p>The Fish-Footman began by producing from under his arm a great letter, and this he
+ handed over to the other, saying, in a solemn tone, "For the Duchess.<a id="Page_32"
+ class="pageno" title="[Pg 32]"></a> An invitation from the Queen to play croquet." The
+ Frog-Footman repeated, in the same solemn tone, "From the Queen. An invitation for the
+ Duchess to play croquet." Then they both bowed low and their curls got entangled
+ together.</p>
+
+ <p>When Alice next peeped out, the Fish-Footman was gone, and the other was sitting on
+ the ground near the door, staring stupidly up into the sky. Alice went timidly up to
+ the door and knocked.</p>
+
+ <p>"There's no sortof use in knocking," said the Footman, "and that for two reasons.
+ First, because I'm on the same side of the door as you are; secondly, because they're
+ making such a noise inside, no one could possibly hear you." And certainly there
+ <i>was</i> a most extraordinary noise going on within&#8212;a constant howling and
+ sneezing, and every now and then a great crash, as if a dish or kettle had been broken
+ to pieces.</p>
+
+ <p>"How am I to get in?" asked Alice.</p>
+
+ <p>"<i>Are</i> you to get in at all?" said the Footman. "That's the first question, you
+ know."</p>
+
+ <p>Alice opened the door and went in. The door led right into a large kitchen, which
+ was full of smoke from one end to the other; the Duchess was sitting on a three-legged
+ stool in the middle, nursing a baby; the cook was leaning over the fire, stirring a
+ large caldron which seemed to be full of soup.</p>
+
+ <p>"There's certainly too much pepper in that soup!" Alice said to herself, as well as
+ she could for sneezing. Even the Duchess sneezed occasionally; and asforthe baby, it
+ was sneezing and howling alternately without a moment'spause. The only two
+ creatures<a id="Page_33" class="pageno" title="[Pg 33]"></a> in the kitchen that did
+ <i>not</i> sneeze were the cook and a large cat, which was grinning from ear to
+ ear.</p>
+
+ <p>"Please would you tell me," said Alice, a little timidly, "why your cat grins like
+ that?"</p>
+
+ <p>"It's a Cheshire-Cat," said the Duchess,"and that's why."</p>
+
+ <p>"I didn't know that Cheshire-Cats always grinned; in fact, I didn't know that cats
+ <i>could</i> grin," said Alice.</p>
+
+ <p>"You don't know much," said the Duchess, "and that's a fact."</p>
+
+ <p>Just then the cook took the caldron of soupoff the fire, and at once set to work
+ throwing everything within her reach at the Duchess and the baby&#8212;the fire-irons
+ came first; then followed a shower of saucepans, plates and dishes. The Duchess took no
+ notice of them, even when they hit her, and the baby was howling so much already that
+ itwas quite impossible to say whether the blows hurt it or not.</p>
+
+ <p>"Oh, <i>please</i> mind what you're doing!" cried Alice, jumping up and down in an
+ agony of terror.</p>
+
+ <p>"Here! You may nurse it a bit, if you like!" the Duchess said to Alice, flinging the
+ baby at her as she spoke. "I must go and get ready to play croquet with the Queen," and
+ she hurried out of the room.</p>
+
+ <p>Alice caught the baby with some difficulty, as it was a queer-shaped little creature
+ and held out its arms and legs in all directions. "If I don't take this child away with
+ me," thought Alice, "they're sure to kill it in a day or two. Wouldn't it be murder to
+ leave it behind?" She said the last words out loud and the little thing grunted in
+ reply.<a id="Page_34" class="pageno" title="[Pg 34]"></a></p>
+
+ <p>"If you're going to turn into a pig, my dear," said Alice, "I'll have nothing more
+ to do with you. Mind now!"</p>
+
+ <p>Alice was just beginning to think to herself, "Now, what am I to do with this
+ creature, when I get it home?" when it grunted again so violently that Alice looked
+ down into its face in some alarm. This time there could be <i>no</i> mistake about
+ it&#8212;it was neither more nor less than a pig; so she set the little creature down
+ and felt quite relieved to see it trot awayquietly into the wood.</p>
+
+ <p>Alice was a little startled by seeing the Cheshire-Catsitting on a bough of a tree
+ a few yards off. The Cat only grinned when it saw her. "Cheshire-Puss," began Alice,
+ rather timidly, "would you please tell me which way I ought to gofrom here?"</p>
+
+ <p>"In <i>that</i> direction," the Cat said, waving the right paw 'round, "lives a
+ Hatter; and in <i>that</i> direction," waving the other paw, "lives a March Hare. Visit
+ either you like; they're both mad."</p>
+
+ <p>"But I don't want to go among mad people," Alice remarked.</p>
+
+ <p>"Oh, you can't help that," said the Cat; "we're all mad here. Do you play croquet
+ with the Queen to-day?"</p>
+
+ <p>"I should like it very much," said Alice, "but I haven't been invited yet."</p>
+
+ <p>"You'll see me there," said the Cat, and vanished.</p>
+
+ <p>Alice had not gone much farther before she came in sight of the house of the March
+ Hare; it was so large a house that she did not like to go near till she had nibbled
+ some more of the left-hand bit of mushroom.</p>
+
+ <p><a id="Page_35" class="pageno" title="[Pg 35]"></a></p>
+
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_007.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_007.xhtml
new file mode 100644
index 0000000..5a79bca
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_007.xhtml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00010"><a id="VII_A_MAD_TEA-PARTY"></a>A Mad Tea-Party</h2>
+
+ <p>There was a table set out under a tree in front of the
+ house, and the March Hare and the Hatter were having tea at it; a Dormouse was sitting
+ between them, fast asleep.</p>
+
+ <p>The table was a large one, but the three were all crowded together at one corner of
+ it. "No room! No room!" they cried out when they saw Alice coming. "There's
+ <i>plenty</i> of room!" said Alice indignantly, and she sat down in a large arm-chair
+ at one end of the table.</p>
+
+ <p>The Hatter opened his eyes very wide on hearing this, but all he said was "Why is a
+ raven like a writing-desk?"</p>
+
+ <p>"I'm glad they've begun asking riddles&#8212;I believe I can guess that," she added
+ aloud.</p>
+
+ <p>"Do you mean that you think you can find out the answer to it?" said the March
+ Hare.</p>
+
+ <p>"Exactly so," said Alice.</p>
+
+ <p>"Then you should say what you mean," the March Hare went on.</p>
+
+ <p>"I do," Alice hastily replied; "at least&#8212;at least I mean what I
+ say&#8212;that's the same thing, you know."</p>
+
+ <p>"You might just as well say," added the Dormouse, which seemed to be talking in its
+ sleep, "that 'I breathe when I sleep' is the same thing as 'I sleep when I
+ breathe!'"<a id="Page_36" class="pageno" title="[Pg36]"></a></p>
+
+ <p>"It <i>is</i> the same thing with you," said the Hatter, and he poured a little hot
+ tea upon its nose. The Dormouse shook its head impatiently and said, without opening
+ its eyes,"Ofcourse, of course; just what I was going to remark myself."</p>
+
+ <figure class="small">
+ <img src="images/i017_th.jpg" alt="Illo17" />
+ </figure>
+
+ <p>"Have you guessed the riddle yet?" the Hatter said, turning to Alice again.</p>
+
+ <p>"No, I give it up," Alice replied. "What's theanswer?"</p>
+
+ <p>"I haven't the slightest idea," said the Hatter.</p>
+
+ <p>"Nor I,"said the March Hare.</p>
+
+ <p>Alice gave a weary sigh. "I think you might do something better with the time," she
+ said, "than wasting it in asking riddles that have no answers."</p>
+
+ <p>"Take some more tea," the March Hare said to Alice, very earnestly.</p>
+
+ <p>"I've had nothing yet," Alice replied in an offended tone, "so I can't take
+ more."</p>
+
+ <p>"You mean you can't take <i>less</i>," said the Hatter; "it's very easy to take
+ <i>more</i> than nothing."</p>
+
+ <p>At this, Alice got up and walked off. The Dormouse fell asleep instantly and neither
+ of the others took the least notice of her going, thoughshe looked <a id="Page_37"
+ class="pageno" title="[Pg 37]"></a>back once or twice; the last time she saw them, they
+ were trying to put the Dormouse into the tea-pot.</p>
+
+
+ <figure class="full">
+ <img src="images/plate04_th.jpg" alt="The Trial of the Knave of Hearts." title="The Trial of the Knave of Hearts." />
+ <figcaption>
+ <p>The Trial of the Knave of Hearts.</p>
+ </figcaption>
+ </figure>
+
+ <p>"At any rate, I'll never go <i>there</i> again!" said Alice, as she picked her way
+ through the wood. "It's the stupidest tea-party I ever was at in all my life!" Just as
+ she said this, she noticed that one of the trees had a door leading right into it.
+ "That's very curious!" she thought. "I think I may as well go in at once." And in she
+ went.</p>
+
+ <p>Once more she foundherself in the long hall and close to the little glass table.
+ Taking the little golden key, she unlocked the door that led into the garden. Then she
+ set to work nibbling at the mushroom (she had kept a piece of it in her pocket) till
+ she was about a foot high; then she walked down the little passage; and
+ <i>then</i>&#8212;she found herself at last in the beautiful garden, among the bright
+ flower-beds and the cool fountains.</p>
+
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_008.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_008.xhtml
new file mode 100644
index 0000000..06f0522
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_008.xhtml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00011"><a id="VIII_THE_QUEENS_CROQUET_GROUND"></a>
+ The Queen's Croquet Ground</h2>
+
+ <p>A large rose-tree stood near the entrance of the garden; the
+ roses growing on it were white, but there were threegardeners at it, busily painting
+ them red. Suddenly their eyes chanced to fall upon Alice, as she stood watching them.
+ "Would you tell me, please," said Alice, a little timidly, "why you are painting those
+ roses?"</p>
+
+ <p>Five and Seven said nothing, butlooked at Two.<a id="Page_38" class="pageno" title=
+ "[Pg 38]"></a> Twobegan, in a low voice, "Why, the fact is, you see, Miss, this here
+ ought to have been a <i>red</i> rose-tree, and we put a white one in by mistake; and,
+ if the Queen was to find it out, we should all have our heads cut off, you know. So you
+ see, Miss, we're doing our best, afore she comes, to&#8212;" At this moment, Five, who
+ had been anxiously looking across the garden, called out, "The Queen! The Queen!" and
+ the three gardeners instantly threw themselves flat upon their faces. There was a sound
+ of many footstepsand Alice looked 'round, eager to see the Queen.</p>
+
+ <p>First came ten soldiers carrying clubs, with their hands and feet at the corners:
+ next the ten courtiers; these were ornamented all over with diamonds. After these came
+ the royal children; there were ten of them, all ornamented with hearts. Next came the
+ guests, mostly Kings and Queens, and among them Alice recognized the White Rabbit. Then
+ followed the Knave of Hearts, carrying the King's crown on a crimson velvet cushion;
+ and last of all this grand procession came THE KING AND THE QUEEN OF HEARTS.</p>
+
+ <p>When the procession came opposite to Alice, they all stopped and looked at her, and
+ the Queen said severely, "Who is this?" She said it to the Knave of Hearts, who only
+ bowed and smiled in reply.</p>
+
+ <p>"My name is Alice, so please Your Majesty," said Alice very politely; but she added
+ to herself, "Why, they're only a pack of cards, after all!"</p>
+
+ <p>"Can you play croquet?" shouted the Queen. The question was evidently meant for
+ Alice.<a id="Page_39" class="pageno" title="[Pg 39]"></a></p>
+
+ <p>"Yes!" said Alice loudly.</p>
+
+ <p>"Come on, then!" roared the Queen.</p>
+
+ <p>"It's&#8212;it's a very fine day!" said a timid voice to Alice. She was walking by
+ the White Rabbit, who was peeping anxiously into her face.</p>
+
+ <p>"Very," said Alice. "Where's the Duchess?"</p>
+
+ <p>"Hush! Hush!" said the Rabbit. "She's under sentence of execution."</p>
+
+ <p>"What for?" said Alice.</p>
+
+ <p>"She boxed the Queen's ears&#8212;" the Rabbit began.</p>
+
+ <p>"Get to your places!" shouted the Queen in a voice of thunder, and people began
+ running about in all directions, tumbling up against each other. However, they got
+ settled down in a minute or two, and the game began.</p>
+
+ <p>Alice thought she had never seen such a curious croquet-ground in her life; it was
+ all ridges and furrows. The croquet balls were live hedgehogs, and the mallets live
+ flamingos and the soldiers had to double themselves up and stand on their hands and
+ feet, to make the arches.</p>
+
+ <p>The players all played at once, without waiting for turns, quarrelling all the while
+ and fighting for the hedgehogs; and in a very short time, the Queen was in a furious
+ passion and went stamping about and shouting, "Off with his head!" or "Off with her
+ head!" about once in a minute.</p>
+
+ <p>"They're dreadfully fond of beheading people here," thought Alice; "the great wonder
+ is that there's anyone left alive!"</p>
+
+ <p>She was looking about for some way of escape, when she noticed a curious appearance
+ in the air.<a id="Page_40" class="pageno" title="[Pg 40]"></a> "It's the Cheshire-Cat,"
+ she said to herself; "now I shall have somebody to talk to."</p>
+
+ <p>"How are you getting on?" said the Cat.</p>
+
+ <p>"I don't think they play at all fairly," Alice said, in a rather complaining tone;
+ "and they all quarrel so dreadfully one can't hear oneself speak&#8212;and they don't
+ seem to have any rules in particular."</p>
+
+ <p>"How do you like the Queen?" said the Cat in a low voice.</p>
+
+ <p>"Not at all," said Alice.</p>
+
+ <figure class="small">
+ <img src="images/i018_th.jpg" alt="Illo18" />
+ </figure>
+
+ <p>Alice thought she might as well go back and see how the game was going on. So she
+ went off in search of her hedgehog. The hedgehog was engaged in a fight with another
+ hedgehog, which seemed to Alice an excellent opportunity for croqueting one of them
+ with the other; the only difficulty was that her flamingo was gone across to the other
+ side of the garden, where Alice could see it trying, in a helpless sort of way, to fly
+ up into a tree. She caught the flamingo and tucked it away under her arm, that it might
+ not escape again.<a id="Page_41" class="pageno" title="[Pg 41]"></a></p>
+
+ <p>Just then Alice ran across the Duchess (who was now out of prison). She tucked her
+ arm affectionately into Alice's and they walked off together. Alice was very glad to
+ find her in such a pleasant temper. She was a little startled, however, when she heard
+ the voice of the Duchess close to her ear. "You're thinking about something, my dear,
+ and that makes you forget to talk."</p>
+
+ <p>"The game's going on rather better now," Alice said, by way of keeping up the
+ conversation a little.</p>
+
+ <p>"'Tis so," said the Duchess; "and the moral of that is&#8212;'Oh, 'tis love, 'tis
+ love that makes the world go 'round!'"</p>
+
+ <p>"Somebody said," Alice whispered, "that it's done by everybody minding his own
+ business!"</p>
+
+ <p>"Ah, well! It means much the same thing," said the Duchess, digging her sharp little
+ chin into Alice's shoulder, as she added "and the moral of <i>that</i> is&#8212;'Take
+ care of the sense and the sounds will take care of themselves.'"</p>
+
+ <p>To Alice's great surprise, the Duchess's arm that was linked into hers began to
+ tremble. Alice looked up and there stood the Queen in front of them, with her arms
+ folded, frowning like a thunderstorm!</p>
+
+ <p>"Now, I give you fair warning," shouted the Queen, stamping on the ground as she
+ spoke, "either you or your head must be off, and that in about half no time. Take your
+ choice!" The Duchess took her choice, and was gone in a moment.</p>
+
+ <p>"Let's go on with the game," the Queen said to Alice; and Alice was too much
+ frightened to say a<a id="Page_42" class="pageno" title="[Pg 42]"></a> word, but slowly
+ followed her back to the croquet-ground.</p>
+
+ <p>All the time they were playing, the Queen never left off quarreling with the other
+ players and shouting, "Off with his head!" or "Off with her head!" By the end of half
+ an hour or so, all the players, except the King, the Queen and Alice, were in custody
+ of the soldiers and under sentence of execution.</p>
+
+ <p>Then the Queen left off, quite out of breath, and walked away with Alice.</p>
+
+ <p>Alice heard the King say in a low voice to the company generally, "You are all
+ pardoned."</p>
+
+ <p>Suddenly the cry "The Trial's beginning!" was heard in the distance, and Alice ran
+ along with the others.</p>
+
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_009.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_009.xhtml
new file mode 100644
index 0000000..57653ae
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_009.xhtml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00012"><a id="IX_WHO_STOLE_THE_TARTS"></a>Who Stole The Tarts?</h2>
+
+ <p>The King and Queen of Hearts were seated on their throne
+ when they arrived, with a great crowd assembled about them&#8212;all sorts of little
+ birds and beasts, as well as the whole pack of cards: the Knave was standing before
+ them, in chains, with a soldier on each side to guard him; and near the King was the
+ White Rabbit, with a trumpet in one hand and a scroll of parchment in the other. In the
+ very middle of the court<a id="Page_43" class="pageno" title="[Pg 43]"></a> was a
+ table, with a large dish of tarts upon it. "I wish they'd get the trial done," Alice
+ thought, "and hand 'round the refreshments!"</p>
+
+ <figure class="small">
+ <img src="images/i019_th.jpg" alt="Illo19" />
+ </figure>
+
+ <p>The judge, by the way, was the King and he wore his crown over his great wig.
+ "That's the jury-box," thought Alice; "and those twelve creatures (some were animals
+ and some were birds) I suppose they are the jurors."</p>
+
+ <p>Just then the White Rabbit cried out "Silence in the court!"</p>
+
+ <p>"Herald, read the accusation!" said the King.</p>
+
+ <p>On this, the White Rabbit blew three blasts on the trumpet, then unrolled the
+ parchment-scroll and read as follows:</p>
+
+ <div class="poem stanza">
+ <span class="i0">"The Queen of Hearts, she made some tarts,<br /></span> <span class=
+ "i2">All on a summer day;<br /></span> <span class="i0">The Knave of Hearts, he stole
+ those tarts<br /></span> <span class="i2">And took them quite away!"<br /></span>
+ </div>
+
+ <p>"Call the first witness," said the King; and the White Rabbit blew three blasts on
+ the trumpet and called out, "First witness!"</p>
+
+ <p>The first witness was the Hatter. He came in with<a id="Page_44" class="pageno"
+ title="[Pg 44]"></a> a teacup in one hand and a piece of bread and butter in the
+ other.</p>
+
+ <p>"You ought to have finished," said the King. "When did you begin?"</p>
+
+ <p>The Hatter looked at the March Hare, who had followed him into the court, arm in arm
+ with the Dormouse. "Fourteenth of March, I <i>think</i> it was," he said.</p>
+
+ <p>"Give your evidence," said the King, "and don't be nervous, or I'll have you
+ executed on the spot."</p>
+
+ <p>This did not seem to encourage the witness at all; he kept shifting from one foot to
+ the other, looking uneasily at the Queen, and, in his confusion, he bit a large piece
+ out of his teacup instead of the bread and butter.</p>
+
+ <p>Just at this moment Alice felt a very curious sensation&#8212;she was beginning to
+ grow larger again.</p>
+
+ <p>The miserable Hatter dropped his teacup and bread and butter and went down on one
+ knee. "I'm a poor man, Your Majesty," he began.</p>
+
+ <p>"You're a <i>very</i> poor <i>speaker</i>," said the King.</p>
+
+ <p>"You may go," said the King, and the Hatter hurriedly left the court.</p>
+
+ <p>"Call the next witness!" said the King.</p>
+
+ <p>The next witness was the Duchess's cook. She carried the pepper-box in her hand and
+ the people near the door began sneezing all at once.</p>
+
+ <p>"Give your evidence," said the King.</p>
+
+ <p>"Sha'n't," said the cook.</p>
+
+ <p>The King looked anxiously at the White Rabbit, who said, in a low voice, "Your
+ Majesty must cross-examine <i>this</i> witness."<a id="Page_45" class="pageno" title=
+ "[Pg 45]"></a></p>
+
+ <p>"Well, if I must, I must," the King said. "What are tarts made of?"</p>
+
+ <p>"Pepper, mostly," said the cook.</p>
+
+ <p>For some minutes the whole court was in confusion and by the time they had settled
+ down again, the cook had disappeared.</p>
+
+ <p>"Never mind!" said the King, "call the next witness."</p>
+
+ <p>Alice watched the White Rabbit as he fumbled over the list. Imagine her surprise
+ when he read out, at the top of his shrill little voice, the name "Alice!"</p>
+
+ </section>
+</body>
+</html> \ No newline at end of file
diff --git a/lib/epub.js/test/fixtures/alice/OPS/chapter_010.xhtml b/lib/epub.js/test/fixtures/alice/OPS/chapter_010.xhtml
new file mode 100644
index 0000000..4dc46c5
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/chapter_010.xhtml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="chapter">
+
+ <h2 id="pgepubid00013"><a id="X_ALICES_EVIDENCE"></a>Alice's Evidence</h2>
+
+ <p>"Here!" cried Alice. She jumped up in such a hurry that she
+ tipped over the jury-box, upsetting all the jurymen on to the heads of the crowd
+ below.</p>
+
+ <p>"Oh, I <i>beg</i> your pardon!" she exclaimed in a tone of great dismay.</p>
+
+ <p>"The trial cannot proceed," said the King, "until all the jurymen are back in their
+ proper places&#8212;<i>all</i>," he repeated with great emphasis, looking hard at
+ Alice.</p>
+
+ <p>"What do you know about this business?" the King said to Alice.</p>
+
+ <p>"Nothing whatever," said Alice.</p>
+
+ <p>The King then read from his book: "Rule forty-<a id="Page_46" class="pageno" title=
+ "[Pg 46]"></a>two. <i>All persons more than a mile high to leave the court</i>."</p>
+
+ <p>"<i>I'm</i> not a mile high," said Alice.</p>
+
+ <p>"Nearly two miles high," said the Queen.</p>
+
+ <figure>
+ <img src="images/i020_th.jpg" alt="Illo20" />
+ </figure>
+
+ <p>"Well, I sha'n't go, at any rate," said Alice.</p>
+
+ <p>The King turned pale and shut his note-book hastily. "Consider your verdict," he
+ said to the jury, in a low, trembling voice.</p>
+
+ <p>"There's more evidence to come yet, please Your Majesty," said the White Rabbit,
+ jumping up in a great hurry. "This paper has just been picked up. It seems to be a
+ letter written by the prisoner to&#8212;to somebody." He unfolded the paper as he spoke
+ and added, "It isn't a letter, after all; it's a set of verses."</p>
+
+ <p>"Please, Your Majesty," said the Knave, "I didn't write it and they can't prove that
+ I did; there's no name signed at the end."</p>
+
+ <p>"You <i>must</i> have meant some mischief, or else you'd have signed your name like
+ an honest man," said the King. There was a general clapping of hands at this.<a id=
+ "Page_47" class="pageno" title="[Pg 47]"></a></p>
+
+ <p>"Read them," he added, turning to the White Rabbit.</p>
+
+ <p>There was dead silence in the court whilst the White Rabbit read out the verses.</p>
+
+ <p>"That's the most important piece of evidence we've heard yet," said the King.</p>
+
+ <p>"<i>I</i> don't believe there's an atom of meaning in it," ventured Alice.</p>
+
+ <p>"If there's no meaning in it," said the King, "that saves a world of trouble, you
+ know, as we needn't try to find any. Let the jury consider their verdict."</p>
+
+ <p>"No, no!" said the Queen. "Sentence first&#8212;verdict afterwards."</p>
+
+ <p>"Stuff and nonsense!" said Alice loudly. "The idea of having the sentence
+ first!"</p>
+
+ <figure class="small">
+ <img src="images/ii021_th.jpg" alt="Illo21" />
+ </figure>
+
+ <p>"Hold your tongue!" said the Queen, turning purple.</p>
+
+ <p>"I won't!" said Alice.</p>
+
+ <p>"Off with her head!" the Queen shouted at the top of her voice. Nobody moved.</p>
+
+ <p>"Who cares for <i>you</i>?" said Alice (she had grown to her full size by this
+ time). "You're nothing but a pack of cards!"</p>
+
+ <p>At this, the whole pack rose up in the air and came flying down upon her; she<a id=
+ "Page_48" class="pageno" title="[Pg 48]"></a> gave a little scream, half of fright and
+ half of anger, and tried to beat them off, and found herself lying on the bank, with
+ her head in the lap of her sister, who was gently brushing away some dead leaves that
+ had fluttered down from the trees upon her face.</p>
+
+ <p>"Wake up, Alice dear!" said her sister. "Why, what a long sleep you've had!"</p>
+
+ <p>"Oh, I've had such a curious dream!" said Alice. And she told her sister, as well as
+ she could remember them, all these strange adventures of hers that you have just been
+ reading about. Alice got up and ran off, thinking while she ran, as well she might,
+ what a wonderful dream it had been.</p>
+
+ <figure class="small">
+ <img src="images/i022_th.jpg" alt="Illo22" />
+ </figure>
+
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/cover.xhtml b/lib/epub.js/test/fixtures/alice/OPS/cover.xhtml
new file mode 100644
index 0000000..ac72347
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/cover.xhtml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Cover</title>
+ <link rel="stylesheet" type="text/css" href="css/stylesheet.css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <img src="images/cover_th.jpg" alt="Cover Image" title="Cover Image"/>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/css/stylesheet.css b/lib/epub.js/test/fixtures/alice/OPS/css/stylesheet.css
new file mode 100644
index 0000000..57531fe
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/css/stylesheet.css
@@ -0,0 +1,105 @@
+body {
+ font-family: Georgia, serif;
+ font-size: 1em;
+ line-height: 1.33em;
+}
+
+/* Book Title */
+h1 {
+ font-size: 1.5em;
+ line-height: 1.33em;
+}
+
+/* Chapter Title */
+h2 {
+ font-size: 1.33em;
+ line-height: 1.2em;
+}
+
+/* Subtitle */
+h3 {
+ font-size: 1.25em;
+ line-height: 1.12em;
+}
+
+/* Meta Info */
+h4 {
+ font-size: 1.1em;
+ line-height: 1.05em;
+}
+
+/* Chapter Container */
+section {
+
+}
+
+section > p {
+
+}
+
+/* Drop Cap */
+section > p:first-of-type:first-letter {
+ float: left;
+ font-size: 4em;
+ line-height: .8;
+ padding: 0 .2em;
+ font-family: Georgia;
+}
+
+figure.small {
+
+}
+
+figure.full {
+
+}
+
+figure > img {
+
+}
+
+figcaption {
+
+}
+
+figcaption > p {
+
+}
+
+/* More specific Kindle Eink queries at: http://epubsecrets.com/media-queries-for-kindle-devices.php */
+
+/* Amazon Kindle */
+@media amzn-kf8 {
+
+}
+
+/* Many device available at: https://css-tricks.com/snippets/css/media-queries-for-standard-devices/ */
+
+/* Smartphone - Portrait */
+@media only screen
+ and (min-device-width: 320px)
+ and (max-device-width: 667px)
+ and (orientation: portrait) {
+
+}
+
+/* Smartphone - Landscape */
+@media only screen
+ and (min-device-width: 320px)
+ and (max-device-width: 667px)
+ and (orientation: landscape) {
+
+}
+
+/* Tablet - Portrait and Landscape */
+@media only screen
+ and (min-device-width: 768px)
+ and (max-device-width: 1024px) {
+
+}
+
+/* Laptop & Desktops */
+@media only screen
+ and (min-device-width: 1025px) {
+
+} \ No newline at end of file
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/cover_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/cover_th.jpg
new file mode 100644
index 0000000..b9cc3b3
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/cover_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i001_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i001_th.jpg
new file mode 100644
index 0000000..ab6a9c5
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i001_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i002_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i002_th.jpg
new file mode 100644
index 0000000..df12dc5
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i002_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i003_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i003_th.jpg
new file mode 100644
index 0000000..2005bd2
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i003_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i004_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i004_th.jpg
new file mode 100644
index 0000000..7ad8456
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i004_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i005_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i005_th.jpg
new file mode 100644
index 0000000..3d8cd6a
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i005_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i006_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i006_th.jpg
new file mode 100644
index 0000000..786b173
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i006_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i007_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i007_th.jpg
new file mode 100644
index 0000000..ef2cd70
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i007_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i008_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i008_th.jpg
new file mode 100644
index 0000000..7999df7
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i008_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i009_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i009_th.jpg
new file mode 100644
index 0000000..c89542b
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i009_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i010_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i010_th.jpg
new file mode 100644
index 0000000..73b480c
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i010_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i011_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i011_th.jpg
new file mode 100644
index 0000000..75d7162
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i011_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i012_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i012_th.jpg
new file mode 100644
index 0000000..a95a783
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i012_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i013_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i013_th.jpg
new file mode 100644
index 0000000..b0e5620
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i013_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i014_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i014_th.jpg
new file mode 100644
index 0000000..492169f
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i014_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i015_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i015_th.jpg
new file mode 100644
index 0000000..cba87ed
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i015_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i016_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i016_th.jpg
new file mode 100644
index 0000000..6e38f32
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i016_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i017_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i017_th.jpg
new file mode 100644
index 0000000..bc22737
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i017_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i018_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i018_th.jpg
new file mode 100644
index 0000000..b0e5de0
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i018_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i019_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i019_th.jpg
new file mode 100644
index 0000000..779d5aa
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i019_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i020_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i020_th.jpg
new file mode 100644
index 0000000..3db3517
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i020_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/i022_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/i022_th.jpg
new file mode 100644
index 0000000..f8a0b96
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/i022_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/ii021_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/ii021_th.jpg
new file mode 100644
index 0000000..2f83b7d
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/ii021_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/plate01_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/plate01_th.jpg
new file mode 100644
index 0000000..b8798cc
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/plate01_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/plate02_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/plate02_th.jpg
new file mode 100644
index 0000000..010d94c
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/plate02_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/plate03_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/plate03_th.jpg
new file mode 100644
index 0000000..e96ff78
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/plate03_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/plate04_th.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/plate04_th.jpg
new file mode 100644
index 0000000..a8184ea
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/plate04_th.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/images/title.jpg b/lib/epub.js/test/fixtures/alice/OPS/images/title.jpg
new file mode 100644
index 0000000..34a4fb2
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/images/title.jpg
Binary files differ
diff --git a/lib/epub.js/test/fixtures/alice/OPS/package.opf b/lib/epub.js/test/fixtures/alice/OPS/package.opf
new file mode 100644
index 0000000..da1f41e
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/package.opf
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="pub-id">
+ <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
+ <dc:language>en-US</dc:language>
+ <meta property="dcterms:modified">2012-01-18T12:47:00Z</meta>
+ <!-- Id, referenced above - in Reverse domain name notation -->
+ <dc:identifier id="pub-id">edu.nyu.itp.future-of-publishing.alice-in-wonderland</dc:identifier>
+ <!-- Basic Metadata -->
+ <dc:rights>Public domain in the USA.</dc:rights>
+ <dc:creator>Lewis Carroll</dc:creator>
+ <dc:contributor>Gordon Robinson</dc:contributor>
+ <dc:title>Alice's Adventures in Wonderland</dc:title>
+ <dc:subject>Fantasy</dc:subject>
+ <dc:source>http://www.gutenberg.org/files/19033/19033-h/19033-h.htm</dc:source>
+
+ <meta content="coverpage" name="cover"/>
+
+ </metadata>
+ <manifest>
+ <!-- Frontmater -->
+ <item id="toc" properties="nav" href="toc.xhtml" media-type="application/xhtml+xml"/>
+ <item id="cover" href="cover.xhtml" media-type="application/xhtml+xml"/>
+ <!-- Stylesheets -->
+ <item id="style" href="css/stylesheet.css" media-type="text/css"/>
+ <!-- Images -->
+ <item id="cover-image" properties="cover-image" href="images/cover_th.jpg" media-type="image/jpeg"/>
+ <item id="i001_th" href="images/i001_th.jpg" media-type="image/jpeg"/>
+ <item id="i002_th" href="images/i002_th.jpg" media-type="image/jpeg"/>
+ <item id="i003_th" href="images/i003_th.jpg" media-type="image/jpeg"/>
+ <item id="i004_th" href="images/i004_th.jpg" media-type="image/jpeg"/>
+ <item id="i005_th" href="images/i005_th.jpg" media-type="image/jpeg"/>
+ <item id="i006_th" href="images/i006_th.jpg" media-type="image/jpeg"/>
+ <item id="i007_th" href="images/i007_th.jpg" media-type="image/jpeg"/>
+ <item id="i008_th" href="images/i008_th.jpg" media-type="image/jpeg"/>
+ <item id="i009_th" href="images/i009_th.jpg" media-type="image/jpeg"/>
+ <item id="i010_th" href="images/i010_th.jpg" media-type="image/jpeg"/>
+ <item id="i011_th" href="images/i011_th.jpg" media-type="image/jpeg"/>
+ <item id="i012_th" href="images/i012_th.jpg" media-type="image/jpeg"/>
+ <item id="i013_th" href="images/i013_th.jpg" media-type="image/jpeg"/>
+ <item id="i014_th" href="images/i014_th.jpg" media-type="image/jpeg"/>
+ <item id="i015_th" href="images/i015_th.jpg" media-type="image/jpeg"/>
+ <item id="i016_th" href="images/i016_th.jpg" media-type="image/jpeg"/>
+ <item id="i017_th" href="images/i017_th.jpg" media-type="image/jpeg"/>
+ <item id="i018_th" href="images/i018_th.jpg" media-type="image/jpeg"/>
+ <item id="i019_th" href="images/i019_th.jpg" media-type="image/jpeg"/>
+ <item id="i020_th" href="images/i020_th.jpg" media-type="image/jpeg"/>
+ <item id="i022_th" href="images/i022_th.jpg" media-type="image/jpeg"/>
+ <item id="ii021_th" href="images/ii021_th.jpg" media-type="image/jpeg"/>
+ <item id="plate01_th" href="images/plate01_th.jpg" media-type="image/jpeg"/>
+ <item id="plate02_th" href="images/plate02_th.jpg" media-type="image/jpeg"/>
+ <item id="plate03_th" href="images/plate03_th.jpg" media-type="image/jpeg"/>
+ <item id="plate04_th" href="images/plate04_th.jpg" media-type="image/jpeg"/>
+ <item id="title-img" href="images/title.jpg" media-type="image/jpeg"/>
+ <!-- Chapters -->
+ <item id="titlepage" href="titlepage.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_001" href="chapter_001.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_002" href="chapter_002.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_003" href="chapter_003.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_004" href="chapter_004.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_005" href="chapter_005.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_006" href="chapter_006.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_007" href="chapter_007.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_008" href="chapter_008.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_009" href="chapter_009.xhtml" media-type="application/xhtml+xml"/>
+ <item id="chapter_010" href="chapter_010.xhtml" media-type="application/xhtml+xml"/>
+ </manifest>
+ <spine>
+ <!-- Frontmater -->
+ <itemref idref="cover" linear="no"/>
+ <itemref idref="toc" linear="no"/>
+ <!-- Chapters -->
+ <itemref linear="yes" idref="titlepage"/>
+ <itemref linear="yes" idref="chapter_001"/>
+ <itemref linear="yes" idref="chapter_002"/>
+ <itemref linear="yes" idref="chapter_003"/>
+ <itemref linear="yes" idref="chapter_004"/>
+ <itemref linear="yes" idref="chapter_005"/>
+ <itemref linear="yes" idref="chapter_006"/>
+ <itemref linear="yes" idref="chapter_007"/>
+ <itemref linear="yes" idref="chapter_008"/>
+ <itemref linear="yes" idref="chapter_009"/>
+ <itemref linear="yes" idref="chapter_010"/>
+ </spine>
+</package>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/titlepage.xhtml b/lib/epub.js/test/fixtures/alice/OPS/titlepage.xhtml
new file mode 100644
index 0000000..f7da637
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/titlepage.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+</head>
+<body>
+ <section epub:type="titlepage">
+
+ <p><a id="Page_1" class="pageno" title="[Pg 1]"></a></p>
+
+ <h1 id="pgepubid00001">
+ Alice's Adventures In Wonderland
+ </h1>
+
+ <p><a id="Page_2" class="pageno" title="[Pg 2]"></a></p>
+
+ <figure class="full titlepage">
+ <img src= "images/title.jpg" alt="title" />
+ </figure>
+
+
+ <p><a id="Page_3" class="pageno" title="[Pg 3]"></a></p>
+
+ <h4 id="pgepubid00003">
+ Copyright, 1916,<br />
+ By Sam'l Gabriel Sons &#38; Company<br />
+ New York
+ </h4>
+
+ <figure class="full">
+ <img src= "images/plate01_th.jpg" alt= "Alice in the Room of the Duchess." title= "Alice in the Room of the Duchess." />
+ <figcaption>
+ <p>Alice in the Room of the Duchess.</p>
+ </figcaption>
+ </figure>
+
+ </section>
+</body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/OPS/toc.xhtml b/lib/epub.js/test/fixtures/alice/OPS/toc.xhtml
new file mode 100644
index 0000000..eff8c48
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/OPS/toc.xhtml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+ <head>
+ <title>Alice's Adventures in Wonderland</title>
+ <link rel="stylesheet" href="css/stylesheet.css" type="text/css"/>
+ <meta charset="utf-8"/>
+ </head>
+ <body>
+ <section epub:type="frontmatter toc">
+ <header>
+ <h1>Contents</h1>
+ </header>
+
+ <nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc">
+ <ol>
+ <li><a href="titlepage.xhtml">Title Page</a></li>
+ <li><a href="chapter_001.xhtml">Down The Rabbit-Hole</a></li>
+ <li><a href="chapter_002.xhtml">The Pool Of Tears</a></li>
+ <li><a href="chapter_003.xhtml">A Caucus-Race And A Long Tale</a></li>
+ <li><a href="chapter_004.xhtml">The Rabbit Sends In A Little Bill</a></li>
+ <li><a href="chapter_005.xhtml">Advice From A Caterpillar</a></li>
+ <li><a href="chapter_006.xhtml">Pig And Pepper</a></li>
+ <li><a href="chapter_007.xhtml">A Mad Tea-Party</a></li>
+ <li><a href="chapter_008.xhtml">The Queen's Croquet Ground</a></li>
+ <li><a href="chapter_009.xhtml">Who Stole The Tarts?</a></li>
+ <li><a href="chapter_010.xhtml">Alice's Evidence</a></li>
+ </ol>
+ </nav>
+
+ </section>
+ </body>
+</html>
diff --git a/lib/epub.js/test/fixtures/alice/mimetype b/lib/epub.js/test/fixtures/alice/mimetype
new file mode 100644
index 0000000..57ef03f
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice/mimetype
@@ -0,0 +1 @@
+application/epub+zip \ No newline at end of file
diff --git a/lib/epub.js/test/fixtures/alice_without_cover.epub b/lib/epub.js/test/fixtures/alice_without_cover.epub
new file mode 100644
index 0000000..b215b2a
--- /dev/null
+++ b/lib/epub.js/test/fixtures/alice_without_cover.epub
Binary files differ
diff --git a/lib/epub.js/test/fixtures/chapter1-highlights.xhtml b/lib/epub.js/test/fixtures/chapter1-highlights.xhtml
new file mode 100644
index 0000000..200cd00
--- /dev/null
+++ b/lib/epub.js/test/fixtures/chapter1-highlights.xhtml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+<title>
+Moby-Dick</title>
+<link rel="stylesheet" href="css/stylesheet.css" type="text/css"></link>
+<meta charset="utf-8"/>
+</head>
+<body>
+<section class="body-rw Chapter-rw" epub:type="bodymatter chapter">
+<header>
+<h1><span class="audio" id="c001s0000">Chapter 1. Loomings.</span></h1></header>
+
+
+
+<p><span class="audio" id="c001s0001"><span id="highlight-2" class='annotator-hl'>Call me Ishmael.</span> Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.</span> <span class="audio" id="c001s0003">It is a way I have of driving off the spleen and regulating the circulation.</span> <span class="audio" id="c001s0004">Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can.</span> <span class="audio" id="c001s0005">This is my substitute for pistol and ball.</span> <span class="audio" id="c001s0006">With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship.</span> <span class="audio" id="c001s0007">There is nothing surprising in this.</span> <span class="audio" id="c001s0008">If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.</span></p>
+<p><span class="audio" id="c001p0002">There now is your insular city of the Manhattoes, belted round by wharves as Indian isles by coral reefs—commerce surrounds it with her surf. Right and left, the streets take you waterward. Its extreme downtown is the battery, where that noble mole is washed by waves, and cooled by breezes, which a few hours previous were out of sight of land. Look at the crowds of water-gazers there.</span></p>
+<p><span class="audio" id="c001p0003">Circumambulate the city of a dreamy Sabbath afternoon. Go from Corlears Hook to Coenties Slip, and from thence, by Whitehall, northward. What do you see?—Posted like silent sentinels all around the town, stand thousands upon thousands of mortal men fixed in ocean reveries. Some leaning against the spiles; some seated upon the pier-heads; some looking over the bulwarks of ships from China; some high aloft in the rigging, as if striving to get a still better seaward peep. But these are all landsmen; of week days pent up in lath and plaster—tied to counters, nailed to benches, clinched to desks. How then is this? Are the green fields gone? What do they here?</span>
+</p>
+<p><span class="audio" id="c001p0004">But look! here come more crowds, pacing straight for the water, and seemingly bound for a dive. Strange! Nothing will content them but the extremest limit of the land; loitering under the shady lee of yonder warehouses will not suffice. No. They must get just as nigh the water as they possibly can without falling in. And there they stand—miles of them—leagues. Inlanders all, they come from lanes and alleys, streets and avenues—north, east, south, and west. Yet here they all unite. Tell me, does the magnetic virtue of the needles of the compasses of all those ships attract them thither?</span></p>
+<p><span class="audio" id="c001p0005">Once more. Say you are in the country; in some high land of lakes. Take almost any path you please, and ten to one it carries you down in a dale, and leaves you there by a pool in the stream. There is magic in it. Let the most absent-minded of men be plunged in his deepest reveries—stand that man on his legs, set his feet a-going, and he will infallibly lead you to water, if water there be in all that region. Should you ever be athirst in the great American desert, try this experiment, if your caravan happen to be supplied with a metaphysical professor. Yes, as every one knows, meditation and water are wedded for ever.</span></p>
+<p><span class="audio" id="c001p0006">But here is an artist. He desires to paint you the dreamiest, shadiest, quietest, most enchanting bit of romantic landscape in all the valley of the Saco. What is the chief element he employs? There stand his trees, each with a hollow trunk, as if a hermit and a crucifix were within; and here sleeps his meadow, and there sleep his cattle; and up from yonder cottage goes a sleepy smoke. Deep into distant woodlands winds a mazy way, reaching to overlapping spurs of mountains bathed in their hill-side blue. But though the picture lies thus tranced, and though this pine-tree shakes down its sighs like leaves upon this shepherd’s head, yet all were vain, unless the shepherd’s eye were fixed upon the magic stream before him. Go visit the Prairies in June, when for scores on scores of miles you wade knee-deep among Tiger-lilies—what is the one charm wanting?—Water—there is not a drop of water there! Were Niagara but a cataract of sand, would you travel your thousand miles to see it? Why did the poor poet of Tennessee, upon suddenly receiving two handfuls of silver, deliberate whether to buy him a coat, which he sadly needed, or invest his money in a pedestrian trip to Rockaway Beach? Why is almost every robust healthy boy with a robust healthy soul in him, at some time or other crazy to go to sea? Why upon your first voyage as a passenger, did you yourself feel such a mystical vibration, when first told that you and your ship were now out of sight of land? Why did the old Persians hold the sea holy? Why did the Greeks give it a separate deity, and own brother of Jove? Surely all this is not without meaning. And still deeper the meaning of that story of Narcissus, who because he could not grasp the tormenting, mild image he saw in the fountain, plunged into it and was drowned. But that same image, we ourselves see in all rivers and oceans. It is the image of the ungraspable phantom of life; and this is the key to it all.</span></p>
+<p><span class="audio" id="c001p0007">Now, when I say that I am in the habit of going to sea whenever I begin to grow hazy about the eyes, and begin to be over conscious of my lungs, I do not mean to have it inferred that I ever go to sea as a passenger. For to go as a passenger you must needs have a purse, and a purse is but a rag unless you have something in it. Besides, passengers get sea-sick—grow quarrelsome—don’t sleep of nights—do not enjoy themselves much, as a general thing;—no, I never go as a passenger; nor, though I am something of a salt, do I ever go to sea as a Commodore, or a Captain, or a Cook. I abandon the glory and distinction of such offices to those who like them. For my part, I abominate all honourable respectable toils, trials, and tribulations of every kind whatsoever. It is quite as much as I can do to take care of myself, without taking care of ships, barques, brigs, schooners, and what not. And as for going as cook,—though I confess there is considerable glory in that, a cook being a sort of officer on ship-board—yet, somehow, I never fancied broiling fowls;—though once broiled, judiciously buttered, and judgmatically salted and peppered, there is no one who will speak more respectfully, not to say reverentially, of a broiled fowl than I will. It is out of the idolatrous dotings of the old Egyptians upon broiled ibis and roasted river horse, that you see the mummies of those creatures in their huge bake-houses the pyramids.</span></p>
+<p><span class="audio" id="c001p0008">No, when I go to sea, I go as a simple sailor, right before the mast, plumb down into the forecastle, aloft there to the royal mast-head. True, they rather order me about some, and make me jump from spar to spar, like a grasshopper in a May meadow. And at first, this sort of thing is unpleasant enough. It touches one’s sense of honour, particularly if you come of an old established family in the land, the Van Rensselaers, or Randolphs, or Hardicanutes. And more than all, if just previous to putting your hand into the tar-pot, you have been lording it as a country schoolmaster, making the tallest boys stand in awe of you. The transition is a keen one, I assure you, from a schoolmaster to a sailor, and requires a strong decoction of Seneca and the Stoics to enable you to grin and bear it. But even this wears off in time.</span></p>
+<p><span class="audio" id="c001p0009">What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? What does that indignity amount to, weighed, I mean, in the scales of the New Testament? Do you think the archangel Gabriel thinks anything the less of me, because I promptly and respectfully obey that old hunks in that particular instance? Who ain’t a slave? Tell me that. Well, then, however the old sea-captains may order me about—however they may thump and punch me about, I have the satisfaction of knowing that it is all right; that everybody else is one way or other served in much the same way—either in a physical or metaphysical point of view, that is; and so the universal thump is passed round, and all hands should rub each other’s shoulder-blades, and be content.</span></p>
+<p><span class="audio" id="c001p0010">Again, I always go to sea as a sailor, because they make a point of paying me for my trouble, whereas they never pay passengers a single penny that I ever heard of. On the contrary, passengers themselves must pay. And there is all the difference in the world between paying and being paid. The act of paying is perhaps the most uncomfortable infliction that the two orchard thieves entailed upon us. But BEING PAID,—what will compare with it? The urbane activity with which a man receives money is really marvellous, considering that we so earnestly believe money to be the root of all earthly ills, and that on no account can a monied man enter heaven. Ah! how cheerfully we consign ourselves to perdition!</span></p>
+<p><span class="audio" id="c001p0011">Finally, I always go to sea as a sailor, because of the wholesome exercise and pure air of the fore-castle deck. For as in this world, head winds are far more prevalent than winds from astern (that is, if you never violate the Pythagorean maxim), so for the most part the Commodore on the quarter-deck gets his atmosphere at second hand from the sailors on the forecastle. He thinks he breathes it first; but not so. In much the same way do the commonalty lead their leaders in many other things, at the same time that the leaders little suspect it. But wherefore it was that after having repeatedly smelt the sea as a merchant sailor, I should now take it into my head to go on a whaling voyage; this the invisible police officer of the Fates, who has the constant surveillance of me, and secretly dogs me, and influences me in some unaccountable way—he can better answer than any one else. And, doubtless, my going on this whaling voyage, formed part of the grand programme of Providence that was drawn up a long time ago. It came in as a sort of brief interlude and solo between more extensive performances. I take it that this part of the bill must have run something like this:</span></p>
+
+<div class="block-rw extract-rw headline-rw">
+<p><span class="audio" id="c001p0012">“GRAND CONTESTED ELECTION FOR THE PRESIDENCY OF THE UNITED STATES.</span></p>
+<p><span class="audio" id="c001p0013">“WHALING VOYAGE BY ONE ISHMAEL.</span></p>
+<p><span class="audio" id="c001p0014">“BLOODY BATTLE IN AFFGHANISTAN.”</span></p></div>
+<p><span class="audio" id="c001p0015">Though I cannot tell why it was exactly that those stage managers, the Fates, put me down for this shabby part of a whaling voyage, when others were set down for magnificent parts in high tragedies, and short and easy parts in genteel comedies, and jolly parts in farces—though I cannot tell why this was exactly; yet, now that I recall all the circumstances, I think I can see a little into the springs and motives which being cunningly presented to me under various disguises, induced me to set about performing the part I did, besides cajoling me into the delusion that it was a choice resulting from my own unbiased freewill and discriminating judgment.</span></p>
+<p><span class="audio" id="c001p0016">Chief among these motives was the overwhelming idea of the great whale himself. Such a portentous and mysterious monster roused all my curiosity. Then the wild and distant seas where he rolled his island bulk; the undeliverable, nameless perils of the whale; these, with all the attending marvels of a thousand Patagonian sights and sounds, helped to sway me to my wish. With other men, perhaps, such things would not have been inducements; but as for me, I am tormented with an everlasting itch for things remote. I love to sail forbidden seas, and land on barbarous coasts. Not ignoring what is good, I am quick to perceive a horror, and could still be social with it—would they let me—since it is but well to be on friendly terms with all the inmates of the place one lodges in.</span></p>
+<p><span class="audio" id="c001p0017">By reason of these things, then, the <span id="highlight-1" class='annotator-hl'>whaling voyage</span> was welcome; the great flood-gates of the wonder-world swung open, and in the wild conceits that swayed me to my purpose, two and two there floated into my inmost soul, endless processions of the whale, and, mid most of them all, one grand hooded phantom, like a snow hill in the air.</span></p>
+</section></body></html>
diff --git a/lib/epub.js/test/fixtures/chapter1.xhtml b/lib/epub.js/test/fixtures/chapter1.xhtml
new file mode 100644
index 0000000..1875a7e
--- /dev/null
+++ b/lib/epub.js/test/fixtures/chapter1.xhtml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+<title>
+Moby-Dick</title>
+<link rel="stylesheet" href="css/stylesheet.css" type="text/css"></link>
+<meta charset="utf-8"/>
+</head>
+<body>
+<section class="body-rw Chapter-rw" epub:type="bodymatter chapter">
+<header>
+<h1><span class="audio" id="c001s0000">Chapter 1. Loomings.</span></h1></header>
+
+
+
+<p><span class="audio" id="c001s0001">Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.</span> <span class="audio" id="c001s0003">It is a way I have of driving off the spleen and regulating the circulation.</span> <span class="audio" id="c001s0004">Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can.</span> <span class="audio" id="c001s0005">This is my substitute for pistol and ball.</span> <span class="audio" id="c001s0006">With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship.</span> <span class="audio" id="c001s0007">There is nothing surprising in this.</span> <span class="audio" id="c001s0008">If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.</span></p>
+<p><span class="audio" id="c001p0002">There now is your insular city of the Manhattoes, belted round by wharves as Indian isles by coral reefs—commerce surrounds it with her surf. Right and left, the streets take you waterward. Its extreme downtown is the battery, where that noble mole is washed by waves, and cooled by breezes, which a few hours previous were out of sight of land. Look at the crowds of water-gazers there.</span></p>
+<p><span class="audio" id="c001p0003">Circumambulate the city of a dreamy Sabbath afternoon. Go from Corlears Hook to Coenties Slip, and from thence, by Whitehall, northward. What do you see?—Posted like silent sentinels all around the town, stand thousands upon thousands of mortal men fixed in ocean reveries. Some leaning against the spiles; some seated upon the pier-heads; some looking over the bulwarks of ships from China; some high aloft in the rigging, as if striving to get a still better seaward peep. But these are all landsmen; of week days pent up in lath and plaster—tied to counters, nailed to benches, clinched to desks. How then is this? Are the green fields gone? What do they here?</span>
+</p>
+<p><span class="audio" id="c001p0004">But look! here come more crowds, pacing straight for the water, and seemingly bound for a dive. Strange! Nothing will content them but the extremest limit of the land; loitering under the shady lee of yonder warehouses will not suffice. No. They must get just as nigh the water as they possibly can without falling in. And there they stand—miles of them—leagues. Inlanders all, they come from lanes and alleys, streets and avenues—north, east, south, and west. Yet here they all unite. Tell me, does the magnetic virtue of the needles of the compasses of all those ships attract them thither?</span></p>
+<p><span class="audio" id="c001p0005">Once more. Say you are in the country; in some high land of lakes. Take almost any path you please, and ten to one it carries you down in a dale, and leaves you there by a pool in the stream. There is magic in it. Let the most absent-minded of men be plunged in his deepest reveries—stand that man on his legs, set his feet a-going, and he will infallibly lead you to water, if water there be in all that region. Should you ever be athirst in the great American desert, try this experiment, if your caravan happen to be supplied with a metaphysical professor. Yes, as every one knows, meditation and water are wedded for ever.</span></p>
+<p><span class="audio" id="c001p0006">But here is an artist. He desires to paint you the dreamiest, shadiest, quietest, most enchanting bit of romantic landscape in all the valley of the Saco. What is the chief element he employs? There stand his trees, each with a hollow trunk, as if a hermit and a crucifix were within; and here sleeps his meadow, and there sleep his cattle; and up from yonder cottage goes a sleepy smoke. Deep into distant woodlands winds a mazy way, reaching to overlapping spurs of mountains bathed in their hill-side blue. But though the picture lies thus tranced, and though this pine-tree shakes down its sighs like leaves upon this shepherd’s head, yet all were vain, unless the shepherd’s eye were fixed upon the magic stream before him. Go visit the Prairies in June, when for scores on scores of miles you wade knee-deep among Tiger-lilies—what is the one charm wanting?—Water—there is not a drop of water there! Were Niagara but a cataract of sand, would you travel your thousand miles to see it? Why did the poor poet of Tennessee, upon suddenly receiving two handfuls of silver, deliberate whether to buy him a coat, which he sadly needed, or invest his money in a pedestrian trip to Rockaway Beach? Why is almost every robust healthy boy with a robust healthy soul in him, at some time or other crazy to go to sea? Why upon your first voyage as a passenger, did you yourself feel such a mystical vibration, when first told that you and your ship were now out of sight of land? Why did the old Persians hold the sea holy? Why did the Greeks give it a separate deity, and own brother of Jove? Surely all this is not without meaning. And still deeper the meaning of that story of Narcissus, who because he could not grasp the tormenting, mild image he saw in the fountain, plunged into it and was drowned. But that same image, we ourselves see in all rivers and oceans. It is the image of the ungraspable phantom of life; and this is the key to it all.</span></p>
+<p><span class="audio" id="c001p0007">Now, when I say that I am in the habit of going to sea whenever I begin to grow hazy about the eyes, and begin to be over conscious of my lungs, I do not mean to have it inferred that I ever go to sea as a passenger. For to go as a passenger you must needs have a purse, and a purse is but a rag unless you have something in it. Besides, passengers get sea-sick—grow quarrelsome—don’t sleep of nights—do not enjoy themselves much, as a general thing;—no, I never go as a passenger; nor, though I am something of a salt, do I ever go to sea as a Commodore, or a Captain, or a Cook. I abandon the glory and distinction of such offices to those who like them. For my part, I abominate all honourable respectable toils, trials, and tribulations of every kind whatsoever. It is quite as much as I can do to take care of myself, without taking care of ships, barques, brigs, schooners, and what not. And as for going as cook,—though I confess there is considerable glory in that, a cook being a sort of officer on ship-board—yet, somehow, I never fancied broiling fowls;—though once broiled, judiciously buttered, and judgmatically salted and peppered, there is no one who will speak more respectfully, not to say reverentially, of a broiled fowl than I will. It is out of the idolatrous dotings of the old Egyptians upon broiled ibis and roasted river horse, that you see the mummies of those creatures in their huge bake-houses the pyramids.</span></p>
+<p><span class="audio" id="c001p0008">No, when I go to sea, I go as a simple sailor, right before the mast, plumb down into the forecastle, aloft there to the royal mast-head. True, they rather order me about some, and make me jump from spar to spar, like a grasshopper in a May meadow. And at first, this sort of thing is unpleasant enough. It touches one’s sense of honour, particularly if you come of an old established family in the land, the Van Rensselaers, or Randolphs, or Hardicanutes. And more than all, if just previous to putting your hand into the tar-pot, you have been lording it as a country schoolmaster, making the tallest boys stand in awe of you. The transition is a keen one, I assure you, from a schoolmaster to a sailor, and requires a strong decoction of Seneca and the Stoics to enable you to grin and bear it. But even this wears off in time.</span></p>
+<p><span class="audio" id="c001p0009">What of it, if some old hunks of a sea-captain orders me to get a broom and sweep down the decks? What does that indignity amount to, weighed, I mean, in the scales of the New Testament? Do you think the archangel Gabriel thinks anything the less of me, because I promptly and respectfully obey that old hunks in that particular instance? Who ain’t a slave? Tell me that. Well, then, however the old sea-captains may order me about—however they may thump and punch me about, I have the satisfaction of knowing that it is all right; that everybody else is one way or other served in much the same way—either in a physical or metaphysical point of view, that is; and so the universal thump is passed round, and all hands should rub each other’s shoulder-blades, and be content.</span></p>
+<p><span class="audio" id="c001p0010">Again, I always go to sea as a sailor, because they make a point of paying me for my trouble, whereas they never pay passengers a single penny that I ever heard of. On the contrary, passengers themselves must pay. And there is all the difference in the world between paying and being paid. The act of paying is perhaps the most uncomfortable infliction that the two orchard thieves entailed upon us. But BEING PAID,—what will compare with it? The urbane activity with which a man receives money is really marvellous, considering that we so earnestly believe money to be the root of all earthly ills, and that on no account can a monied man enter heaven. Ah! how cheerfully we consign ourselves to perdition!</span></p>
+<p><span class="audio" id="c001p0011">Finally, I always go to sea as a sailor, because of the wholesome exercise and pure air of the fore-castle deck. For as in this world, head winds are far more prevalent than winds from astern (that is, if you never violate the Pythagorean maxim), so for the most part the Commodore on the quarter-deck gets his atmosphere at second hand from the sailors on the forecastle. He thinks he breathes it first; but not so. In much the same way do the commonalty lead their leaders in many other things, at the same time that the leaders little suspect it. But wherefore it was that after having repeatedly smelt the sea as a merchant sailor, I should now take it into my head to go on a whaling voyage; this the invisible police officer of the Fates, who has the constant surveillance of me, and secretly dogs me, and influences me in some unaccountable way—he can better answer than any one else. And, doubtless, my going on this whaling voyage, formed part of the grand programme of Providence that was drawn up a long time ago. It came in as a sort of brief interlude and solo between more extensive performances. I take it that this part of the bill must have run something like this:</span></p>
+
+<div class="block-rw extract-rw headline-rw">
+<p><span class="audio" id="c001p0012">“GRAND CONTESTED ELECTION FOR THE PRESIDENCY OF THE UNITED STATES.</span></p>
+<p><span class="audio" id="c001p0013">“WHALING VOYAGE BY ONE ISHMAEL.</span></p>
+<p><span class="audio" id="c001p0014">“BLOODY BATTLE IN AFFGHANISTAN.”</span></p></div>
+<p><span class="audio" id="c001p0015">Though I cannot tell why it was exactly that those stage managers, the Fates, put me down for this shabby part of a whaling voyage, when others were set down for magnificent parts in high tragedies, and short and easy parts in genteel comedies, and jolly parts in farces—though I cannot tell why this was exactly; yet, now that I recall all the circumstances, I think I can see a little into the springs and motives which being cunningly presented to me under various disguises, induced me to set about performing the part I did, besides cajoling me into the delusion that it was a choice resulting from my own unbiased freewill and discriminating judgment.</span></p>
+<p><span class="audio" id="c001p0016">Chief among these motives was the overwhelming idea of the great whale himself. Such a portentous and mysterious monster roused all my curiosity. Then the wild and distant seas where he rolled his island bulk; the undeliverable, nameless perils of the whale; these, with all the attending marvels of a thousand Patagonian sights and sounds, helped to sway me to my wish. With other men, perhaps, such things would not have been inducements; but as for me, I am tormented with an everlasting itch for things remote. I love to sail forbidden seas, and land on barbarous coasts. Not ignoring what is good, I am quick to perceive a horror, and could still be social with it—would they let me—since it is but well to be on friendly terms with all the inmates of the place one lodges in.</span></p>
+<p><span class="audio" id="c001p0017">By reason of these things, then, the whaling voyage was welcome; the great flood-gates of the wonder-world swung open, and in the wild conceits that swayed me to my purpose, two and two there floated into my inmost soul, endless processions of the whale, and, mid most of them all, one grand hooded phantom, like a snow hill in the air.</span></p>
+</section></body></html>
diff --git a/lib/epub.js/test/fixtures/highlight.xhtml b/lib/epub.js/test/fixtures/highlight.xhtml
new file mode 100644
index 0000000..9fdc98c
--- /dev/null
+++ b/lib/epub.js/test/fixtures/highlight.xhtml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta charset="utf-8"/>
+ <title>Highlight Test</title>
+ </head>
+ <body>
+ <p id="p1">Alice was beginning to get very tired of sitting by her
+ sister on the bank, and of having nothing to do. Once or twice she had peeped into the
+ book her sister was reading, but it had no pictures or conversations in it, "and what
+ is the use of a book," thought Alice, "without pictures or conversations?"</p>
+
+ <p id="p2"><span class="annotator-hl" id="a1">So she was considering in her own mind (as well as she could, for the day made her
+ feel very sleepy and stupid)</span>, whether the <span class="annotator-hl" id="a2">pleasure of making a daisy-chain</span> would be
+ worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit
+ with pink eyes ran close by her.</p>
+
+ <p id="p3">There was nothing so very remarkable in that, nor did Alice think it so
+ <a id="Page_4" class="pageno" title="[Pg 4]"></a>very much out of the way to hear the Rabbit
+ say to itself, "Oh dear! Oh dear! I shall be too late!" But when the Rabbit actually
+ took a watch out of its waistcoat-pocket and looked at it and then hurried on, Alice
+ started to her feet, for it flashed across her mind that she had never before seen a
+ rabbit with either a waistcoat-pocket, or a watch to take out of it, and, burning with
+ curiosity, she ran across the field after it and was just in time to see it pop down a
+ large rabbit-hole, under the hedge. In another moment, down went Alice after it!</p>
+ </body>
+</html>
diff --git a/lib/epub.js/test/fixtures/locations.xhtml b/lib/epub.js/test/fixtures/locations.xhtml
new file mode 100644
index 0000000..7f97adf
--- /dev/null
+++ b/lib/epub.js/test/fixtures/locations.xhtml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
+<head>
+<title>
+Moby-Dick</title>
+<link rel="stylesheet" href="css/stylesheet.css" type="text/css"></link>
+<meta charset="utf-8"/>
+</head>
+<body>
+<section class="body-rw Chapter-rw" epub:type="bodymatter chapter">
+<header>
+<!-- 20 -->
+<h1>Chapter 1. Loomings.</h1>
+</header>
+
+<!-- 1107 -->
+<p>Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.
+It is a way I have of driving off the spleen and regulating the circulation.
+Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can.
+This is my substitute for pistol and ball.
+With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship.
+There is nothing surprising in this.
+If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.</p>
+
+<!-- 387 -->
+<p>There now is your insular city of the Manhattoes, belted round by wharves as Indian isles by coral reefs—commerce surrounds it with her surf. Right and left, the streets take you waterward. Its extreme downtown is the battery, where that noble mole is washed by waves, and cooled by breezes, which a few hours previous were out of sight of land. Look at the crowds of water-gazers there.</p>
+
+</section></body></html>
diff --git a/lib/epub.js/test/index.html b/lib/epub.js/test/index.html
new file mode 100644
index 0000000..b2a5495
--- /dev/null
+++ b/lib/epub.js/test/index.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Mocha</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" href="./node_modules/mocha/mocha.css" />
+ <script src="/test/test.build.js"></script>
+ </head>
+ <body>
+ </body>
+</html>
diff --git a/lib/epub.js/test/locations.js b/lib/epub.js/test/locations.js
new file mode 100644
index 0000000..64288eb
--- /dev/null
+++ b/lib/epub.js/test/locations.js
@@ -0,0 +1,31 @@
+import assert from 'assert';
+import Locations from '../src/locations';
+import * as core from '../src/utils/core';
+
+describe('Locations', function() {
+
+ describe('#parse', function() {
+ var chapter = require('./fixtures/locations.xhtml').default;
+
+ it('parse locations from a document', function() {
+ var doc = core.parse(chapter, "application/xhtml+xml");
+ var contents = doc.documentElement;
+ var locations = new Locations();
+ var result = locations.parse(contents, "/6/4[chap01ref]", 100);
+ assert.equal(result.length, 15);
+
+ });
+
+ it('parse locations from xmldom', function() {
+ var doc = core.parse(chapter, "application/xhtml+xml", true);
+ var contents = doc.documentElement;
+
+ var locations = new Locations();
+ var result = locations.parse(contents, "/6/4[chap01ref]", 100);
+ assert.equal(result.length, 15);
+
+ });
+
+ });
+
+});
diff --git a/lib/epub.js/test/old/epub.js b/lib/epub.js/test/old/epub.js
new file mode 100644
index 0000000..8723114
--- /dev/null
+++ b/lib/epub.js/test/old/epub.js
@@ -0,0 +1,371 @@
+var domain = window.location.origin;
+
+module('Core');
+
+test("EPUBJS.core.resolveUrl", 1, function() {
+ var a = "http://example.com/fred/chasen/";
+ var b = "/chasen/derf.html";
+
+ var resolved = EPUBJS.core.resolveUrl(a, b);
+
+ equal( resolved, "http://example.com/fred/chasen/derf.html", "resolved" );
+
+});
+
+test("EPUBJS.core.resolveUrl ../", 1, function() {
+ var a = "http://example.com/fred/chasen/";
+ var b = "../derf.html";
+
+ var resolved = EPUBJS.core.resolveUrl(a, b);
+
+ equal( resolved, "http://example.com/fred/derf.html", "resolved" );
+});
+
+
+test("EPUBJS.core.resolveUrl folders", 1, function() {
+ var a = "/fred/chasen/";
+ var b = "/fred/chasen/derf.html";
+
+ var resolved = EPUBJS.core.resolveUrl(a, b);
+
+ equal( resolved, "/fred/chasen/derf.html", "resolved" );
+});
+
+test("EPUBJS.core.resolveUrl ../folders", 1, function() {
+ var a = "/fred/chasen/";
+ var b = "../../derf.html";
+
+ var resolved = EPUBJS.core.resolveUrl(a, b);
+
+ equal( resolved, "/derf.html", "resolved" );
+});
+
+module('Create');
+
+asyncTest("Create new ePub(/path/to/epub/)", 1, function() {
+
+ var book = ePub("../books/moby-dick/");
+ book.opened.then(function(){
+ equal( book.url, "../books/moby-dick/OPS/", "book url is passed to new EPUBJS.Book" );
+ start();
+ });
+
+});
+
+asyncTest("Create new ePub(/path/to/epub/package.opf)", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ equal( book.url, domain + "/books/moby-dick/OPS/", "bookPath is passed to new EPUBJS.Book" );
+ start();
+ });
+
+});
+
+asyncTest("Open using ePub(/path/to/epub/package.opf)", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ equal( book.packageUrl, "../books/moby-dick/OPS/package.opf", "packageUrl is set" );
+ start();
+ });
+
+});
+
+asyncTest("Open Remote ePub", 1, function() {
+
+ var book = ePub("https://s3.amazonaws.com/moby-dick/");
+ book.opened.then(function(){
+ equal( book.packageUrl, "https://s3.amazonaws.com/moby-dick/OPS/package.opf", "packageUrl is set" );
+ start();
+ });
+
+});
+
+asyncTest("Open Remote ePub from Package", 1, function() {
+
+ var book = ePub("https://s3.amazonaws.com/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ equal( book.packageUrl, "https://s3.amazonaws.com/moby-dick/OPS/package.opf", "packageUrl is set" );
+ start();
+ });
+
+});
+
+asyncTest("Find Epub Package", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ equal( book.packageUrl, "../books/moby-dick/OPS/package.opf", "packageUrl is set" );
+ start();
+ });
+
+});
+
+module('Parse');
+
+//TODO: add mocked tests for parser
+
+asyncTest("Manifest", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ equal( Object.keys(book.package.manifest).length, 152, "Manifest is parsed" );
+ start();
+ });
+
+});
+
+asyncTest("Metadata", 3, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ equal( book.package.metadata.creator, "Herman Melville", "Creator metadata is parsed" );
+ equal( book.package.metadata.title, "Moby-Dick", "Title metadata is parsed" );
+ equal( book.package.metadata.identifier, "code.google.com.epub-samples.moby-dick-basic", "Identifier metadata is parsed" );
+ start();
+ });
+
+});
+
+asyncTest("Spine", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ equal( book.package.spine.length, 144, "Spine is parsed" );
+ start();
+ });
+
+});
+
+asyncTest("Cover", 1, function() {
+
+ var book = ePub("../books/moby-dick/");
+ book.opened.then(function(){
+ equal( book.cover, "../books/moby-dick/OPS/images/9780316000000.jpg", "Cover is set" );
+ start();
+ });
+
+});
+
+module('Spine');
+
+asyncTest("Length", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ equal( book.spine.length, 144, "All spine items present" );
+ start();
+ });
+
+});
+
+asyncTest("Items", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ equal( book.spine.spineItems.length, 144, "All spine items added" );
+ start();
+ });
+
+});
+
+asyncTest("First Item", 2, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ var section = book.spine.get(0);
+ equal( section.href, "cover.xhtml", "First spine item href found" );
+ equal( section.cfiBase, "/6/2[cover]", "First spine item cfi found" );
+
+ start();
+ });
+
+});
+
+asyncTest("Find Item by Href", 2, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ var section = book.spine.get("chapter_001.xhtml");
+ equal( section.href, "chapter_001.xhtml", "chap 1 spine item href found" );
+ equal( section.cfiBase, "/6/14[xchapter_001]", "chap 1 spine item cfi found" );
+
+ start();
+ });
+
+});
+
+asyncTest("Find Item by ID", 2, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ var section = book.spine.get("#xchapter_050");
+ equal( section.href, "chapter_050.xhtml", "chap 50 spine item href found" );
+ equal( section.cfiBase, "/6/112[xchapter_050]", "chap 50 spine item cfi found" );
+
+ start();
+ });
+
+});
+
+asyncTest("Render Spine Item", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ var section = book.spine.get("#xchapter_050");
+ section.render().then(function(content){
+ equal( content.substring(377, 429), "<h1>Chapter 50. Ahab’s Boat and Crew. Fedallah.</h1>", "Chapter text rendered as string" );
+ });
+
+ start();
+ });
+
+});
+
+module('Navigation');
+
+asyncTest("NCX & Nav", 2, function() {
+
+ var book = ePub("../books/moby-dick/");
+ book.opened.then(function(){
+ equal( book.navigation.navUrl, "../books/moby-dick/OPS/toc.xhtml", "Nav URL found" );
+ equal( book.navigation.ncxUrl, "../books/moby-dick/OPS/toc.ncx", "NCX URL found" );
+
+ start();
+ });
+
+});
+
+
+asyncTest("Load TOC Auto Pick", 1, function() {
+
+ var book = ePub("../books/moby-dick/");
+ book.opened.then(function(){
+ book.navigation.load().then(function(toc){
+ equal( toc.length, 141, "Full Nav toc parsed" );
+ start();
+ });
+ });
+
+});
+
+asyncTest("Load TOC from Nav", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ var nav = book.navigation.nav.load();
+ nav.then(function(toc){
+ equal( toc.length, 141, "Full Nav toc parsed" );
+ start();
+ });
+ });
+
+});
+
+asyncTest("Load TOC from NCX", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.opened.then(function(){
+ var ncx = book.navigation.ncx.load();
+ ncx.then(function(toc){
+ equal( toc.length, 14, "Full NCX toc parsed" );
+ start();
+ });
+ });
+
+});
+
+asyncTest("Get all TOC", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.loaded.navigation.then(function(){
+ equal( book.navigation.get().length, 141, "Full Nav toc parsed" );
+ start();
+ });
+
+});
+
+asyncTest("Get TOC item by href", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.loaded.navigation.then(function(){
+ var item = book.navigation.get("chapter_001.xhtml");
+ equal( item.id, "toc-chapter_001", "Found TOC item" );
+ start();
+ });
+
+});
+
+asyncTest("Get TOC item by ID", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ book.loaded.navigation.then(function(){
+ var item = book.navigation.get("#toc-chapter_001");
+ equal( item.href, "chapter_001.xhtml", "Found TOC item" );
+ start();
+ });
+
+});
+
+module('Hooks');
+
+asyncTest("Register a new hook", 1, function() {
+
+ var beforeDisplay = new EPUBJS.Hook();
+ beforeDisplay.register(function(args){
+ var defer = new RSVP.defer();
+ console.log("ran", 1);
+ defer.resolve();
+ return defer.promise;
+ });
+ equal( beforeDisplay.hooks.length, 1, "Registered a hook" );
+ start();
+
+// this.beforeDisplay.trigger(args).then(function(){});
+
+});
+
+asyncTest("Trigger all new hook", 4, function() {
+
+ var beforeDisplay = new EPUBJS.Hook(this);
+ this.testerObject = {tester: 1};
+
+ beforeDisplay.register(function(testerObject){
+ var defer = new RSVP.defer();
+
+ start();
+ equal( testerObject.tester, 1, "tester is 1" );
+ stop();
+
+ testerObject.tester += 1;
+
+ defer.resolve();
+ return defer.promise;
+ });
+
+ beforeDisplay.register(function(testerObject){
+ var defer = new RSVP.defer();
+
+ start();
+ equal(testerObject.tester, 2, "tester is 2" );
+ stop();
+
+ testerObject.tester += 1;
+
+ defer.resolve();
+ return defer.promise;
+ });
+
+ start();
+ equal( beforeDisplay.hooks.length, 2, "Added two hooks" );
+ stop();
+
+ beforeDisplay.trigger(this.testerObject).then(function(){
+
+ start();
+ equal( this.testerObject.tester, 3, "tester is 3" );
+
+ }.bind(this));
+
+});
diff --git a/lib/epub.js/test/old/rendering.js b/lib/epub.js/test/old/rendering.js
new file mode 100644
index 0000000..5cf1357
--- /dev/null
+++ b/lib/epub.js/test/old/rendering.js
@@ -0,0 +1,16 @@
+module('Rendering');
+/*
+asyncTest("Render To", 1, function() {
+
+ var book = ePub("../books/moby-dick/OPS/package.opf");
+ var rendition = book.renderTo("qunit-fixture", {width:400, height:600});
+ var displayed = rendition.display(0);
+
+ displayed.then(function(){
+ equal( $( "iframe", "#qunit-fixture" ).length, 1, "iframe added successfully" );
+ start();
+ });
+
+
+});
+*/
diff --git a/lib/epub.js/test/section.js b/lib/epub.js/test/section.js
new file mode 100644
index 0000000..5a2902e
--- /dev/null
+++ b/lib/epub.js/test/section.js
@@ -0,0 +1,77 @@
+import assert from 'assert';
+import ePub from '../src/epub';
+
+describe("section", function() {
+ it("finds a single result in a section", function() {
+ var book = ePub("./fixtures/alice/", {width: 400, height: 400});
+ return book.ready.then(function() {
+ var section = book.section("chapter_001.xhtml");
+ return section.load().then(function() {
+ const queryString = "they were filled with cupboards and book-shelves";
+ const findResults = section.find(queryString);
+ const searchResults = section.search(queryString);
+ [findResults , searchResults].forEach( (results)=>{
+ assert.equal(results.length, 1);
+ assert.equal(results[0].cfi, "epubcfi(/6/8[chapter_001]!/4/2/16,/1:275,/1:323)");
+ assert.equal(results[0].excerpt, "... see anything; then she looked at the sides of the well and\n\t\tnoticed that they were filled with cupboards and book-shelves; here and there she saw\n\t\t...");
+ });
+ });
+ });
+ });
+
+ it("finds multiple results in a section", function() {
+ var book = ePub("./fixtures/alice/", {width: 400, height: 400});
+ return book.ready.then(function() {
+ var section = book.section("chapter_001.xhtml");
+ return section.load().then(function() {
+ const queryString = "white rabbit";
+ const findResults = section.find(queryString);
+ const searchResults = section.search(queryString);
+ [findResults , searchResults].forEach( (results)=>{
+ assert.equal(results.length, 2);
+ assert.equal(results[0].cfi, "epubcfi(/6/8[chapter_001]!/4/2/8,/1:240,/1:252)");
+ assert.equal(results[0].excerpt, "...e worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her....");
+ assert.equal(results[1].cfi, "epubcfi(/6/8[chapter_001]!/4/2/20,/1:148,/1:160)");
+ assert.equal(results[1].excerpt, "...ut it was\n\t\tall dark overhead; before her was another long passage and the White Rabbit was still\n\t\tin sight, hurrying down it. There was not a moment...");
+ });
+ });
+ });
+
+ });
+
+ it("finds result that spanning multiple document nodes, tag at ending", function() {
+ var book = ePub("./fixtures/alice/", {width: 400, height: 400});
+ return book.ready.then(function() {
+ var section = book.section("chapter_010.xhtml");
+ return section.load().then(function() {
+ const queryString = "I beg";
+
+ const findResult = section.find(queryString);
+ assert.equal(findResult.length, 0);
+
+ const searchResults = section.search(queryString);
+ assert.equal(searchResults.length, 1);
+ assert.equal(searchResults[0].cfi, "epubcfi(/6/26[chapter_010]!/4/2/6,/1:5,/2/1:3)");
+ assert.equal(searchResults[0].excerpt,'"Oh, I beg');
+ });
+ });
+ });
+
+ it("finds result that spanning multiple document nodes, tag at middle", function() {
+ var book = ePub("./fixtures/alice/", {width: 400, height: 400});
+ return book.ready.then(function() {
+ var section = book.section("chapter_010.xhtml");
+ return section.load().then(function() {
+ const queryString = "I beg your pardon";
+
+ const findResult = section.find(queryString);
+ assert.equal(findResult.length, 0);
+
+ const searchResults = section.search(queryString);
+ assert.equal(searchResults.length, 1);
+ assert.equal(searchResults[0].cfi, "epubcfi(/6/26[chapter_010]!/4/2/6,/1:5,/3:12)");
+ assert.equal(searchResults[0].excerpt,'"Oh, I beg your pardon!" she exclaimed in a tone of great dismay.');
+ });
+ });
+ });
+});