Skip to content

fix: Word merged cells, footnotes and tracked changes - #229

Merged
bencode merged 1 commit into
mainfrom
fix/word-conversion
Oct 26, 2026
Merged

bencode merged 1 commit into
mainfrom
fix/word-conversion

Conversation

@bencode

@bencode bencode commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Three places where a Word document converted into something other than what it says. The reader and the assistant read the same conversion, so each fix applies to both.

#178: tables with merged cells

  • Mammoth hands over colspan and rowspan, but GFM tables cannot merge cells. The reader cuts every row to the width of its header, so values shifted under the wrong heading and the cells past the header's width were dropped.
  • expandMergedCells in formats/docx.ts runs before the other table passes:
    • A merged cell gets an empty cell for each other position it covers, across both columns and rows.
    • The value appears once, where Word shows it, and every row has the same number of cells.

#191: footnotes and endnotes

  • Mammoth links each note and its reference with anchors whose ids are lost on the way to Markdown. References went nowhere, and the notes ended as an unlabelled list.
  • They now become GFM footnotes ([^footnote-1]), which the reader renders with links both ways.
    • Two turndown rules write them, because turndown escapes square brackets in text.
    • Mammoth's back links are removed.
    • A note with several paragraphs keeps them by indenting.
  • Footnotes and endnotes share one numbering in the reader. In Word they are numbered apart.
  • Reader fix, outside the Word path: a footnote's back link (↩) went nowhere in any Markdown note.
    • MarkdownAnchor, and the FileLink that hands # links to it, dropped the id the reference carries.
    • The id is now kept in the reader variant only. Chat does not follow # links, and its messages would repeat the same ids.

#181: tracked changes

  • Mammoth shows a document under review as if every change were accepted, and deleted text disappears.
  • When the body has revisions to text, notePendingRevisions in formats/docx-unconverted.ts puts one note at the top. Revisions to paragraph marks or formatting alone don't count. The note reads:
    (2 tracked changes by Alice are not yet accepted or rejected; shown here as accepted, with the changed text unmarked)
  • "with the changed text unmarked" was added after an end-to-end run. Without it, the assistant named the wrong sentences as the changed ones. With it, the assistant says it cannot tell which text changed and suggests checking in Word.
  • Documents without revisions convert exactly as before.

Verification

  • New tests:
  • All four new tests fail on the code before the fix.
  • pnpm check passes:
    • Biome shows only the 4 warnings already on main.
    • TypeScript passes.
    • Unit tests: web 466.
    • Integration tests: 84. In an earlier run, one conversation-switching test failed under load; it passed twice when run on its own and on the next full run.
  • Checked in the browser against a local server, with a generated .docx that has a merged table, two footnotes and two tracked changes:
    • The table lines up.
    • Footnote 2 jumps to the notes, and its ↩ jumps back: scrollTop went from 1040 to 189.
    • The revision note shows at the top.
    • The assistant quoted the second footnote and both Revenue rows correctly.

Closes #178, closes #191, closes #181

…, footnotes link both ways, and a document under review says its tracked changes are shown as accepted
@bencode
bencode merged commit e5e4c5b into main Oct 26, 2026
@bencode
bencode deleted the fix/word-conversion branch October 26, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment