GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): DOCX merged table cells no longer shift later columns in… · patroza/t3code@b136053

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/provider
    • documentTextWorker.ts
    • userInputAttachments.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/provider/documentTextWorker.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/provider/documentTextWorker.ts
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,18 @@ function* table(node: XmlNode): Generator<TextPart, void> {
366366
for (let index = 0; index < repeat; index++) {
367367
if (++rowCount > 10_000) throw new Truncation("Row limit");
368368
let column = 0;
369+
let gap = 0;
369370
for (const cell of cells) {
370371
const count = repeatCount(cell.attrs["number-columns-repeated"]);
372+
// Word emits no cell for columns covered by w:gridSpan; pad before the next cell.
373+
const tcPr = cell.name === "tc" ? children(cell).find((c) => c.name === "tcPr") : undefined;
374+
const val = tcPr && children(tcPr).find((c) => c.name === "gridSpan")?.attrs.val;
375+
const span = val ? Math.max(1, Number.parseInt(val, 10) || 1) : 1;
371376
for (let i = 0; i < count; i++) {
372-
if (column >= 512) throw new Truncation("Column limit");
373-
if (column++) yield "\t";
377+
column += span;
378+
if (column > 512) throw new Truncation("Column limit");
379+
if (gap) yield "\t".repeat(gap);
380+
gap = span;
374381
// LibreOffice hides the contents a merge covers; the cell still holds its column.
375382
if (covered(cell)) continue;
376383
yield CELL_START;
Collapse file

‎apps/server/src/provider/userInputAttachments.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/provider/userInputAttachments.test.ts
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,25 @@ describe("question answer paths", () => {
961961
"Before Inner After\tNeighbor\t\u2011\n\u2011\nDemoted\nIntro. # Box title",
962962
],
963963
},
964+
{
965+
ext: "docx",
966+
bounded: true,
967+
parts: {
968+
"word/document.xml":
969+
'<w:document xmlns:w="urn:w"><w:body><w:tbl>' +
970+
"<w:tr><w:tc><w:p><w:r><w:t>A</w:t></w:r></w:p></w:tc><w:tc><w:p><w:r><w:t>B</w:t></w:r></w:p></w:tc><w:tc><w:p><w:r><w:t>C</w:t></w:r></w:p></w:tc></w:tr>" +
971+
'<w:tr><w:tc><w:p><w:r><w:t>Tail</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:gridSpan w:val="2"/></w:tcPr><w:p><w:r><w:t>End</w:t></w:r></w:p></w:tc></w:tr>' +
972+
'<w:tr><w:tc><w:tcPr><w:gridSpan w:val="2"/></w:tcPr><w:p><w:r><w:t>Merged</w:t></w:r></w:p></w:tc><w:tc><w:p><w:r><w:t>Total</w:t></w:r></w:p></w:tc></w:tr>' +
973+
'<w:tr><w:tc><w:tcPr><w:gridSpan w:val="0"/></w:tcPr><w:p><w:r><w:t>Zero</w:t></w:r></w:p></w:tc><w:tc><w:p><w:r><w:t>Next</w:t></w:r></w:p></w:tc></w:tr>' +
974+
'<w:tr><w:tc><w:tcPr><w:gridSpan w:val="513"/></w:tcPr><w:p><w:r><w:t>Wide</w:t></w:r></w:p></w:tc></w:tr>' +
975+
"</w:tbl></w:body></w:document>",
976+
},
977+
expected: [
978+
"A\tB\tC\nTail\tEnd\nMerged\t\tTotal\nZero\tNext",
979+
"[Extracted text truncated at document extraction limits.]",
980+
],
981+
absent: ["Wide"],
982+
},
964983
{
965984
ext: "docx",
966985
bounded: true,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.