Skip to content

Conversation

rdeltour
Copy link
Member

disallow remote links in toc/landmarks/page-list nav …

A new message NAV_010 (ERROR) is reported when a toc, landmarks,
or page-list nav contains links to remote resources.

Fix #890

check that toc & page-list nav are in reading order

New Message:

  • NAV_011 (ERROR) is reported when the links in toc and page-list
    nav (in the Navigation Document) do not follow the reading order
    (i.e. spine order + order of IDs in the Content Documents).

Checking logic for NAV_011:

  1. collect the nav links as references in XRefChecker
  2. check the reading order consistency in XRefChecker.checkReferences
    (ran after all documents have been parsed and validated)

Internal changes:

  • In the PathUtil utilities:
    • rename the removeAnchor method to removeFragment
    • add a new getFragment method
  • In the OPFItem class:
    • for spine items, record their position in the spine
    • add a new public getSpinePosition() getter
  • In the XRefChecker class:
    • add a new getResource(path) public method to get an OPFItem
      for a given path.
    • add a new getAnchorPosition(id) method to the internal Resource
      class.
    • some registered references are duplicates of already-registered
      references, with a specific reference type (e.g. a Nav Doc link is
      registered both as a HYPERLINK and as a NAV_TOC_LINK): these
      subtypes are now checked in separate private methods, to keep the
      main checkReference(Reference) method pristine.
    • add a new checkReadingOrder(Queue, int, int) private method which
      processes a queue of references (along with the last known spine
      position and fragment position) and check they are in reading order
  • add new tests for the Navigation Document reading order check
  • fix existing tests

Fix #888

A new message `NAV_010` (`ERROR`) is reported when a `toc`, `landmarks`,
or `page-list` nav contains links to remote resources.

Fix #890
New Message:
- `NAV_011` (`ERROR`) is reported when the links in `toc` and `page-list`
  `nav` (in the Navigation Document) do not follow the reading order
  (i.e. spine order + order of IDs in the Content Documents).

Checking logic for `NAV_011`:
1. collect the nav links as references in `XRefChecker`
2. check the reading order consistency in `XRefChecker.checkReferences`
   (ran after all documents have been parsed and validated)

Internal changes:
- In the `PathUtil` utilities:
  - rename the `removeAnchor` method to `removeFragment`
  - add a new `getFragment` method
- In the `OPFItem` class:
  - for spine items, record their position in the spine
  - add a new public `getSpinePosition()` getter
- In the `XRefChecker` class:
  - add a new `getResource(path)` public method to get an `OPFItem`
    for a given path.
  - add a new `getAnchorPosition(id)` method to the internal `Resource`
    class.
  - some registered references are duplicates of already-registered
    references, with a specific reference type (e.g. a Nav Doc link is
    registered both as a HYPERLINK and as a NAV_TOC_LINK): these
    subtypes are now checked in separate private methods, to keep the
    main `checkReference(Reference)` method pristine.
  - add a new `checkReadingOrder(Queue, int, int)` private method which
    processes a queue of references (along with the last known spine
    position and fragment position) and check they are in reading order
- add new tests for the Navigation Document reading order check
- fix existing tests

Fix #888
@rdeltour rdeltour added the status: needs review Needs to be reviewed by a team member before further processing label Mar 12, 2019
@rdeltour rdeltour added this to the 4.2.0-RC milestone Mar 12, 2019
@rdeltour rdeltour self-assigned this Mar 12, 2019
@rdeltour rdeltour requested a review from mattgarrish March 12, 2019 09:14
@rdeltour rdeltour changed the title Feat/nav doc rules Nav Doc link checks (remote resources + reading order) Mar 12, 2019
@rdeltour rdeltour added status: ready to merge The pull request is ready to be merged and removed status: needs review Needs to be reviewed by a team member before further processing labels Mar 12, 2019
@rdeltour rdeltour merged commit 8ba384f into next/v4.2.0 Mar 12, 2019
@rdeltour rdeltour deleted the feat/nav-doc-rules branch March 12, 2019 13:57
rdeltour added a commit that referenced this pull request Jul 11, 2019
As agreed on the 2019-07-11 EPUB CG call:
https://www.w3.org/2019/07/11-epub3cg-minutes.html

Changes the behavior introduced in #999

Fixes #1036
rdeltour added a commit that referenced this pull request Jul 17, 2019
* feat: revert the spine/toc nav order check to a WARNING

As agreed on the 2019-07-11 EPUB CG call:
https://www.w3.org/2019/07/11-epub3cg-minutes.html

- changes the behavior introduced in #999
- adds an INFO message about NAV_011 being subject to change

Fixes #1036
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready to merge The pull request is ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants