Skip to content

Fix MTEXT paragraph property codes leaking into plain text - #83

Merged
mahach666 merged 2 commits into
IOExtend:mainfrom
gryaznulka:fix/mtext-paragraph-formatting
Dec 6, 2026
Merged

mahach666 merged 2 commits into
IOExtend:mainfrom
gryaznulka:fix/mtext-paragraph-formatting

Conversation

@gryaznulka

Copy link
Copy Markdown
Contributor

What changes and why

MTEXT uses uppercase \P for a paragraph break and lowercase \p...; for paragraph formatting (indentation, alignment and tabs). The latter currently inserts a newline and leaves the formatting arguments visible in plain text, including scene annotations.

This change strips terminated paragraph properties without introducing an extra newline. If the terminator is missing before another formatting command, group or line break, the literal code is preserved rather than swallowing the following text. Raw Text is unchanged.

How it was checked

  • Added five cases covering documented paragraph properties, actual line breaks, CAD Unicode escapes, escaped literals, and an unterminated command. Each verifies the raw string, PlainText and scene annotation.

  • On base 56db8485, three cases failed and two passed on both .NET 8 and .NET 10.

  • After the fix: dotnet test tests/DwgIO.Tests/DwgIO.Tests.csproj -c Release --no-restore -m:1 passed 314 tests per framework (3 skipped each). No native AutoCAD run or before/after drawing-wide JSON/inspect comparison was performed; the intended output difference is the corrected plain annotation text.

  • dotnet build DwgIO.slnx -c Release has no warnings (solution-wide build not run separately)

  • dotnet test passes

  • JSON exports and dwgio inspect output of the same drawings before and after are identical, or the differences are listed and intended

  • The change is original work; no code or text is copied from other projects

  • No drawings, customer data, vendor code or binaries are added

Reference: Autodesk developer blog: MTEXT formatting codes.

@mahach666
mahach666 merged commit 87f8678 into IOExtend:main Dec 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants