Skip to content

Improve ChyoaParser: recursive tree walk with nested TOC EPUB output#2764

Merged
dteviot merged 2 commits into
dteviot:ExperimentalTabModefrom
ARYAN-9099:feature/chyoa-recursive-epub
Jul 3, 2026
Merged

Improve ChyoaParser: recursive tree walk with nested TOC EPUB output#2764
dteviot merged 2 commits into
dteviot:ExperimentalTabModefrom
ARYAN-9099:feature/chyoa-recursive-epub

Conversation

@ARYAN-9099

Copy link
Copy Markdown
Contributor

Hello i'm pretty new to contributing on Github. Please tell if there are any mistakes.

Improve ChyoaParser to support recursive branching stories on CHYOA.

The previous parser only read a flat story-map, producing a broken linear EPUB. This PR updates ChyoaParser to:

  • Perform a recursive tree-walk of the story (using a visited-URL Set to guard against circular paths)
  • Construct a nested Table of Contents that matches the story's choice tree
  • Retain and convert choice links to working internal EPUB hyperlinks
  • Strip UI clutter (ratings, ad frames, navigation, and write buttons)
  • Append a warning to the "Searching for URLs" message warning users that tree-walks take longer on CHYOA
  • Extract author metadata from p.meta a

@dteviot dteviot left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This does not collect images.
Have a look at Parser.js, line 604 where fetchImagesUsedInDocument() is called.

Comment thread plugin/js/parsers/ChyoaParser.js Outdated
let clone = contentEl.cloneNode(true);

// Remove CHYOA clutter: ads, ratings, navigation links
for (let sel of [

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Duplicates logic of removeUnwantedElementsFromContentElement. Should update that function and call it here

Comment thread plugin/js/parsers/ChyoaParser.js Outdated
constructor() {
super();
// visitedUrls maps normalized URL → epub-item index.
// Tracks what we've already scraped to handle circular links.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Don't use the "s" word. It can cause problems with extension approval.

@ARYAN-9099

Copy link
Copy Markdown
Contributor Author

@dteviot hey ive made the requested changes. please go ahead and review them again.

@dteviot dteviot merged commit 759d7dc into dteviot:ExperimentalTabMode Jul 3, 2026
1 check passed
@dteviot

dteviot commented Jul 3, 2026

Copy link
Copy Markdown
Owner

@ARYAN-9099
Thank you very much.

@ARYAN-9099

Copy link
Copy Markdown
Contributor Author

@dteviot I wanted to say this extension has been a great help for me for the last 3 years. Thanks for developing this gem. Looking forward to help all that I can.

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.

2 participants