adeu icon indicating copy to clipboard operation
adeu copied to clipboard

Comment marker uses rStyle "CommentReference" without defining the style

Open Dmitry-Kov opened this issue 2 months ago • 2 comments

Small one. Ran adeu 3.0.2 (Python SDK) over a contract with existing reviewer comments, footnotes and another author's unaccepted tracked changes: one ModifyText with a comment, then compared the output against the source by construct count. Everything that was there survived — comment anchors 2 → 3, tracked insertions 2 → 3, deletions 1 → 2, footnote references, styles and numbering intact. That's the cleanest round-trip I've measured so far, so first: nice.

The one thing that came up: the run holding the new w:commentReference gets rStyle w:val="CommentReference", but styles.xml in the source document has no style with that id, and adeu doesn't add one. Word tolerates a dangling rStyle silently and formats the reference mark with the run's default properties instead of the built-in 8pt "annotation reference" style. No warning anywhere, just a slightly wrong-looking mark. LibreOffice behaves the same.

<w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:commentReference w:id="3"/></w:r>
# styles.xml: no w:styleId="CommentReference"

Fix is to define the style when adding a comment if the document lacks it — the definition Word writes is roughly:

<w:style w:type="character" w:styleId="CommentReference">
  <w:name w:val="annotation reference"/>
  <w:basedOn w:val="DefaultParagraphFont"/>
  <w:uiPriority w:val="99"/>
  <w:semiHidden/><w:unhideWhenUsed/>
  <w:rPr><w:sz w:val="16"/><w:szCs w:val="16"/></w:rPr>
</w:style>

(python-docx 1.2's add_comment has the same gap, for what it's worth.)

Separately: while building the checker I used for this (github.com/Dmitry-Kov/ooxml-integrity) I assembled 220 labelled before/after .docx pairs from five producers, including inputs that already carry another author's tracked changes. If a subset would be useful as regression fixtures for the projection, tell me the layout you use and I'll open a PR.

adeu_out.docx base.docx

Dmitry-Kov avatar Sep 07 '26 14:09 Dmitry-Kov

Thanks @Dmitry-Kov for the issue!

mkorpela avatar Sep 07 '26 22:09 mkorpela

Thanks for the report @Dmitry-Kov . The fix shipped in v3.0.3, and your repro document is now a committed fixture (shared/fixtures/base.docx).

You can submit a subset of your corpus as regression fixtures — 2–3 documents per category below. Our suite auto-discovers folders under shared/cross_platform_tests/, runs each one against both engines (Python and TypeScript) on every CI run, and a green PR is all we need to merge. Folders are named NN_<producer>_<feature>, numbering continues from 03.

Category 1 — projection fixtures. Documents with another author's tracked changes, comments, or producer quirks.

  • Paste the before document as shared/cross_platform_tests/03_<producer>_<feature>/input.docx. The after document is not used — don't include it.
  • Add test.json next to it:
{
  "name": "lo75_foreign_revisions",
  "description": "Producer: LibreOffice 7.5. Insertions/deletions by another author, one comment thread.",
  "read_only": true
}
  • From python/, run uv run python scripts/generate_goldens.py and commit the two golden_*.md files it writes into your folder (required — without goldens the scenario asserts nothing). Skim golden_raw.md once to confirm it reflects the document's actual revisions.

Category 2 — before/after pairs. Real editing sessions replayed as tracked changes.

  • Paste the before document as shared/cross_platform_tests/04_<producer>_<feature>/input.docx. Do not commit the after document — it's used once, locally:
uv run adeu diff <before.docx> <after.docx> --json
  • Paste the output array into test.json as "changes" (no read_only key), and note the after-file's sha256 in the description:
{
  "name": "word365_table_edit",
  "description": "Producer: Word 365. after.docx sha256: <hash>",
  "changes": [ ...diff output... ]
}
  • From python/, run uv run python scripts/generate_goldens.py and commit the three golden files it writes into your folder. If the diff output degenerates into one whole-document replacement instead of targeted edits, tell us — that's a bug we want to hear about.

Category 3 — review-action fixtures. Documents where another author's tracked changes get accepted or rejected.

  • Paste the before document (the one carrying foreign tracked changes) as shared/cross_platform_tests/05_<producer>_<feature>/input.docx. The after document is not used — don't include it.
  • Run uv run adeu extract input.docx to see the revision IDs ([Chg:2 insert], [Chg:6 delete], ...), then write test.json replaying review actions against them:
{
  "name": "word2019_accept_reject",
  "description": "Producer: Word 2019. Accepts one foreign insertion, rejects one deletion.",
  "changes": [
    {"type": "accept", "target_id": "Chg:2"},
    {"type": "reject", "target_id": "Chg:6"}
  ]
}
  • From python/, run uv run python scripts/generate_goldens.py and commit the three golden files it writes into your folder.

Housekeeping:

  • Save test.json as UTF-8 without BOM (some Windows editors add one; it breaks the parser).
  • The goldens script regenerates every scenario — commit only files inside your own folders.
  • One focused PR, fixture folders only. State that you have redistribution rights, and no personal data you don't want public (author names inside revisions included).

Git-Uzair avatar Sep 08 '26 15:09 Git-Uzair