fix(metadata): parse FB2 series from title-info sequence (#4646) (#4649)

FB2 stores series info as `<sequence name="…" number="…"/>` inside
`<title-info>`, but the foliate-js FB2 parser never read it, so
`belongsTo.series` was always empty and the series name/index never
surfaced in the library or book details. Refresh-metadata and
re-import didn't help since they share the same parser path.

Bumps the foliate-js submodule to pull in the `<sequence>` parsing
(readest/foliate-js#28) and adds a regression test + fixture.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Huang Xin
2026-06-18 22:12:59 +08:00
committed by GitHub
parent be17654fc0
commit af587b1a41
3 changed files with 58 additions and 1 deletions
@@ -77,6 +77,25 @@ describe('Calibre series metadata', () => {
});
});
describe('FB2 (title-info sequence)', () => {
let book: BookDoc;
beforeAll(async () => {
book = await loadFixture('sample-metadata.fb2', 'application/x-fictionbook+xml', 'FB2');
});
it('extracts series name and position from the sequence element', () => {
const series = getSeries(book);
expect(series).toBeTruthy();
expect(series!.name).toBe('Metadata Series');
expect(series!.position).toBe('3');
});
it('preserves the title', () => {
expect(book.metadata.title).toBe('FB2 Metadata');
});
});
describe('CBZ (ComicInfo.xml + ComicBookInfo)', () => {
let book: BookDoc;
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink">
<description>
<title-info>
<genre>sf_fantasy</genre>
<author>
<first-name>Jane</first-name>
<last-name>Doe</last-name>
</author>
<book-title>FB2 Metadata</book-title>
<annotation>
<p>A short annotation.</p>
</annotation>
<lang>en</lang>
<sequence name="Metadata Series" number="3"/>
</title-info>
<document-info>
<author>
<first-name/>
<last-name/>
</author>
<date value="2023-10-18">18 October 2023</date>
<id>43AC9A08-92D4-432C-B908-FCE4992205CC</id>
<version>1.0</version>
</document-info>
</description>
<body>
<title>
<p>FB2 Metadata</p>
</title>
<section>
<title>
<p>Chapter 1</p>
</title>
<p>Hello world.</p>
</section>
</body>
</FictionBook>