Skip to content

Add XML Tools > Pretty Print XML to the Edit menu#1096

Open
SamJaarsma wants to merge 1 commit into
dail8859:masterfrom
SamJaarsma:feature/xml-tools-pretty-print
Open

Add XML Tools > Pretty Print XML to the Edit menu#1096
SamJaarsma wants to merge 1 commit into
dail8859:masterfrom
SamJaarsma:feature/xml-tools-pretty-print

Conversation

@SamJaarsma

@SamJaarsma SamJaarsma commented Jul 24, 2026

Copy link
Copy Markdown

Adds an "XML Tools" submenu under Edit with a single "Pretty Print XML" action, reformatting the whole document equivalently to xmllint --format.

Implementation notes

Uses QXmlStreamReader/QXmlStreamWriter from Qt6::Core rather than QDomDocument, to avoid adding a Qt6::Xml dependency.
Follows the ScintillaSorter pattern for reading/writing the buffer, wrapped in UndoAction so the transform is a single undo step.
Malformed input shows a warning with line/column and leaves the buffer untouched.

Scope choices

Placed under Edit rather than View since it mutates the buffer, consistent with Convert Case and Line Operations.
Operates on the whole document rather than the selection, matching xmllint --format. Selection support would be a reasonable follow-up.

Known divergence from xmllint: QXmlStreamWriter normalises attribute quoting and always emits a UTF-8 declaration.

The macOS job passes on Qt 6.10 and fails only on 6.5 and 6.8, which suggests the AGL reference comes from Qt's own CMake config and was dropped upstream between 6.8 and 6.10. That would make this a Qt-version issue in CI rather than anything in this diff.

Adds an XmlFormatter that reformats XML using QXmlStreamReader/
QXmlStreamWriter auto-formatting, similar to xmllint --format, without
pulling in a Qt6::Xml dependency.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant