GeezerVison is showing github.com — fix(server): EPUB attachments keep their table captions for agents (#… · patroza/t3code@487a29b
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 +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -355,8 +355,14 @@ function hasCellText(cell: XmlNode): boolean { | 355 | 355 | ); | 356 | 356 | } | 357 | 357 | function* table(node: XmlNode): Generator<TextPart, void> { | | 358 | + for (const caption of children(node)) { | | 359 | + if (caption.name !== "caption") continue; | | 360 | + yield LINE_START; | | 361 | + yield* paragraphs(caption); | | 362 | + yield LINE_START; | | 363 | + } | 358 | 364 | let rowCount = 0; | 359 | | - for (const row of all(node, ["tr", "table-row"])) { | | 365 | + for (const row of all(node, ["tr", "table-row"], ["caption"])) { | 360 | 366 | // Word nests a cell inside w:sdt when a content control wraps the whole cell. | 361 | 367 | const cells = [...all(row, ["tc", "table-cell", "covered-table-cell", "td", "th"])]; | 362 | 368 | // ODS writers pad sheets with repeated empty rows and trailing cells. | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/userInputAttachments.test.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1514,7 +1514,7 @@ describe("question answer paths", () => { | 1514 | 1514 | "OEBPS/book.opf": | 1515 | 1515 | '<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>', | 1516 | 1516 | "OEBPS/a.xhtml": | 1517 | | - '<!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><p><ruby>山路<rt>やまみち</rt></ruby>を歩く。<ruby>東京<rp>(</rp><script type="application/json">{}</script><rt>とうきょう</rt><script type="application/json">{}</script><rp>)</rp></ruby>に着く。<ruby>川<rt/></ruby>を見る。<ruby>海<rp/><rt>うみ</rt><rp> </rp></ruby>まで。</p></body></html>', | | 1517 | + '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><body><p>Last chapter</p><div>Totals<table><caption>Table 1: Revenue</caption><tr><th>Q1</th><th>Q2</th></tr><tr><td>100</td><td>200</td></tr></table></div><table><caption><p>Table 2: Costs</p></caption><tr><td>Rent</td></tr></table><p>Price <s>10</s> 8 <del>old</del></p><p><ruby>山路<rt>やまみち</rt></ruby>を歩く。<ruby>東京<rp>(</rp><script type="application/json">{}</script><rt>とうきょう</rt><script type="application/json">{}</script><rp>)</rp></ruby>に着く。<ruby>川<rt/></ruby>を見る。<ruby>海<rp/><rt>うみ</rt><rp> </rp></ruby>まで。</p></body></html>', | 1518 | 1518 | "OEBPS/b.xhtml": | 1519 | 1519 | '<!DOCTYPE html><html><head><title>My Novel</title><meta name="author" content="Hidden Author"/></head><body><h1>First chapter</h1><p>Larkspur</p><p>Map: <img src="map.png" alt="North & south piers"/> open<img src="blank.png" alt=""/><img src="missing.png"/>.</p><div><img src="cover.png" alt="Cover art"/></div><img hidden="" src="draft.png" alt="Hidden image text"/><img src="none.png" alt="Display none image" style="width: 1em; DISPLAY: none"/><img src="invisible.png" alt="Invisible image" style="visibility:hidden !important"/><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><ol><li>Before boarding<ul><li>Check passports<ol><li>Compare names</li></ol></li><li>Confirm gate</li></ul></li><li>Board promptly</li><li><p>Before landing</p><ul><li>Collect bags</li></ul></li></ol>' + | 1520 | 1520 | "<ol><li>Indented\n <ul><li>Alpha</li></ul></li></ol></body></html>", | @@ -1540,6 +1540,8 @@ describe("question answer paths", () => { | 1540 | 1540 | "Indented\n Alpha", | 1541 | 1541 | "## Chapter 2", | 1542 | 1542 | "Last chapter", | | 1543 | + "Totals\nTable 1: Revenue\nQ1\tQ2\n100\t200", | | 1544 | + "Table 2: Costs\nRent", | 1543 | 1545 | "Price 10 8 old", | 1544 | 1546 | "山路(やまみち)を歩く。東京(とうきょう)に着く。川を見る。海(うみ) まで。", | 1545 | 1547 | "## Chapter 3", | |
|