Skip to content

Commit 72e5bd5

Browse files
committed
fix(rules): properly detect page markers using epub:type="pagebreak"
Closes #85
1 parent 329dad9 commit 72e5bd5

File tree

8 files changed

+66
-2
lines changed

8 files changed

+66
-2
lines changed

src/scripts/ace-extraction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,5 +242,5 @@ ace.hasMathML = function() {
242242
}
243243

244244
ace.hasPageBreaks = function() {
245-
return document.querySelectorAll('[epub\\:type~="pagebreak"], [role~="doc-pagebreak"]').length > 0;
245+
return document.querySelectorAll('[*|type~="pagebreak"], [role~="doc-pagebreak"]').length > 0;
246246
}

src/scripts/ace-extraction.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ describe('finding pagebreaks', () => {
321321
expect(results).toBe(false);
322322
});
323323

324-
test.skip('epub:type break', async () => {
324+
test('epub:type break', async () => {
325325
const results = await run('hasPageBreaks', '<span epub:type="pagebreak" />');
326326
expect(results).toBe(true);
327327
});

tests/__tests__/regression.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ test('issue #57: Failed to execute \'matches\' on \'Element\': \'m:annotation-xm
5050
const report = await ace('../data/issue-57');
5151
expect(report['earl:result']['earl:outcome']).toEqual('pass');
5252
});
53+
54+
test('issue #85: failed to detect page markers from `epub:type`', async () => {
55+
const report = await ace('../data/issue-85');
56+
expect(report['earl:result']['earl:outcome']).toEqual('pass');
57+
expect(report.properties.hasPageBreaks).toBe(true);
58+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
2+
<head>
3+
<title>Minimal EPUB</title>
4+
</head>
5+
<body>
6+
<h1>Loomings</h1>
7+
<p>Call me Ishmael.</p>
8+
<span id="p1" epub:type="pagebreak" aria-label="page 1"/>
9+
</body>
10+
</html>

tests/data/issue-85/EPUB/nav.xhtml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
2+
<head>
3+
<title>Minimal Nav</title>
4+
</head>
5+
<body>
6+
<nav epub:type="toc">
7+
<ol>
8+
<li><a href="content_001.xhtml">content 001</a></li>
9+
</ol>
10+
</nav>
11+
<nav epub:type="page-list">
12+
<ol>
13+
<li><a href="content_001.xhtml#p1">page 1</a></li>
14+
</ol>
15+
</nav>
16+
</body>
17+
</html>

tests/data/issue-85/EPUB/package.opf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="uid">
3+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
4+
<dc:title id="title">Minimal EPUB 3.0</dc:title>
5+
<dc:language>en</dc:language>
6+
<dc:identifier id="uid">NOID</dc:identifier>
7+
<dc:source>https://example.com</dc:source>
8+
<meta property="dcterms:modified">2017-01-01T00:00:01Z</meta>
9+
<meta property="schema:accessibilityFeature">structuralNavigation</meta>
10+
<meta property="schema:accessibilitySummary">everything OK!</meta>
11+
<meta property="schema:accessibilityHazard">noFlashingHazard</meta>
12+
<meta property="schema:accessibilityHazard">noSoundHazard</meta>
13+
<meta property="schema:accessibilityHazard">noMotionSimulationHazard</meta>
14+
<meta property="schema:accessMode">textual</meta>
15+
<meta property="schema:accessModeSufficient">textual</meta>
16+
</metadata>
17+
<manifest>
18+
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
19+
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
20+
</manifest>
21+
<spine>
22+
<itemref idref="content_001" />
23+
</spine>
24+
</package>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
3+
<rootfiles>
4+
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
5+
</rootfiles>
6+
</container>

tests/data/issue-85/mimetype

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
application/epub+zip

0 commit comments

Comments
 (0)