GeezerVison is showing github.com — fix(server): EPUB attachment text no longer includes hidden passages … · patroza/t3code@80cac28
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/documentTextWorker.ts +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -110,11 +110,15 @@ function xml(source: string, extension: string): XmlNode { | 110 | 110 | stack.at(-1)!.children.push(node); | 111 | 111 | stack.push(node); | 112 | 112 | }); | 113 | | - parser.on("closetag", () => { | | 113 | + parser.on("closetag", (tag) => { | 114 | 114 | const node = stack.pop()!; | 115 | 115 | const parent = stack.at(-1)!; | 116 | 116 | if (odf && (node.name === "p" || node.name === "h")) collapseOdfWhitespace(node); | 117 | 117 | if ( | | 118 | + (extension === ".epub" && | | 119 | + (stack[1] ?? node).name === "html" && | | 120 | + Object.hasOwn(tag.attributes, "hidden") && | | 121 | + !/^until-found$/i.test(String(tag.attributes.hidden))) || | 118 | 122 | (extension === ".docx" && node.name === "del") || | 119 | 123 | (extension === ".docx" && | 120 | 124 | node.name === "r" && | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/userInputAttachments.test.ts +13-3Lines changed: 13 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1493,11 +1493,12 @@ describe("question answer paths", () => { | 1493 | 1493 | "META-INF/container.xml": | 1494 | 1494 | '<container><rootfile full-path="OEBPS/book.opf"/></container>', | 1495 | 1495 | "OEBPS/book.opf": | 1496 | | - '<package><manifest><item id="a" href="a.xhtml"/><item id="b" href="b.xhtml"/></manifest><spine><itemref idref="b"/><itemref idref="a"/></spine></package>', | | 1496 | + '<package><manifest><item id="a" href="a.xhtml"/><item id="b" href="b.xhtml"/><item id="c" href="c.xhtml"/></manifest><spine><itemref idref="b"/><itemref idref="a" hidden=""/><itemref idref="c"/></spine></package>', | 1497 | 1497 | "OEBPS/a.xhtml": | 1498 | 1498 | '<!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>', | 1499 | 1499 | "OEBPS/b.xhtml": | 1500 | | - '<!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><dl><dt>Port</dt><dd>443</dd><dt>Timeout</dt><dd>30 seconds</dd></dl></body></html>', | | 1500 | + '<!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><dl><dt>Port</dt><dd>443</dd><dt>Timeout</dt><dd>30 seconds</dd></dl><p hidden="">Draft note</p><div hidden="hidden">Hidden block<p>Hidden nested</p></div><p hidden="UNTIL-FOUND">Findable note</p><p aria-hidden="true">Decorative note</p><p x:hidden="true">Prefixed note</p></body></html>', | | 1501 | + "OEBPS/c.xhtml": '<html hidden=""><body><p>Root hidden</p></body></html>', | 1501 | 1502 | }, | 1502 | 1503 | expected: [ | 1503 | 1504 | "## Chapter 1", | @@ -1511,11 +1512,20 @@ describe("question answer paths", () => { | 1511 | 1512 | "Important value\t731", | 1512 | 1513 | "Before Inner After\tNeighbor", | 1513 | 1514 | "Port\n443\nTimeout\n30 seconds", | | 1515 | + "Findable note\nDecorative note\nPrefixed note", | 1514 | 1516 | "## Chapter 2", | 1515 | 1517 | "Last chapter", | 1516 | 1518 | "Price 10 8 old", | | 1519 | + "## Chapter 3", | | 1520 | + ], | | 1521 | + absent: [ | | 1522 | + "My Novel", | | 1523 | + "Hidden Author", | | 1524 | + "Draft note", | | 1525 | + "Hidden block", | | 1526 | + "Hidden nested", | | 1527 | + "Root hidden", | 1517 | 1528 | ], | 1518 | | - absent: ["My Novel", "Hidden Author"], | 1519 | 1529 | }, | 1520 | 1530 | ]; | 1521 | 1531 | for (const [caseIndex, item] of cases.entries()) { | |
|