Skip to content

fix(madara): preserve volume order for multi-volume chapter lists (v2.4.0) - #1

Closed
7ui77 wants to merge 2 commits into
masterfrom
fix/madara-volume-chapter-order
Closed

7ui77 wants to merge 2 commits into
masterfrom
fix/madara-volume-chapter-order

Conversation

@7ui77

@7ui77 7ui77 commented Oct 31, 2026

Copy link
Copy Markdown
Owner

fix(madara): preserve volume order for multi-volume chapter lists (v2.4.0)

Checklist

  • Update version code if an existing plugin was modified
  • Test changes in Plugin Playground or the app
  • Reference related issues in the PR body (e.g. Closes #xyz)
  • Commit messages follow type(scope): description (e.g. feat(<generator>): add new source)

Summary

Fixes inverted chapter order for multi-volume/multi-arc novels under the Madara multisrc generator (such as Foxaholic: Strange Grief Wants to Retire The Weakest Hunter Dreams of a Hero).

On WordPress Madara theme sites, volume containers (li.parent.has-child) are rendered in ascending order (Volume 0: Short Story -> Arc 1 -> Arc 2 -> ... -> Arc 11), while chapters within each volume are rendered in descending order (newest first).

Previously, flattening all .wp-manga-chapter elements across the whole page into a single array and reversing it inverted the volume sequence itself (putting Arc 11 first and Short Stories / Arc 1 last).

 parseNovel(novelPath)
-  chapters = all('.wp-manga-chapter').map(parseChapter)
-  return chapters.reverse()
+  if (volumes = all('li.parent.has-child')).length > 0
+    for each volume in volumes (chronological order)
+      volChapters = volume.all('.wp-manga-chapter').map(parseChapter)
+      chapters.push(...volChapters.reverse())
+  else
+    chapters = all('.wp-manga-chapter').map(parseChapter).reverse()
+  reindex(chapterNumber: 1..N)

Evidence

  • Before:
    ✖ Foxaholic chapter order for multi-volume novel (Strange Grief)
      AssertionError [ERR_ASSERTION]: Expected first chapter to be SS1 or 1-23, but got "467.1 - Detention"
      First chapter: '467.1 - Detention' (chapterNumber: 1)
      Last chapter:  'SS3.2 - Strange Grief Wants to be Recorded' (chapterNumber: 927)
    
  • After:
    ✔ Madara multi-volume chapter ordering (6/6 chaps correctly sorted)
    ✔ Madara chapter order for flat non-volume novel (3/3 chaps correctly sorted)
    ✔ Foxaholic chapter order for multi-volume novel (Strange Grief)
      First chapter: 'SS1 - Tino Shade’s Creed' (chapterNumber: 1)
      Chapter 5:     '1-23 - PDF Chapter 1-23 by Redhare404' (chapterNumber: 5)
      Last chapter:  '503.1 - Fox God's Shrine Maiden' (chapterNumber: 927)
    

@7ui77 7ui77 closed this Oct 31, 2026
@7ui77
7ui77 deleted the fix/madara-volume-chapter-order branch November 1, 2026 12:37
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