Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse <nav> elements nested in other HTML elements in EPUB 3 navigation documents #113

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

vers-one
Copy link
Owner

@vers-one vers-one commented Jun 4, 2024

Parse <nav> elements nested in other HTML elements in EPUB 3 navigation documents

This is:

  • a bug fix
  • an enhancement

Related issue: #106

Description

When EpubReader parses a EPUB 3 navigation file, it expects to find a <nav epub:type="toc"> element among the children of the <body> element. However, if the <nav> element is wrapped in another HTML element (e.g. <div>), EpubReader won't be able to find it. The EPUB 3 specification doesn't specify whether <nav> elements can be wrapped in other elements, but since it doesn't prohibit it, EpubReader should support this case.

This pull request adds a recursive search for all <nav> elements within the EPUB 3 navigation file.

Testing steps

  1. Use the toc.xhtml file from the linked issue to test the parsing of a <nav> element is wrapped in a <div>.
  2. Run the newly added unit test (Epub3NavDocumentReaderTests.ReadEpub3NavDocumentAsyncWithNonTopLevelNavElementTest).

@vers-one vers-one self-assigned this Jun 4, 2024
@vers-one vers-one merged commit 57a921e into master Jun 4, 2024
4 checks passed
@vers-one vers-one deleted the nested-navs branch June 4, 2024 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse <nav> elements nested in other HTML elements in EPUB 3 navigation documents
1 participant