Conversation
Word writes every modern shape and text box as <mc:AlternateContent> with a wps <mc:Choice> and a legacy <w:pict> <mc:Fallback>. Neither tag is matched by readRun or walkRunContainer, so the whole subtree is dropped before it reaches the AST -- including the ChartRun placeholder the reader intends to emit. Resolve the wrapper to its Choice branch (Fallback when a producer wrote only that) in both walkers. The placeholder contract already held for the branch almost nobody writes; this makes it hold for the one Word always writes. Refs kklimuk#4 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JsWGQLZuWdd5aksp63VeVM
Owner
|
@Ryujiyasu I've pushed a commit and a new version that solves your problem. |
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.
Fixes the reader half of #4.
Word writes every modern shape and text box as
<mc:AlternateContent>— awps<mc:Choice>holding the<w:drawing>, beside an<mc:Fallback>holding a legacy<w:pict>. Neither tag is matched byreadRunorwalkRunContainer, so the whole subtree is dropped before it reaches the AST, including theChartRunplaceholder the reader intends to emit ("surface as ChartRun placeholders so callers know 'something visual lives here'").The placeholder contract already held for the branch almost nobody writes — strip a document to its
mc:Fallbackandreadprints`[drawing]`— and was missed for the one Word always writes. This makes it hold for both.What this is and is not
This is option (a) from the issue: it removes the silent part. An agent can now see that a shape is there and reach for
raw. It does not make the text inside a text box readable —docx find tests/fixtures/multi-column.docx "Permission to make digital"still returnsno matches, because that needsw:txbxContentparagraphs to become addressable blocks, and a text box is a separate story like a header, so it needs a locator decision that is yours to make. Happy to do that too if you tell me what shape you want the locators to take.Shape of the change
One helper plus one call site in each of the two walkers — 26 lines.
resolveAlternateContentreturns its input unchanged when there is no wrapper, which is the overwhelmingly common case, so the hot path is oneArray.someover a run's children.Choice is preferred over Fallback because it is what Word itself reads; Fallback is taken when a producer wrote only that.
Tests
Four cases in
tests/core/ast/read.test.ts, all against synthetic XML so they need no new fixture: a Choice branch reaching the run walker, a Fallback-only wrapper, Choice winning when both are present (taking the wrong branch is silent, so it is worth pinning), and text either side of a wrapper coming through untouched.bun run checkpasses.bun test tests/core tests/cligives 1625 pass; the three failures on my machine (docx info skillSKILL.md sync, the compiled-binaryupgradetest, and the LibreOffice integration test) fail identically on unpatchedmainhere — nosoffice, no compiled binary. I skipped the pre-commit hook for that reason; CI should have a better environment than mine.Windows 11, bun 1.4.0.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JsWGQLZuWdd5aksp63VeVM