From 15825a5ea265c0854a30af0343cd493c2e1a5cae Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Mon, 24 Jan 2022 10:36:22 +0100 Subject: [PATCH] feat: check that 'page-list' and 'landmarks' nav are flat lists EPUB 3.3 clarifies that authors should not use nested lists for 'page-list' and 'landmarks' nav. This commit: - reports a schema warning for nested 'page-list' or 'landmarks' nav (implemented in schematron) - add tests Fix #1279 --- .../adobe/epubcheck/schema/30/epub-nav-30.sch | 17 ++++++------ .../nav-landmarks-nested-warning.xhtml | 26 +++++++++++++++++++ .../nav-page-list-nested-warning.xhtml | 26 +++++++++++++++++++ .../epub3/navigation-document.feature | 14 ++++++++++ 4 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 src/test/resources/epub3/files/navigation-document/nav-landmarks-nested-warning.xhtml create mode 100644 src/test/resources/epub3/files/navigation-document/nav-page-list-nested-warning.xhtml diff --git a/src/main/resources/com/adobe/epubcheck/schema/30/epub-nav-30.sch b/src/main/resources/com/adobe/epubcheck/schema/30/epub-nav-30.sch index 1c7cdf20f..e9856ee53 100644 --- a/src/main/resources/com/adobe/epubcheck/schema/30/epub-nav-30.sch +++ b/src/main/resources/com/adobe/epubcheck/schema/30/epub-nav-30.sch @@ -24,6 +24,7 @@ + @@ -35,10 +36,11 @@ and only reported within the same ancestor landmarks element --> Another landmark was found with the same epub:type and same reference to "" + ])">Another landmark was found with the same epub:type and same reference to "" @@ -75,12 +77,11 @@ - + diff --git a/src/test/resources/epub3/files/navigation-document/nav-landmarks-nested-warning.xhtml b/src/test/resources/epub3/files/navigation-document/nav-landmarks-nested-warning.xhtml new file mode 100644 index 000000000..8e09430b4 --- /dev/null +++ b/src/test/resources/epub3/files/navigation-document/nav-landmarks-nested-warning.xhtml @@ -0,0 +1,26 @@ + + + + + Minimal Nav + + + + + + diff --git a/src/test/resources/epub3/files/navigation-document/nav-page-list-nested-warning.xhtml b/src/test/resources/epub3/files/navigation-document/nav-page-list-nested-warning.xhtml new file mode 100644 index 000000000..84b235b3c --- /dev/null +++ b/src/test/resources/epub3/files/navigation-document/nav-page-list-nested-warning.xhtml @@ -0,0 +1,26 @@ + + + + + Minimal Nav + + + + + + diff --git a/src/test/resources/epub3/navigation-document.feature b/src/test/resources/epub3/navigation-document.feature index 19fb7e5b4..a8805783f 100644 --- a/src/test/resources/epub3/navigation-document.feature +++ b/src/test/resources/epub3/navigation-document.feature @@ -104,6 +104,13 @@ Feature: EPUB 3 ▸ Navigation Document ▸ Navigation Document Checks And the message contains 'Multiple occurrences of the "page-list" nav element' And no other errors or warnings are reported + Scenario: Report nested `ol` in `page-list` nav + When checking document 'nav-page-list-nested-warning.xhtml' + Then warning RSC-017 is reported + And the message contains "page-list" + And the message contains "no nested sublists" + And no other errors or warnings are reported + #### 5.4.2.4 The landmarks nav Element Scenario: Allow a `landmarks` nav @@ -131,6 +138,13 @@ Feature: EPUB 3 ▸ Navigation Document ▸ Navigation Document Checks Then error RSC-005 is reported 2 times And the message contains 'Another landmark was found with the same epub:type and same reference' And no other errors or warnings are reported + + Scenario: Report nested `ol` in `landmarks` nav + When checking document 'nav-landmarks-nested-warning.xhtml' + Then warning RSC-017 is reported + And the message contains "landmarks" + And the message contains "no nested sublists" + And no other errors or warnings are reported #### 5.4.2.5 Other nav Elements