Repository navigation
fix(docx): read the comments part and render comments as notes (#191) - #210
Open
rahul05ranjan wants to merge 4 commits into
Open
rahul05ranjan wants to merge 4 commits into
rahul05ranjan wants to merge 4 commits into
Conversation
…rawl#191) Word's review layer was dropped whole: the comments relationship was unknown so word/comments.xml was never located, and commentReference fell through the run walker's catch-all so even the anchor position vanished. The comments part now loads through the same table-driven path as footnotes and endnotes (NoteKind::Comment), and a commentReference pushes the note reference that renders the comment as a Markdown footnote. Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
…rawl#191) Word's review layer was dropped whole: the comments relationship was unknown so word/comments.xml was never located, and commentReference fell through the run walker's catch-all so even the anchor position vanished. The comments part now loads through the same table-driven path as footnotes and endnotes (NoteKind::Comment), and a commentReference pushes the note reference that renders the comment as a Markdown footnote. Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
…rawl#191) Word's review layer was dropped whole: the comments relationship was unknown so word/comments.xml was never located, and commentReference fell through the run walker's catch-all so even the anchor position vanished. The comments part now loads through the same table-driven path as footnotes and endnotes (NoteKind::Comment), and a commentReference pushes the note reference that renders the comment as a Markdown footnote. Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
…rawl#191) Word's review layer was dropped whole: the comments relationship was unknown so word/comments.xml was never located, and commentReference fell through the run walker's catch-all so even the anchor position vanished. The comments part now loads through the same table-driven path as footnotes and endnotes (NoteKind::Comment), and a commentReference pushes the note reference that renders the comment as a Markdown footnote. Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
Author
|
Hi — this PR adds support for reading the comments part and rendering comments as notes in docx output. Ready for review whenever you have a moment 🙏 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Word's review layer —
word/comments.xml, its relationship, and thew:commentRangeStart/w:commentRangeEnd/w:commentReferenceanchors — is read and rendered as notes instead of being dropped without a trace. Fixes #191.What changed
src/package/relationships.rs: arel_type::COMMENTSconstant, so the comments relationship is locatable the same wayFOOTNOTESandENDNOTESare.src/formats/docx/mod.rs: the comments part loads through the existing table-driven note loader, as(comments_part, "comments", "comment", "c", NoteKind::Comment);typed_part_path'scomments.xmlfallback covers producers that omit the relationship. The comment's paragraphs parse with the part's own relationships, exactly like a footnote's.src/formats/docx/content.rs: a"commentReference"arm inwalk_run_contentpushes the note referencec<id>where the comment is anchored;commentRangeStart/Endstay ignored as range boundaries (they carry no content, and the commented text between them renders as normal runs).src/model/mod.rs:NoteKind::Commentdescribes the new source.comments_load_as_notes_and_render: a docx with a comment range around one word plusword/comments.xmlparses into aNoteRef("c1")inline and aNoteKind::Commentnote, and the Markdown keeps the anchored text and renders[^1]: This section needs a citation.The renderer is already note-kind-agnostic: a comment renders as a Markdown footnote definition in first-reference order, which is how a comment layer survives in Markdown.
Verification
No cargo toolchain was available where I prepared this, so no cargo run is claimed. What I did verify:
e7178e0:grep '"sym"\|"commentReference"' src/finds nothing;rel_typehas no comments entry; the note loader indocx/mod.rsiterates only footnotes and endnotes;Inline::NoteRefand the note renderer (render/markdown/mod.rs: numbering by first reference,[^n]:definitions) handle anyNoteKindwithout consulting it.FOOTNOTES→COMMENTS, the loader table row, and thecommentReferencearm besidefootnoteReference/endnoteReferencein the same match.docx_partshelper and namespace constants; its assertions were walked by hand against the loader's logic (idc1, prefixc, one comment, first-reference number 1).