Repository navigation
Conversation
…tes nothing on refusal `create --from page.html` exited 0 with an empty document: CommonMark swallows a line opening with a block tag into one opaque html node, and the importer dropped it with its prose. The walker now refuses a block html node whose markup carries visible text (USAGE, exit 2) — comments (every read hint) and tag-only wrappers still drop silently. Applies to every markdown ingress (create --from, insert/edit --markdown, notes). `create` now builds in memory over Document.fromPackage and saves once, so any refused source writes nothing and an existing FILE under --force survives. Fixes #61 Triage-Routine: true Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LkctEPJa5FWBzPoeq7imqE
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
printf '<h1>Title</h1><p>Body</p>' > p.html; docx create h.docx --from p.htmlprintedcreate h.docx, exited 0, andreadshowed no paragraphs. CommonMark treats a line that opens with a block tag (<h1>,<p>,<div>,<table>, …) as one raw HTML block running to the next blank line. The importer then dropped that block along with the text inside it. The same thing happened to<div>/<table>blocks inside ordinary Markdown.What changed
core/markdown/walker.tsx: an HTML block that contains visible text is now refused withUSAGE(exit 2). The error names the line and shows a preview of the text that would be lost. The hint tells the agent to rewrite the content as Markdown.<!-- … -->comments (everyreadhint) and tag-only wrappers (a README's<div align="center">around real Markdown) still drop silently. Inline tags inside a paragraph are unaffected. The guard applies to every Markdown ingress:create --from,insert/edit --markdown, and note bodies.cli/create:createnow runs content, geometry and header/footer changes on one in-memory document (Document.fromPackage) and saves once. Before, it saved a blank file and then reopened it for each step. Now any refused source (block HTML, a bad image) writes nothing, and an existing FILE overwritten with--forcesurvives a failed create.create --help,core/markdown/CLAUDE.md. Tests are increate.test.tsandinsert.test.ts. One HEIC test inimages.test.tsasserted that a blank file was left behind; it now asserts that no file is written.Verification
readof a document whose text contains literal<div>hi</div>emits\<div\>…, so a round trip ofreadoutput back throughcreate --fromstill exits 0.create --from ok.md --page-numbers --margins 1.5 --header Hi --size a4through the single-save path, thenread+validate: the output is valid and the header, footer, page settings and footnote are all present.bun run check✅bun run test:unit✅ (2104 tests)Decisions for you
h1–h6,p,ul/ol/li,table,br) into OOXML, so an HTML page imports instead of failing. That means more surface to maintain, and anything we can't convert would still need this guard.insert/edit --markdownand note bodies as well ascreate. Content that used to be dropped silently now fails with exit 2. I think this is the right behaviour under "a mutation that changes nothing is an error", but it is a behaviour change.Fixes #61
Action needed: approve/merge — review PR #65 and tick the two decisions above (refuse vs. convert; refusal on insert/edit too).
Generated by Claude Code