GeezerVison is showing github.com — feat: check that non-linear content is reachable · w3c/epubcheck@f20993e
File treeExpand file treeCollapse file tree Open diff view settings resources/com/adobe/epubcheck/messages
files/epub/edupub-non-linear-valid/EPUB
epub-region-nav/files/epub/data-nav-in-spine-warning/EPUB spine-nonlinear-not-reachable-error spine-nonlinear-reachable-via-hyperlink-valid spine-nonlinear-reachable-via-nav-valid spine-nonlinear-reachable-via-script-valid spine-not-listing-hyperlink-target-error spine-not-listing-navigation-document-target-error
content-fxl-svg-no-viewbox-error/EPUB content-fxl-svg-no-viewbox-on-inner-svg-valid/EPUB content-fxl-svg-no-viewbox-width-height-percent-error/EPUB content-fxl-svg-no-viewbox-width-height-units-error/EPUB content-fxl-svg-valid/EPUB
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -289,6 +289,8 @@ private void initialize() | 289 | 289 | severities.put(MessageId.OPF_093, Severity.ERROR); | 290 | 290 | severities.put(MessageId.OPF_094, Severity.ERROR); | 291 | 291 | severities.put(MessageId.OPF_095, Severity.ERROR); | | 292 | + severities.put(MessageId.OPF_096, Severity.ERROR); | | 293 | + severities.put(MessageId.OPF_096b, Severity.USAGE); | 292 | 294 |
| 293 | 295 | // PKG | 294 | 296 | severities.put(MessageId.PKG_001, Severity.WARNING); | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/messages/MessageId.java +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -283,6 +283,8 @@ public enum MessageId implements Comparable<MessageId> | 283 | 283 | OPF_093("OPF-093"), | 284 | 284 | OPF_094("OPF-094"), | 285 | 285 | OPF_095("OPF-095"), | | 286 | + OPF_096("OPF-096"), | | 287 | + OPF_096b("OPF-096b"), | 286 | 288 |
| 287 | 289 | // Messages relating to the entire package | 288 | 290 | PKG_001("PKG-001"), | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java +24-3Lines changed: 24 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 24 | 24 |
| 25 | 25 | import java.util.Set; | 26 | 26 |
| | 27 | +import org.w3c.epubcheck.core.references.Reference; | 27 | 28 | import org.w3c.epubcheck.util.url.URLFragment; | 28 | 29 |
| 29 | 30 | import com.adobe.epubcheck.api.EPUBLocation; | @@ -183,6 +184,26 @@ else if (!overlayTextChecker.isCorrectOverlay(docURL, mo)) | 183 | 184 | } | 184 | 185 | } | 185 | 186 | } | | 187 | + | | 188 | + // check that non-linear content documents are reachable | | 189 | + if (item.isInSpine() && !item.isLinear() && context.referenceRegistry.isPresent() | | 190 | + // search the reference registry for any hyperlink pointing to this item | | 191 | + && !context.referenceRegistry.get().asList().stream() | | 192 | + .anyMatch(ref -> ref.type == Reference.Type.HYPERLINK | | 193 | + && ref.targetResource.equals(item.getURL()))) | | 194 | + { | | 195 | + // if content is scripted, references can be added by scripting | | 196 | + // se we only report a usage | | 197 | + if (context.featureReport.hasFeature(FeatureEnum.HAS_SCRIPTS)) | | 198 | + { | | 199 | + report.message(MessageId.OPF_096b, item.getLocation(), item.getPath()); | | 200 | + } | | 201 | + // else, report an error if no hyperlink were found | | 202 | + else | | 203 | + { | | 204 | + report.message(MessageId.OPF_096, item.getLocation(), item.getPath()); | | 205 | + } | | 206 | + } | 186 | 207 | } | 187 | 208 |
| 188 | 209 | @Override | @@ -194,14 +215,15 @@ protected void checkSpineItem(OPFItem item, OPFHandler opfHandler) | 194 | 215 | return; | 195 | 216 | } | 196 | 217 |
| 197 | | - String mimeType = item.getMimeType(); | 198 | | - | | 218 | + // check properties | 199 | 219 | if (item.getProperties() | 200 | 220 | .contains(PackageVocabs.ITEM_VOCAB.get(PackageVocabs.ITEM_PROPERTIES.DATA_NAV))) | 201 | 221 | { | 202 | 222 | report.message(MessageId.OPF_077, item.getLocation()); | 203 | 223 | } | 204 | 224 |
| | 225 | + // check that spine items have content document fallback | | 226 | + String mimeType = item.getMimeType(); | 205 | 227 | if (!isBlessedItemType(mimeType, version)) | 206 | 228 | { | 207 | 229 | if (!item.hasFallback()) | @@ -213,7 +235,6 @@ else if (!item.hasContentDocumentFallback()) | 213 | 235 | report.message(MessageId.OPF_044, item.getLocation(), mimeType); | 214 | 236 | } | 215 | 237 | } | 216 | | - | 217 | 238 | } | 218 | 239 |
| 219 | 240 | private void checkCollections() | |
Collapse file Copy file name to clipboardExpand all lines: src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -210,7 +210,9 @@ OPF_091=The item href URL must not have a fragment identifier. | 210 | 210 | OPF_092=Language tag "%1$s" is not well-formed: %2$s | 211 | 211 | OPF_093=The "media-type" attribute is required for linked resources located in the EPUB container | 212 | 212 | OPF_094=The "media-type" attribute is required for "%1$s" links. | 213 | | -OPF_095=The "media-type" attribute of "voicing" links must be an audio MIME type, but found "%1$s". | | 213 | +OPF_095=The "media-type" attribute of "voicing" links must be an audio MIME type, but found "%1$s". | | 214 | +OPF_096=Non-linear content must be reachable, but found no hyperlink to "%1$s". | | 215 | +OPF_096b=No hyperlink was found to non-linear document "%1$s", please check that it can be reached from scripted content. | 214 | 216 |
| 215 | 217 | #Package | 216 | 218 | PKG_001=Validating the EPUB against version %1$s but detected version %2$s. | |
Collapse file Copy file name to clipboardExpand all lines: src/test/resources/epub-edupub/edupub-publication.feature +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,7 +51,7 @@ Feature: EPUB for Education ▸ Full Publication Checks | 51 | 51 |
| 52 | 52 | ## 4.2 Sectioning | 53 | 53 |
| 54 | | - Scenario: Verify an non-linear content does not have to follow the sectioning rules | | 54 | + Scenario: Verify that non-linear content does not have to follow the sectioning rules | 55 | 55 | When checking EPUB 'edupub-non-linear-valid' | 56 | 56 | Then no errors or warnings are reported | 57 | 57 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/test/resources/epub-edupub/files/epub/edupub-non-linear-valid/EPUB/nav.xhtml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | <nav epub:type="toc"> | 9 | 9 | <ol> | 10 | 10 | <li><a href="content_001.xhtml">content 001</a></li> | | 11 | + <li><a href="nonlinear.xhtml">non-linear</a></li> | 11 | 12 | </ol> | 12 | 13 | </nav> | 13 | 14 | </body> | |
Collapse file Copy file name to clipboardExpand all lines: src/test/resources/epub-edupub/files/epub/edupub-non-linear-valid/EPUB/package.opf +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 11 | 11 | <manifest> | 12 | 12 | <item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/> | 13 | 13 | <item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/> | 14 | | - <item id="non" href="nonlinear.xhtml" media-type="application/xhtml+xml" /> | | 14 | + <item id="nonlinear" href="nonlinear.xhtml" media-type="application/xhtml+xml" /> | 15 | 15 | </manifest> | 16 | 16 | <spine> | 17 | 17 | <itemref idref="content_001" /> | 18 | | - <itemref idref="non" linear="no" /> | | 18 | + <itemref idref="nonlinear" linear="no" /> | 19 | 19 | </spine> | 20 | 20 | </package> |
Collapse file Copy file name to clipboardExpand all lines: src/test/resources/epub-region-nav/files/epub/data-nav-in-spine-warning/EPUB/nav.xhtml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | <nav epub:type="toc"> | 9 | 9 | <ol> | 10 | 10 | <li><a href="content_001.xhtml">content 001</a></li> | | 11 | + <li><a href="data-nav.xhtml">data nav</a></li> | 11 | 12 | </ol> | 12 | 13 | </nav> | 13 | 14 | </body> | |
Collapse file Copy file name to clipboard +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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="q"> | | 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="q">NOID</dc:identifier> | | 7 | + <meta property="dcterms:modified">2017-06-14T00:00:01Z</meta> | | 8 | +</metadata> | | 9 | +<manifest> | | 10 | + <item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/> | | 11 | + <item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/> | | 12 | +</manifest> | | 13 | +<spine> | | 14 | +<!-- <itemref idref="content_001" />--> | | 15 | +</spine> | | 16 | +</package> |
Collapse file Copy file name to clipboard File renamed without changes.
|