The best way to control Claude Code, Codex and more from any computer or phone
fix(server): EPUB text extraction skips the chapter head (#32370)
Co-authored-by: azhar <azhar.amir@amartha.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
azhar committed
Nov 15, 2026 at 12:12 UTC
7b9af5f22220318fd5518531371aa733ab45c521
2 files changed
+6
-4
apps/server/src/provider/documentTextWorker.ts
+3
-2
@@ -14,9 +14,10 @@ const CELL_END = Symbol("cell-end");
14
type TextPart = string | typeof CELL_START | typeof CELL_END | { fallback: string };
15
16
const TRUNCATED = "\n\n[Extracted text truncated at document extraction limits.]";
17
-// Parts the document never displays: tracked deletions and moves, field codes, phonetic guides,
18
-// paragraph properties such as tab-stop definitions.
17
+// Parts the document never displays: the XHTML head, tracked deletions and moves, field codes,
18
+// phonetic guides, paragraph properties such as tab-stop definitions.
19
const HIDDEN = new Set([
20
+ "head",
21
"script",
22
"style",
23
"binary-data",
apps/server/src/provider/userInputAttachments.test.ts
+3
-2
@@ -1078,11 +1078,11 @@ describe("question answer paths", () => {
1078
"OEBPS/a.xhtml":
1079
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><body><p>Last chapter</p><p>Price <s>10</s> 8 <del>old</del></p></body></html>',
1080
"OEBPS/b.xhtml":
1081
- "<!DOCTYPE html><html><body><h1>First chapter</h1><p>Larkspur</p><div>Direct div<section>Direct section<li>Direct item <em>emphasis</em> trailing</li></section></div><div>Account: A<br/>Balance: 731<line-break/>Currency: USD</div><table><thead><tr><th>Heading</th><th>Total</th></tr></thead><tbody><tr><td>Important value</td><td>731</td></tr><tr><td>Before<table><tr><td>Inner</td></tr></table>After</td><td>Neighbor</td></tr></tbody></table></body></html>",
1081
+ '<!DOCTYPE html><html><head><title>My Novel</title><meta name="author" content="Hidden Author"/></head><body><h1>First chapter</h1><p>Larkspur</p><div>Direct div<section>Direct section<li>Direct item <em>emphasis</em> trailing</li></section></div><div>Account: A<br/>Balance: 731<line-break/>Currency: USD</div><table><thead><tr><th>Heading</th><th>Total</th></tr></thead><tbody><tr><td>Important value</td><td>731</td></tr><tr><td>Before<table><tr><td>Inner</td></tr></table>After</td><td>Neighbor</td></tr></tbody></table></body></html>',
1082
},
1083
expected: [
1084
"## Chapter 1",
1085
- "# First chapter",
1085
+ "\n# First chapter",
1086
"Larkspur",
1087
"Direct div",
1088
"Direct section",
@@ -1095,6 +1095,7 @@ describe("question answer paths", () => {
1095
"Last chapter",
1096
"Price 10 8 old",
1097
],
1098
+ absent: ["My Novel", "Hidden Author"],
1099
},
1100
];
1101
for (const [caseIndex, item] of cases.entries()) {