Skip to content

Parse EPUB 2 guide as EPUB 3 landmarks #603

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

Merged
merged 1 commit into from
Jun 4, 2025
Merged

Conversation

mickael-menu
Copy link
Member

Added

Streamer

  • The EPUB 2 <guide> element is now parsed into the RWPM landmarks subcollection when no EPUB 3 landmarks navigation document is declared.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for parsing EPUB 2 guide elements as a fallback for landmarks when no EPUB 3 navigation document is supplied.

  • Adds a new test (testParseEPUB2GuideAsLandmarks) to verify the parsing of the EPUB 2 guide as landmarks.
  • Updates the OPFParser to include the EPUB 2 guide in its returned Package and revises the EPUBManifestParser to integrate this fallback behavior.
  • Introduces a new String extension (orNilIfBlank) used throughout for clearer blank-checking.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Tests/StreamerTests/Parser/EPUB/EPUBManifestParserTests.swift Added new test for EPUB 2 guide parsing as landmarks.
Tests/StreamerTests/Fixtures/OPF/guide-epub2.opf Added fixture representing an EPUB 2 package with a guide element.
Sources/Streamer/Parser/EPUB/OPFParser.swift Updated to return a Package including the new epub2Guide property and added a new parseEPUB2Guide() function.
Sources/Streamer/Parser/EPUB/Extensions/LinkRelation+EPUB.swift Updated initializers to use clearer parameter names and added an initializer for EPUB 2 types.
Sources/Streamer/Parser/EPUB/EPUBManifestParser.swift Adjusted parsing logic to integrate the EPUB 2 guide when landmarks are absent.
Sources/Shared/Publication/Services/Content/Iterators/HTMLResourceContentIterator.swift Refactored blank-checking by replacing takeUnlessBlank() with orNilIfBlank().
Sources/Internal/Extensions/String.swift Added orNilIfBlank method for enhanced string validation.
CHANGELOG.md Documented the change regarding streaming EPUB 2 guides as landmarks.
Comments suppressed due to low confidence (1)

Sources/Streamer/Parser/EPUB/OPFParser.swift:85

  • [nitpick] The property name 'epub2Guide' clearly indicates its purpose, but for consistency and clarity it might be worth considering a renaming (e.g., to 'epub2GuideLinks') so that it aligns with other link collections like readingOrder and resources.
let epub2Guide: [Link]

@mickael-menu mickael-menu merged commit 0af38f2 into develop Jun 4, 2025
5 checks passed
@mickael-menu mickael-menu deleted the epub2-guide branch June 4, 2025 07:42
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.

1 participant