Skip to content

Core 2259 epub page roles - #467

Open
TylerZeroMaster wants to merge 11 commits into
mainfrom
CORE-2259-epub-page-roles
Open

Core 2259 epub page roles#467
TylerZeroMaster wants to merge 11 commits into
mainfrom
CORE-2259-epub-page-roles

Conversation

@TylerZeroMaster

@TylerZeroMaster TylerZeroMaster commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds structural semantics extracted from the EPUB ToC into generated page XHTML to improve screen-reader navigation and heading structure.

Changes:

  • Extend ToC tree nodes to capture data-toc-type / data-toc-target-type from ToC <li> elements.
  • Derive ARIA landmark roles (and labels) for structural pages (unit/chapter/preface/appendix/index) based on ToC metadata.
  • Normalize page heading levels and optionally inject an “ancestor” title heading for chapter/unit intro pages; add targeted test coverage and snapshot updates.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
bakery-js/src/model/base-toc.tsx Captures ToC metadata attributes into the generic ToC tree model.
bakery-js/src/epub/toc.tsx Maps ToC metadata to ARIA roles and sets role/label info on the relevant PageFiles.
bakery-js/src/epub/toc.test.ts Adds tests for ToC metadata capture, role assignment, and ancestor title behavior.
bakery-js/src/epub/page.tsx Applies heading normalization, injects ancestor title, and writes role/epub:type/aria-label onto page content.
bakery-js/src/epub/page.test.ts Adds tests for heading normalization, ancestor title insertion, and structural role attributes.
bakery-js/src/epub/snapshots/toc.test.ts.snap Updates snapshots for new ToC attributes and ToC output changes.
bakery-js/src/epub/snapshots/page.test.ts.snap Updates snapshots for heading normalization and new PageFile fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bakery-js/src/epub/page.tsx Outdated
Comment thread bakery-js/src/epub/page.tsx Outdated
Comment thread bakery-js/src/epub/page.test.ts Outdated

@Dantemss Dantemss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems fine, I just had one question

stack.pop()
}

const parent = stack[stack.length - 1]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was confused for a sec about the stack with the while loop but I see it's just a way to track potential parent headings, and not actually doing recursion.

Comment thread bakery-js/src/epub/toc.tsx Outdated
// A chapter/unit start (set below, via an ancestor INNER node) is a
// structural landmark and takes priority over this leaf's own
// tocTargetType — e.g. an "intro" page IS a chapter's first page, so
// it should stay `doc-chapter` rather than being reassigned here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Took me way too long to figure out this comment is explaining the toc.page.ariaSpec === null check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think I will rewrite this one 😂

if (role !== undefined) {
const firstPage = this.findFirstPage(toc)
firstPage.ariaSpec = { role, label: toc.title }
firstPage.ancestorTitle = { title: toc.title, pos: toc.titlePos }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this still fine if there are no chapter intro pages etc?

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.

3 participants