Skip to content

Commit 15a7380

Browse files
committed
Add qml support
Resolve: #1754
1 parent a5485f7 commit 15a7380

File tree

6 files changed

+11
-2
lines changed

6 files changed

+11
-2
lines changed

js/src/cli.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ var path = require('path'),
8888
"wrap_attributes": ["auto", "force", "force-aligned", "force-expand-multiline", "aligned-multiple", "preserve", "preserve-aligned"],
8989
"wrap_attributes_indent_size": Number,
9090
"e4x": Boolean,
91+
"qml": Boolean,
9192
"end_with_newline": Boolean,
9293
"comma_first": Boolean,
9394
"operator_position": ["before-newline", "after-newline", "preserve-newline"],
@@ -371,6 +372,7 @@ function usage(err) {
371372
msg.push(' -x, --unescape-strings Decode printable characters encoded in xNN notation');
372373
msg.push(' -w, --wrap-line-length Wrap lines that exceed N characters [0]');
373374
msg.push(' -X, --e4x Pass E4X xml literals through untouched');
375+
msg.push(' --qml Add Qml support');
374376
msg.push(' --good-stuff Warm the cockles of Crockford\'s heart');
375377
msg.push(' -C, --comma-first Put commas at the beginning of new line instead of end');
376378
msg.push(' -O, --operator-position Set operator position (before-newline|after-newline|preserve-newline) [before-newline]');
@@ -689,4 +691,4 @@ function logToStdout(str, config) {
689691
if (typeof config.quiet === "undefined" || !config.quiet) {
690692
console.log(str);
691693
}
692-
}
694+
}

js/src/javascript/beautifier.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ Beautifier.prototype.handle_word = function(current_token) {
974974
}
975975

976976
if (reserved_array(current_token, line_starters) && this._flags.last_token.text !== ')') {
977-
if (this._flags.inline_frame || this._flags.last_token.text === 'else' || this._flags.last_token.text === 'export') {
977+
if (this._flags.inline_frame || this._flags.last_token.text === 'else' || this._flags.last_token.text === 'export' || (this._options.qml && this._flags.last_token.text === 'property')) {
978978
prefix = 'SPACE';
979979
} else {
980980
prefix = 'NEWLINE';

js/src/javascript/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function Options(options) {
7474
this.space_before_conditional = this._get_boolean('space_before_conditional', true);
7575
this.unescape_strings = this._get_boolean('unescape_strings');
7676
this.e4x = this._get_boolean('e4x');
77+
this.qml = this._get_boolean('qml');
7778
this.comma_first = this._get_boolean('comma_first');
7879
this.operator_position = this._get_selection('operator_position', validPositionValues);
7980

python/jsbeautifier/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def usage(stream=sys.stdout):
124124
-f, --keep-function-indentation Do not re-indent function bodies defined in var lines.
125125
-x, --unescape-strings Decode printable chars encoded in \\xNN notation.
126126
-X, --e4x Pass E4X xml literals through untouched
127+
--qml Add QML support
127128
-C, --comma-first Put commas at the beginning of new line instead of end.
128129
-m,
129130
--max-preserve-newlines=NUMBER Number of line-breaks to be preserved in one chunk (default 10)
@@ -186,6 +187,7 @@ def main():
186187
"operator-position=",
187188
"outfile=",
188189
"quiet",
190+
"qml",
189191
"replace",
190192
"space-after-anon-function",
191193
"space-after-named-function",
@@ -254,6 +256,8 @@ def main():
254256
js_options.unescape_strings = True
255257
elif opt in ("--e4x", "-X"):
256258
js_options.e4x = True
259+
elif opt in ("--qml",):
260+
js_options.qml = True
257261
elif opt in ("--end-with-newline", "-n"):
258262
js_options.end_with_newline = True
259263
elif opt in ("--comma-first", "-C"):

python/jsbeautifier/javascript/beautifier.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ def handle_word(self, current_token):
10931093
self._flags.inline_frame
10941094
or self._flags.last_token.text == "else "
10951095
or self._flags.last_token.text == "export"
1096+
or (self._options.qml and self._flags.last_token.text == "property")
10961097
):
10971098
prefix = "SPACE"
10981099
else:

python/jsbeautifier/javascript/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def __init__(self, options=None):
8686
)
8787
self.unescape_strings = self._get_boolean("unescape_strings")
8888
self.e4x = self._get_boolean("e4x")
89+
self.qml = self._get_boolean("qml")
8990
self.comma_first = self._get_boolean("comma_first")
9091
self.operator_position = self._get_selection(
9192
"operator_position", OPERATOR_POSITION

0 commit comments

Comments
 (0)