-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow jsBeautify to be used for XML #369
Comments
Could you provide a code sample that you believe to be in error so that I may work on improving this for you? Pretty Diff was chosen over jsBeautify because jsBeautify uses an HTML parser to provide incomplete support for XML. Officially, jsBeautify project does not support XML at all, though it sounds like they are working on this. The incomplete and hacky support for XML made it difficult to extend base XML support for various edge cases, templating schemes, and particuarly React JSX format. The straw that broke the camel's back for this project was an internationalization issue. It is important to note that jsBeautify now provides for React JSX using a ES4X library to provide some JavaScript to XML conformance. Both projects based their support off this document that I assembled: https://github.com/prettydiff/prettydiff/blob/master/unit_tests/beautification_javascript_jsx.txt The Pretty Diff approach is to provide a base markup parser then apply different rules for various different language formats. The Pretty Diff approach is not necessarily better or more stable but is certainly more extensible. |
Thanks for the detailed answer! <foo xmlns:ns1="ns1"
xmlns:ns2="ns2"
xmlns:ns3="ns3" /> ...which can be easier to work with. It also allows the attribute indent size to be set separately to the standard indent. I'm not sure whether I prefer the first attribute appearing on the same line as the tag name. I got used to it recently when using atom-beautifier/jsBeautifier, but the pretty printer I have previously used also put the first attribute on a separate line. |
Since this issue is add XML language to JS-Beautify beautifier, here are instructions for what would need to be done and submitted in a Pull Request. It's very straight forward:
I will accept a pull request with the above implemented. Thanks! |
Published to v0.28.1 |
Beautification of XML used to use jsBeautify and it worked OK (apart from beautifier/js-beautify#683), in particular it has better options (then PrettyDiff) for attribute wrapping etc. Could it be made a settings option again.
The text was updated successfully, but these errors were encountered: