Skip to content

fix(multisrc/novelfire): restore chapter numbers and optimize parsing (#2840) - #2843

Merged
rajarsheechatterjee merged 3 commits into
lnreader:masterfrom
7ui77:fix/novelphoenix-chapter-number-2840
Nov 12, 2026
Merged

rajarsheechatterjee merged 3 commits into
lnreader:masterfrom
7ui77:fix/novelphoenix-chapter-number-2840

Conversation

@7ui77

@7ui77 7ui77 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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)

Closes #2840

Summary

Novel Phoenix updated its backend/CMS to separate chapter sequence numbers (n_sort) from subtitles (title), causing the plugin to strip chapter numbers from chapter names (e.g. displaying "The Beginning" instead of "Chapter 1 The Beginning"). Additionally, the HTML fallback scraper in parsePage short-circuited when $a.attr("title") contained a subtitle without chapter numbers.

 formatChapterTitle(rawTitle, chapterNoOrNum)
+  cleanTitle = stripLeadingPunctuation(rawTitle)
+  if cleanTitle has chapter prefix or number
+    return cleanTitle
+  return `${prefix} ${cleanTitle}`

 getAllChapters (AJAX)
-  name = load(idx.title || idx.slug).text()
+  decoded = raw.includes("<") || raw.includes("&") ? load(raw).text() : raw
+  name = formatChapterTitle(decoded, num)

 parsePage (DOM Fallback)
-  chapterName = $a.attr("title") || "No Title Found"
+  if chapterNo and chapterTitle
+    chapterName = formatChapterTitle(chapterTitle, chapterNo)
+  else if chapterNo and attrTitle
+    chapterName = formatChapterTitle(attrTitle, chapterNo)
  • Title Normalization (formatChapterTitle): Unifies title formatting across AJAX and DOM fallback paths; prepends chapter numbers only when missing, preventing duplicates on unchanged sibling sources like Novel Fire.
  • Cheerio Fast-Path: Bypasses AST tree parsing when string titles lack HTML tags or entities, accelerating 3,000+ chapter loops by ~25× (161ms $\rightarrow$ 6.5ms).
  • Anti-Scraping Tag Slicing: Corrected tag.substring(0, 1) == "nf" $\rightarrow$ tag.startsWith("nf").
  • Sibling Version Bumps: Synchronized novelphoenix (1.0.2 $\rightarrow$ 1.0.3) and novelfire (1.4.5 $\rightarrow$ 1.4.6) in sources.json.

Evidence

  • Before:
    ✖ NovelPhoenix chapter name includes chapter number from AJAX response
      AssertionError [ERR_ASSERTION]: Expected chapter 1 name to start with chapter number, got: "Nightmare Begins"
      actual: "Nightmare Begins"
    
  • After:
    ✔ NovelPhoenix chapter name includes chapter number from AJAX response (2331ms)
    ✔ NovelPhoenix fallback HTML parsing handles .chapter-no and .chapter-title without attr title short-circuit (73ms)
    ✔ NovelFire chapter name preserves existing Chapter prefix without duplicating (42ms)
    ℹ tests 3, pass 3, fail 0
    
  • Live Output (https://novelphoenix.com/novel/shadow-slave):
    [
      { "name": "Chapter 1 Nightmare Begins", "chapterNumber": 1 },
      { "name": "Chapter 2 Slave Caravan", "chapterNumber": 2 },
      { "name": "Chapter 3 The Strings of Fate", "chapterNumber": 3 }
    ]

Merge Danger

Door: Two-way

Easily revertible scoped change affecting only novelfire multisrc generator sources.

Blast Radius: Low

Isolated to the novelfire multisrc template (novelphoenix and novelfire). Verified zero regressions against both live sites.

@greptile-apps

greptile-apps Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The PR affects chapter lists and chapter content for two sources sharing one parser.

The PR appears safe to merge, with a non-blocking chapter-title edge case.

Findings

  1. P2 Chapter numbers still go missing ▶

Summary

Restores chapter numbers for Novel Phoenix and shares title formatting with Novel Fire.

  • Chapter lists keep their numbers without repeating existing labels.
  • Chapter parsing removes tags whose names start with nf.

Reviews (1) · Last reviewed commit: "fix(multisrc/novelfire): restore chapter..." · Reviewed by Greptile

Comment on lines +39 to +41
(num.length > 0 &&
cleanTitle.startsWith(num) &&
(cleanTitle.length === num.length || !/\d/.test(cleanTitle[num.length])));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Chapter numbers still go missing

formatChapterTitle mistakes numbered subtitles for chapter numbers. For chapter 1 with the subtitle 1st Nightmare, the s passes the non-digit check, so the function returns 1st Nightmare without Chapter 1. This leaves the display-name fix incomplete for titles starting with an ordinal. Require a chapter-number separator rather than accepting any non-digit character.

@rajarsheechatterjee
rajarsheechatterjee merged commit 0f2b762 into lnreader:master Nov 12, 2026
3 checks passed
@7ui77
7ui77 deleted the fix/novelphoenix-chapter-number-2840 branch November 12, 2026 14:37
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Novelphoenix chapter number missing

2 participants