Repository navigation
Conversation
…sh raw bookmark ids
A whole-paragraph `edit` dropped the paragraph's bookmark (`--markdown`
rebuild) or just its `<w:bookmarkEnd>` when it sat inside a rebuilt
`<w:hyperlink>` (`--text`), silently breaking every cross-reference to it
("Error! Bookmark not defined." in print). The edit now lifts the
paragraph's bookmark markers and puts them back around the new content
(outside the `<w:del>`/`<w:ins>` pair under tracking), and the `--text`
word diff restores any marker it rebuilt away.
`raw insert` split every fresh bookmark pair: `remintBookmarkIds` treated
the end marker as colliding with its own start and re-minted it. The first
sight of a free id now maps to itself, so both halves share it.
First, field-independent slice of #40.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LkctENj7B2nTmUttTgfBhs
Triage-Routine: true
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.
🤖 docx-cli triage
What was wrong
A first slice of #40: the two bookmark-integrity bugs that don't depend on the field model (#41). On
tests/fixtures/multi-column.docx, p103 holds_Ref279752219, which p37 and p93 cite:edit --at p103 "Psy. 2013. *Gangnam Style*. Video."dropped the bookmark (17 → 16 pairs).edit --at p103 --text "…"kept thebookmarkStartbut dropped thebookmarkEnd, which sat inside the rebuilt<w:hyperlink>(17 starts, 16 ends).Both exit 0 and pass
validate, but every REF to the bookmark prints "Error! Bookmark not defined."Separately,
raw insert --xml '<w:p><w:bookmarkStart w:id="100" …/>…<w:bookmarkEnd w:id="100"/></w:p>'landed as start id100and end id0.What changed
src/core/bookmarks/markers.ts. It lifts a paragraph's bookmark markers (direct children, or inside run-bearing wrappers) and restores them: a start goes right after<w:pPr>, an end after the last child. It keeps the original nodes, so every attribute survives.Edit.paragraph(single and batch,--markdown/--runs/--textrebuild):<w:del>/<w:ins>, so both accept and reject keep the bookmark.--textword-diff path, markers that survived stay where they are, and only casualties come back at the paragraph boundary.remintBookmarkIds(src/core/raw/references.ts): the first time it sees a free id, it records an identity mapping, so the end marker reuses its start's id.tests/cli/edit-bookmarks.test.ts(6 tests) and one raw-gate test. The 4 untracked edit tests and the raw test fail onmain.Verification
e1 starts=16 ends=16,e2 starts=17 ends=16. After: all 17/17, withw:id="13"paired on p103. This holds for untracked,--track+ accept, and--track+ reject, andvalidatepasses on all of them.w:id="100".bun run check✅bun run test:unit✅ (2098 tests)Decisions for you
Part of #40 (not a full fix; the issue stays open).
Generated by Claude Code