Skip to content

fix(english/lncrawler): keep chapter heading and add search filters - #2754

Merged
rajarsheechatterjee merged 3 commits into
lnreader:masterfrom
tmfahad39:fix/lncrawler-chapter-heading
Oct 24, 2026
Merged

rajarsheechatterjee merged 3 commits into
lnreader:masterfrom
tmfahad39:fix/lncrawler-chapter-heading

Conversation

@tmfahad39

Copy link
Copy Markdown
Contributor

What

  • Chapter heading: the plugin previously stripped the leading <h1> from the chapter body (parseChapterBody), assuming the app already shows the title. In practice readers lost the chapter title/number inside the chapter view. The heading is now kept — LNCrawler titles include the chapter number (e.g. Chapter 1 - 1: Nightmare Begins).
  • Search filters: popularNovels/searchNovels now use the API's filter params discovered from the site frontend: languages (20 ISO languages, repeated param), status, sort_by (title/rating/date_added/popularity/trending/last_updated), sort_order (asc/desc), adult (hide/show/only).
    • Catalog defaults: popular = popularity desc; the Latest toggle = last_updated desc; English when no filters are passed (search interface has no options param).
  • Version 1.0.1 → 1.1.0.

Validation performed

  • npm run check:plugin -- plugins/english/lncrawler.ts → all 4 live checks PASS (20 novels, search OK, 1433 chapters, 9439-char chapter).
  • npx tsc --noEmit -p tsconfig.production.json clean; prettier and lint clean for the file.

Authored with the OpenCode AI agent (Co-Authored-By trailer in commits).

- Keep the API's leading <h1> in chapter bodies so readers see the
  chapter title (including its number) in the chapter header.
- Add filter support to popularNovels/searchNovels via the search
  API: languages, status, sort_by, sort_order and adult content,
  with popular = popularity desc and Latest = last_updated desc.
- Bump version to 1.1.0.

Co-Authored-By: opencode <ai@opencode.dev>
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches readers who browse or read novels through LNCrawler.

Fix the lost language choice before merging; readers can otherwise receive chapters in a language they did not select.

Findings

  1. P1 Chapters ignore the chosen language ▶
  2. P2 Filters cannot be cleared individually ▶
  3. P2 Exported headings appear twice ▶

Summary

Keeps the chapter heading and adds language, status, sort, and adult-content filters to LNCrawler. Raises version to 1.1.0.

  • LNCrawler chapters keep their opening title and number.
  • The LNCrawler catalog can filter by language, status, sorting, and adult content.

Reviews (1) · Last reviewed commit: "fix(english/lncrawler): keep chapter hea..." · Reviewed by Greptile

Comment on lines +439 to +440
for (const language of filters?.languages?.value || []) {
if (language) params.append('languages', language);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Chapters ignore the chosen language

Selecting a non-English language changes the catalog request, but opening a matching novel still calls chooseSource, which prefers English whenever English chapters exist. Cards carry only the novel slug, so the language choice never reaches the chapter source choice. Carry the selected language into the saved path and use it when choosing the source.

Knowledge Base Used: English source plugins

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.

Addressed in a045b06: the catalog now carries the selected languages in the novel path (slug?lang=a,b), and chooseSource prefers a source in one of those languages (first listed first) over the default English preference. Bare-slug/safe fallback (English-first) kept for paths saved before this change.

Comment on lines +385 to +389
status: {
type: FilterTypes.Picker,
label: 'Status',
value: '',
options: STATUS_OPTIONS,

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 Filters cannot be cleared individually

The four new pickers default to '', but none offers an option for that value. After choosing a status, readers cannot return just that field to “All” without resetting their other choices. The default sort and adult-content settings have the same problem. Add a labeled empty option to each picker so readers can clear each choice independently.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

Addressed in a045b06: every picker (status/sort/order/adult) now starts with an empty-value option (All / Default) so any single filter can be reset without touching the others.

.replace(/^\s*<h1\b[^>]*>[\s\S]*?<\/h1>\s*/i, '')
.trim();
return sanitizeChapterHtml(withoutTitle);
return sanitizeChapterHtml(res.body.trim());

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 Exported headings appear twice

The retained chapter heading reaches EPUB export unchanged. createEpub already adds its own heading before the returned content, so exported LNCrawler chapters now start with two headings. Keep the heading for reading, but make the export path avoid adding another when the content already has one.

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.

Keeping the heading is intentional here: without it readers opened chapters with no title/number at all in the chapter header (this was reported by users reading on the app). The heading in the body faithfully mirrors what the source API provides for every chapter. The EPUB-export duplication is app-side — createEpub could skip adding its own title when the chapter content already starts with a heading (same guard other heading-preserving plugins would benefit from). Happy to revisit the opposite way if the app-side guard lands first.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That makes sense. The source heading is needed for the in-app reading experience, and the EPUB duplication is better handled by a generic guard in createEpub than by stripping or altering this plugin’s content. I’m withdrawing the finding; it shouldn’t block this PR.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

tmfahad39 and others added 2 commits October 24, 2026 03:42
…rable filters

- Catalog cards carry the chosen languages in their path
  (slug?lang=a,b); parseNovel now prefers a chapter source in one of
  those languages over the default English preference.
- Add All/Default (empty) options to status, sort, order and adult
  pickers so each filter can be cleared individually.
- Make novel slug extraction robust for bare-slug and resolved URLs.
- Bump version to 1.1.1.

Co-Authored-By: opencode <ai@opencode.dev>
Co-Authored-By: opencode <ai@opencode.dev>
@rajarsheechatterjee
rajarsheechatterjee merged commit 87259e8 into lnreader:master Oct 24, 2026
3 checks passed
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