fix(dxf): stop MTEXT paragraph properties leaking into engraved text - #332
fix(dxf): stop MTEXT paragraph properties leaking into engraved text#332NgoQuocViet2001 wants to merge 4 commits into
Conversation
The paragraph-break replace carried the i flag:
text = text.replace(/\P/gi, "\n")
so lowercase \p matched too. But \p is paragraph PROPERTIES, a different
command that carries a payload up to a semicolon, and p was missing from
the inline-property class on the next line. The replace consumed only
the two characters and left the rest in the text:
\pxqc;PART A -> "xqc;PART A" (want "PART A")
\pxi-2,l2,t2;Item -> "xi-2,l2,t2;Item"
Any MTEXT with a paragraph alignment or indent -- centred titles and
indented notes are the common ones -- engraved the command payload.
Make the break case-sensitive and add p to the property class. Order
already favours this: the \P replace runs first, so no uppercase \P
survives to be eaten by the property run.
|
Looks like one failing test case @NgoQuocViet2001 , can you fix that up or remove if the test case is no longer relevant? |
|
The code is right and the base is right now, thanks for the quick turnaround. One scripts/bundle/bundle-skill.sh cadRun that, commit the regenerated |
bundle.sh --check fails without this: parseDxf.js is baked into the cad skill's esbuild bundle, so the source change leaves the committed bundle stale. Regenerated with scripts/bundle/bundle-skill.sh cad. The only delta is in the minified stripMtextFormatting: /\P/gi -> /\P/g, and p added to the format-command character class.
|
Done — pushed Ran
which is exactly the source change, so nothing else in the bundle moved. Pushed as a fast-forward on top of One note in case it's useful to you: I first built the bundle against current |
parseDxf.js is baked into the dxf skill bundle as well as the cad one, so bundle.sh --check stayed red after regenerating cad alone. Same two-line delta in the minified stripMtextFormatting. scripts/bundle/bundle.sh --check now reports "All bundle outputs are up to date".
|
Correction to my last comment — regenerating
I only saw this once I reproduced the CI job properly. My first pass ran So the branch now carries two bundle commits, Verified locally at the pushed commit, clean tree: Both bundle commits sit on top of |
…aph-properties-develop
|
Branch was showing Worth re-checking rather than assuming, because Both committed bundles are still correct against the new pins, so nothing needed regenerating a second time. PR diff is unchanged at 4 files — |
Re-files #327 against
develop, per @earthtojake — that one targetedmainand edited the generated copy underskills/cad-viewer/.This one patches
packages/cadjs/src/lib/dxf/parseDxf.jsand adds the cases to the existingparseDxf.test.js.The bug
The paragraph-break replace carries the
iflag:\Pis a paragraph break. Lowercase\pis paragraph properties — a different command that carries a payload up to a semicolon (\pxqc;,\pxi-2,l2,t2;). Becausepis also absent from the inline-property class on the next line, the replace consumes only the two characters and leaves the rest in the text:Any MTEXT carrying a paragraph alignment or indent engraves the command payload. Centred titles (
\pxqc;) and indented notes are the everyday cases.The fix
Make the break case-sensitive and add
pto the property-run class:Order already works in favour of this: the
\Preplace runs first, so no uppercase\Psurvives to be eaten by the property run.Tests
Three cases appended to
parseDxf.test.js, covering the properties command, the break, and the other property runs plus plain text.Only the broken case fails on
develop— the paragraph-break and other-property tests pass either way, which is what makes the case-sensitivity change safe.The arc-sampling fix is re-filed as #331.