Add XML Tools > Pretty Print XML to the Edit menu#1096
Open
SamJaarsma wants to merge 1 commit into
Open
Conversation
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>
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.
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.