Announcing m-formatter now opensource and out of beta stadium

Mon Dec 07 2020
We are pleased to announce that our m-formatter is now completely open source under MIT License. You can check out the code in our Github repository. I did a whole rewrite of the formatter to decouple it from the ast serialization. As a result it is now much faster and more robust. Also the testing has been improved. The formatter is now also officially out of beta stadium. To give you more efficient usage of the formatter I re-implemented the code editor. It now uses which provides a much better editing experience more like an IDE than a simple textarea. The code editor parses you powerquery documents when you type. For very low spec computers this might cause lag so you can disable auto highlighting in the options.

Completion of formatting rules

Tue Oct 06 2020
I now completed implementing strategies for all Nodes that can occur in the AST but three. The missing nodes are called FieldProjection, IsNullablePrimitiveType and ListLiteral. I cannot implement a format strategy as I do not have a test case where these nodes occur. I also expanded the test bench using queries microsofts DataConnectors repo. This should make the formatter much more stable. Some more refactoring and performance optimization might be necessary in the future. Let me know if you think performance should be better.

Alignment strategies

Thu Sep 17 2020
The config property alignPairedExpressionsByEqual was deprecated in favor of two properties alignPairedLeftExpressionsByEqual and alignPairedRecordExpressionsByEqual. These two properties now control seperately the strategies used to align paired expressions in either a LetExpression scope or a RecordExpression scope. Valid strategies are "singleline", "always" and "never". "singleline" is a special strategy and the new default. It aligns the expressions if and only if all expressions in the scope are singleline and do not exceed the line length when aligned by the equal sign.

Retrieve plaintext from api

Fri Jul 03 2020
I introduced the option to retrieve just the plaintext instead of the html from the api. For it to work you can set the resultType property of the request object to "html" or "text" (this is documented in the api page). I use html2plaintext for the transformation, as the formatter always yields html. This means that you need to configure the formatter to format html properly and then set the resultType to plaintext for the conversion. Hence for it to work properly you still need to leave the whitespace config as &nbsp; and newline as <br/>.

New editor

Fri May 08 2020
I rewrote the editor today so that it provides a better experience writing code directly in the window instead of writing somewhere else and pasting it. I also introduced keyboard shortcuts for basic navigation. You can see the shortcuts for the different buttons on mouse hover.

Direct code paste and auto copy to clipboard

Wed May 06 2020
You can now paste code directly into the browser window without needing to focus to the code text area. There is also a new setting in the options pane Format on paste to window (default: false) where you can toggle auto triggering the formatter if you paste code into the window . Additionally, after every format the resulting formatted code is now automatically copied to clipboard. If you enable Format on paste to window you can format code with a single ctrl+v into your browser window and automatically have the formatted code in your clipboard. Power Query Formatter will also remember your preferred settings for future sessions.

Live preview

Tue May 05 2020
There is now a new setting in the options pane that allows you to have a live preview of the formatted code when you adjust settings such as indentation whitespace or line width.