mirror of
https://github.com/beautifier/js-beautify.git
synced 2024-11-26 22:20:56 +00:00
parent
3d3bbf2333
commit
f6ed35d9c7
@ -35,12 +35,12 @@ var nonASCIIidentifierChars = "\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u0
|
||||
//var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
||||
//var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
||||
|
||||
var identifierStart = "[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "]";
|
||||
var identifierChars = "[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]*";
|
||||
var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
|
||||
var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
|
||||
|
||||
exports.identifier = new RegExp(identifierStart + identifierChars, 'g');
|
||||
exports.identifierStart = new RegExp(identifierStart);
|
||||
exports.identifierMatch = new RegExp("[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]+");
|
||||
exports.identifierMatch = new RegExp("(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
|
||||
|
||||
var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; // jshint ignore:line
|
||||
|
||||
|
@ -350,6 +350,14 @@ function run_javascript_tests(test_obj, Urlencoded, js_beautify, html_beautify,
|
||||
'var ' + unicode_char(228) + 'x = {\n' +
|
||||
' ' + unicode_char(228) + 'rgerlich: true\n' +
|
||||
'};');
|
||||
bt(
|
||||
'var \\u00E4\\u0ca0\\u0cA0\\u0Ca0 = {\n' +
|
||||
' \\u0ca0rgerlich: true\n' +
|
||||
'};');
|
||||
bt(
|
||||
'var \\u00E4add\\u0025 = {\n' +
|
||||
' \\u0044rgerlich\\u0ca0: true\n' +
|
||||
'};');
|
||||
bt(
|
||||
'var' + unicode_char(160) + unicode_char(3232) + '_' + unicode_char(3232) + ' = "hi";',
|
||||
// -- output --
|
||||
|
41
package-lock.json
generated
41
package-lock.json
generated
@ -2014,7 +2014,8 @@
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@ -2035,12 +2036,14 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@ -2055,17 +2058,20 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -2182,7 +2188,8 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@ -2194,6 +2201,7 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -2208,6 +2216,7 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@ -2215,12 +2224,14 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.3.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.0"
|
||||
@ -2239,6 +2250,7 @@
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@ -2319,7 +2331,8 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@ -2331,6 +2344,7 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -2416,7 +2430,8 @@
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
@ -2452,6 +2467,7 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@ -2471,6 +2487,7 @@
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
@ -2514,12 +2531,14 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -39,24 +39,24 @@ _nonASCIIidentifierChars = six.u(r"\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf
|
||||
#_nonASCIIidentifierStart = re.compile("[" + _nonASCIIidentifierStartChars + "]")
|
||||
#_nonASCIIidentifier = re.compile("[" + _nonASCIIidentifierStartChars + _nonASCIIidentifierChars + "]")
|
||||
|
||||
_identifierStart = six.u("[") + \
|
||||
_identifierStart = six.u(r"(?:\\u[0-9a-fA-F]{4}|[") + \
|
||||
_baseASCIIidentifierStartChars + \
|
||||
_nonASCIIidentifierStartChars + \
|
||||
six.u("]")
|
||||
_identifierChars = six.u("[") + \
|
||||
six.u("])")
|
||||
_identifierChars = six.u(r"(?:\\u[0-9a-fA-F]{4}|[") + \
|
||||
_baseASCIIidentifierChars + \
|
||||
_nonASCIIidentifierStartChars + \
|
||||
_nonASCIIidentifierChars + \
|
||||
six.u("]*")
|
||||
six.u("])*")
|
||||
|
||||
identifier = re.compile(_identifierStart + _identifierChars)
|
||||
|
||||
identifierStart = re.compile(_identifierStart)
|
||||
identifierMatch = re.compile(six.u("[") + \
|
||||
identifierMatch = re.compile(six.u(r"(?:\\u[0-9a-fA-F]{4}|[") + \
|
||||
_baseASCIIidentifierChars + \
|
||||
_nonASCIIidentifierStartChars + \
|
||||
_nonASCIIidentifierChars + \
|
||||
six.u("]+"))
|
||||
six.u("])+"))
|
||||
|
||||
_nonASCIIwhitespace = re.compile(
|
||||
six.u(r"[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]"))
|
||||
|
@ -158,6 +158,14 @@ class TestJSBeautifier(unittest.TestCase):
|
||||
'var ' + unicode_char(228) + 'x = {\n' +
|
||||
' ' + unicode_char(228) + 'rgerlich: true\n' +
|
||||
'};')
|
||||
bt(
|
||||
'var \\u00E4\\u0ca0\\u0cA0\\u0Ca0 = {\n' +
|
||||
' \\u0ca0rgerlich: true\n' +
|
||||
'};')
|
||||
bt(
|
||||
'var \\u00E4add\\u0025 = {\n' +
|
||||
' \\u0044rgerlich\\u0ca0: true\n' +
|
||||
'};')
|
||||
bt(
|
||||
'var' + unicode_char(160) + unicode_char(3232) + '_' + unicode_char(3232) + ' = "hi";',
|
||||
# -- output --
|
||||
|
@ -44,6 +44,18 @@ exports.test_data = {
|
||||
" ' + unicode_char(228) + 'rgerlich: true",
|
||||
"};"
|
||||
]
|
||||
}, {
|
||||
unchanged: [
|
||||
"var \\\\u00E4\\\\u0ca0\\\\u0cA0\\\\u0Ca0 = {",
|
||||
" \\\\u0ca0rgerlich: true",
|
||||
"};"
|
||||
]
|
||||
}, {
|
||||
unchanged: [
|
||||
"var \\\\u00E4add\\\\u0025 = {",
|
||||
" \\\\u0044rgerlich\\\\u0ca0: true",
|
||||
"};"
|
||||
]
|
||||
}, {
|
||||
input_: "var' + unicode_char(160) + unicode_char(3232) + '_' + unicode_char(3232) + ' = \"hi\";",
|
||||
output: "var ' + unicode_char(3232) + '_' + unicode_char(3232) + ' = \"hi\";"
|
||||
|
Loading…
Reference in New Issue
Block a user