Skip to content

Commit

Permalink
feat: warn about doc-endnote or doc-biblioentry on list items
Browse files Browse the repository at this point in the history
The roles `doc-endnote` and `doc-biblioentry` are deprecated in ARIA 1.1, and authors should not use them on list items.

The HTML validator (validator.nu) raises an error when these roles are set on `li` elements.

This commit implements a more permissive approach for EPUBCheck:
- the roles are re-added the HTML schema
- we raise a warning (RSC-017) when the roles are present on `li` elements
  • Loading branch information
rdeltour committed Jul 7, 2023
1 parent 2f6a2c7 commit 5c39157
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,5 +396,14 @@
select="local-name(ancestor::$ancestor)"/> elements.</report>
</rule>
</pattern>

<pattern id="dpub-aria.doc-endnote.deprecated">
<rule context="h:*[@role]">
<report test="tokenize(@role,'\s+')='doc-endnote'"
>WARNING: The "doc-endnote" role is deprecated and should not be used.</report>
<report test="tokenize(@role,'\s+')='doc-biblioentry'"
>WARNING: The "doc-biblioentry" role is deprecated and should not be used.</report>
</rule>
</pattern>

</schema>
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
| common.attrs.aria.role.treeitem
| common.attrs.aria.role.separator
| common.attrs.aria.role.presentation
| common.attrs.aria.role.doc-biblioentry
| common.attrs.aria.role.doc-endnote
)?
)
li.inner =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,14 @@ Feature: EPUB 3 — Content Documents — XHTML
When checking document 'aria-roles-img-valid.xhtml'
Then no errors or warnings are reported

Scenario: Verify the DPUB-ARIA roles allowed on `li`
When checking document 'aria-roles-li-valid.xhtml'
Then no errors or warnings are reported
Scenario: Report deprecated DPUB-ARIA roles on `li`
When checking document 'aria-roles-li-deprecated-warning.xhtml'
Then following warnings are reported:
| RSC-017 | "doc-endnote" role is deprecated |
| RSC-017 | "doc-endnote" role is deprecated |
| RSC-017 | "doc-biblioentry" role is deprecated |
| RSC-017 | "doc-biblioentry" role is deprecated |
Then no other errors or warnings are reported

Scenario: Verify the DPUB-ARIA roles allowed on `nav`
When checking document 'aria-roles-nav-valid.xhtml'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@
<ol>
<li role="doc-endnote"></li>
</ol>
<div role="list">
<div role="doc-endnote">1.</div>
</div>
</section>
<section role="doc-bibliography">
<h2>Bibliography</h2>
<ul>
<li role="doc-biblioentry"></li>
</ul>
<div role="list">
<div role="doc-biblioentry">1.</div>
</div>
</section>
</body>
</html>

0 comments on commit 5c39157

Please sign in to comment.