Repository navigation
Conversation
A Word display block holding several <m:oMath> lines inside one
<m:oMathPara> read as its first line only: read showed `$x=1$` while the
block also held `y=2`, and a tracked `equations edit` then deleted the
line the agent never saw.
- ommlToLatex reads such a block as \begin{gathered}x=1\y=2\end{gathered}.
- latexToOmml splits that form (top-level \ only, not a matrix row) back
into one <m:oMath> per line, so read -> edit -> read keeps the lines.
|
🤖 docx-cli triage Thanks @xsvm — this is a real bug and the fix is sound. Review of What the PR claimsIf an Before / afterThe test doc is
Problems found and fixed locally (commit
|
… real tracked test
- gatheredLines skips a break's own `*` and `[4pt]` option (reusing
findMatchingBracket) instead of writing it into the next line as text.
- The reader prefixes `{}` to a line that opens with `[` or `*`, so
read -> edit doesn't take it for the break's option.
- The tracked-edit test checks the markers: <w:del> holds both old lines,
<w:ins> both new ones (read --accepted/--baseline don't filter tracked
equations yet, so the old toContain checks passed either way).
- equations.docx gains a "Multi-line block (display)" entry so the
multi-<m:oMath> shape round-trips through LibreOffice.
Follows the triage review on kklimuk#30.
|
Thanks for the review. I reproduced every item on
I checked that both new tests fail with the src change reverted. The two pre-existing issues you raised ( |
|
🤖 docx-cli triage Thanks @xsvm. I re-reviewed Prior review items: all addressed
Before / after (on
|
origin/main |
PR | |
|---|---|---|
read |
$$x=1$$ (y=2 is hidden) |
$$\begin{gathered}x=1\\y=2\end{gathered}$$ |
equations add --display '\begin{gathered}a\\b\end{gathered}' |
1 <m:oMath>, reads back as aligned |
2 <m:oMath>, reads back as gathered |
inline equations add with the same LaTeX |
1 <m:oMath> (aligned) |
unchanged |
Other edge cases that work: a \\ inside \text{…} or \left\{…\right., a matrix row inside a line, leading or trailing whitespace, and 3 or more lines. A trailing \\ with nothing after it stays one line. Two gathered blocks side by side aren't split.
bun run check ✅. bun run test:unit ✅ (1915 pass). The first run had one flaky failure that I couldn't reproduce. It passed on the rerun, and no PR test was involved.
Optional nit (not blocking)
\begin{gathered}a\\ [4pt]b\end{gathered} (with a space before [) keeps [4pt]b as line content, and it reads back as a\\{}[4pt]b. You pointed out that LaTeX's \\ skips spaces before [, so gatheredLines could skip whitespace before checking for */[. This is safe because the reader already writes {} before a line that starts with [. Agents rarely write this, and the text stays visible on read, so it's fine as a follow-up.
Open questions for the maintainer
- Is the change wanted? No issue asked for it, but it fixes silent data loss on Word multi-line equations. I'd say yes.
- Behavior change: an agent-authored display
\begin{gathered}…\\…\end{gathered}now becomes separate<m:oMath>lines instead of one eqArr. This is closer to Word, and it now round-trips asgatheredinstead ofaligned. Inline equations are unchanged. - Pre-existing, outside this PR:
readprints a display equation as$$…$$on one line, soread → createparses it as inline math (andgatheredbecomesaligned). Also,read --accepted/--baselinedon't filter tracked equations. @xsvm offered to open issues for both.
Action needed: approve/merge — PR #30 is ready. I didn't push, so the contributor made the last push and your own approval satisfies the last-push rule. Also answer the questions above, and whether you want issues for the two pre-existing bugs.
Generated by Claude Code
|
@xsvm hold off from making further changes till i've had a bit of time to read through and do my own reviews, it's gonna take me a few days. |
Summary
A display equation block that holds several lines, Word's
<m:oMathPara>with more than one<m:oMath>, read as its first line only:readshowed$$x=1$$; theEquationRun'slatexwasx=1while itstextwasx=1y=2.equations edit --at eq0 --equation "x=3" --trackreplaced the whole block, so they=2line was tracked as deleted although the agent never saw it.The fix
ommlToLatexreads such a block as\begin{gathered}x=1\\y=2\end{gathered}, soread,--astand Markdown show every line.latexToOmmlturns that form back into one<m:oMath>per line, so read → edit → read keeps Word's line structure. Only a top-level\\splits; a\\inside braces or an inner environment (a matrix row) does not.eqNper block, so locators don't shift.src/core/equation/CLAUDE.md.Doesn't touch
ast/read.ts; #27 changes other lines ofequation/read.ts, so the two should merge cleanly.Test plan
bunx biome check .,bunx knip,bunx tsc --noEmittests/cli/equations.test.ts: read shows every line, edit round-trip, tracked edit (old block in--baseline, new lines in--accepted), a matrix inside one line stays one linetests/cli/equations.test.tspasses (51 tests)