Skip to content

Mark Word content that does not convert where it stood - #73

Merged
bencode merged 1 commit into
mainfrom
feat/docx-unconverted
Oct 2, 2026
Merged

bencode merged 1 commit into
mainfrom
feat/docx-unconverted

Conversation

@bencode

@bencode bencode commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Closes #45.

Word documents reach both the reader and the assistant through the same Mammoth → Markdown conversion, which silently drops some content. A probe with hand-built documents (Mammoth 1.12.3) showed:

Content Converted Mammoth warns
Custom styles text intact yes (a false alarm)
Equations lost yes
Charts, SmartArt lost no
Embedded objects without a preview image lost yes
Comments lost no

Mammoth's warnings both over- and under-report, so they cannot drive a notice.

Change

  • core/docx-unconverted.ts: before Mammoth runs, word/document.xml is scanned by namespace for a fixed list (m:oMathPara/m:oMath, drawings holding c:chart or dgm:relIds, w:object without v:imagedata). Each is replaced in place with an italic run such as (Equation not converted), so the reader and the assistant both see the gap where it is. Content under mc:Choice is skipped, because Mammoth shows the mc:Fallback. A document with none of these, or input that is not a zip package, goes to Mammoth untouched.
  • core/docx.ts: comments are kept via Mammoth's comment-reference => sup and listed at the end; their anchors are unwrapped, since Turndown drops the ids they point to.
  • Markers and comment numbers use parentheses: escaped square brackets (\\[…\\]) render as display math in the reader.
  • jszip becomes a direct dependency. It was already in the bundle through Mammoth, at the same version.

Verification

  • pnpm check passes. The new tests build real .docx packages and run real Mammoth.
  • In the dev app: equation, chart, and embedded-object documents show the markers in place; a comment shows as (1) with its text at the end; Field notes.docx renders as before.

Mammoth drops equations, charts, SmartArt and bare embedded objects,
often without a warning, so readers and the assistant took the converted
text for the whole document. Before conversion, those elements are now
replaced in document.xml with an italic marker such as
(Equation not converted). Comments are kept and listed at the end.
Documents with none of these pass through unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tell readers which Word content did not convert, instead of logging it to the browser console

1 participant