Skip to content

Commit

Permalink
fix(rules): properly detect page markers using epub:type="pagebreak"
Browse files Browse the repository at this point in the history
Closes #85
  • Loading branch information
rdeltour committed Oct 28, 2017
1 parent 85bc677 commit aa6ecd5
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/scripts/ace-extraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,5 @@ ace.hasMathML = function() {
}

ace.hasPageBreaks = function() {
return document.querySelectorAll('[epub\\:type~="pagebreak"], [role~="doc-pagebreak"]').length > 0;
return document.querySelectorAll('[*|type~="pagebreak"], [role~="doc-pagebreak"]').length > 0;
}
2 changes: 1 addition & 1 deletion src/scripts/ace-extraction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ describe('finding pagebreaks', () => {
expect(results).toBe(false);
});

test.skip('epub:type break', async () => {
test('epub:type break', async () => {
const results = await run('hasPageBreaks', '<span epub:type="pagebreak" />');
expect(results).toBe(true);
});
Expand Down
6 changes: 6 additions & 0 deletions tests/__tests__/regression.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ test('issue #57: Failed to execute \'matches\' on \'Element\': \'m:annotation-xm
const report = await ace('../data/issue-57');
expect(report['earl:result']['earl:outcome']).toEqual('pass');
});

test('issue #85: failed to detect page markers from `epub:type`', async () => {
const report = await ace('../data/issue-85');
expect(report['earl:result']['earl:outcome']).toEqual('pass');
expect(report.properties.hasPageBreaks).toBe(true);
});
10 changes: 10 additions & 0 deletions tests/data/issue-85/EPUB/content_001.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
<head>
<title>Minimal EPUB</title>
</head>
<body>
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
<span id="p1" epub:type="pagebreak" aria-label="page 1"/>
</body>
</html>
17 changes: 17 additions & 0 deletions tests/data/issue-85/EPUB/nav.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
<head>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
<nav epub:type="page-list">
<ol>
<li><a href="content_001.xhtml#p1">page 1</a></li>
</ol>
</nav>
</body>
</html>
24 changes: 24 additions & 0 deletions tests/data/issue-85/EPUB/package.opf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="uid">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="uid">NOID</dc:identifier>
<dc:source>https://example.com</dc:source>
<meta property="dcterms:modified">2017-01-01T00:00:01Z</meta>
<meta property="schema:accessibilityFeature">structuralNavigation</meta>
<meta property="schema:accessibilitySummary">everything OK!</meta>
<meta property="schema:accessibilityHazard">noFlashingHazard</meta>
<meta property="schema:accessibilityHazard">noSoundHazard</meta>
<meta property="schema:accessibilityHazard">noMotionSimulationHazard</meta>
<meta property="schema:accessMode">textual</meta>
<meta property="schema:accessModeSufficient">textual</meta>
</metadata>
<manifest>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
6 changes: 6 additions & 0 deletions tests/data/issue-85/META-INF/container.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
1 change: 1 addition & 0 deletions tests/data/issue-85/mimetype
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip

0 comments on commit aa6ecd5

Please sign in to comment.