diff --git a/components/prism-json.js b/components/prism-json.js index 06e847ec60..3ac9be1b4f 100644 --- a/components/prism-json.js +++ b/components/prism-json.js @@ -4,8 +4,8 @@ Prism.languages.json = { pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/, greedy: true }, - 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, - 'punctuation': /[{}[\]);,]/, + 'number': /-?\d+\.?\d*([Ee][+-]?\d+)?/, + 'punctuation': /[{}[\],]/, 'operator': /:/g, 'boolean': /\b(?:true|false)\b/i, 'null': /\bnull\b/i diff --git a/components/prism-json.min.js b/components/prism-json.min.js index bf24e77916..e4206fa384 100644 --- a/components/prism-json.min.js +++ b/components/prism-json.min.js @@ -1 +1 @@ -Prism.languages.json={property:/"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,string:{pattern:/"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,greedy:!0},number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,punctuation:/[{}[\]);,]/,operator:/:/g,"boolean":/\b(?:true|false)\b/i,"null":/\bnull\b/i},Prism.languages.jsonp=Prism.languages.json; \ No newline at end of file +Prism.languages.json={property:/"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,string:{pattern:/"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,greedy:!0},number:/-?\d+\.?\d*([Ee][+-]?\d+)?/,punctuation:/[{}[\],]/,operator:/:/g,"boolean":/\b(?:true|false)\b/i,"null":/\bnull\b/i},Prism.languages.jsonp=Prism.languages.json; \ No newline at end of file diff --git a/tests/languages/json/number_feature.test b/tests/languages/json/number_feature.test index ba045ec3d4..ca87a480d5 100644 --- a/tests/languages/json/number_feature.test +++ b/tests/languages/json/number_feature.test @@ -4,6 +4,9 @@ 5.0e8 0.2E+2 47e-5 +-1.23 +-2.34E33 +-4.34E-33 ---------------------------------------------------- @@ -13,9 +16,12 @@ ["number", "3.14159"], ["number", "5.0e8"], ["number", "0.2E+2"], - ["number", "47e-5"] + ["number", "47e-5"], + ["number", "-1.23"], + ["number", "-2.34E33"], + ["number", "-4.34E-33"] ] ---------------------------------------------------- -Checks for numbers. \ No newline at end of file +Checks for numbers. diff --git a/tests/languages/json/operator_feature.test b/tests/languages/json/operator_feature.test new file mode 100644 index 0000000000..9d30b2e5e6 --- /dev/null +++ b/tests/languages/json/operator_feature.test @@ -0,0 +1,11 @@ +: + +---------------------------------------------------- + +[ + ["operator", ":"] +] + +---------------------------------------------------- + +Checks for all operators. diff --git a/tests/languages/json/punctuation_feature.test b/tests/languages/json/punctuation_feature.test new file mode 100644 index 0000000000..b8e351cd8e --- /dev/null +++ b/tests/languages/json/punctuation_feature.test @@ -0,0 +1,20 @@ +{} +{ } +[] +], +}, +, + +---------------------------------------------------- + +[ + ["punctuation", "{"], ["punctuation", "}"], + ["punctuation", "{"], ["punctuation", "}"], + ["punctuation", "["], ["punctuation", "]"], + ["punctuation", "]"], ["punctuation", ","], + ["punctuation", "}"], ["punctuation", ","], + ["punctuation", ","] +] +---------------------------------------------------- + +Checks for punctuation. diff --git a/tests/languages/json/string_feature.test b/tests/languages/json/string_feature.test index 08ac8c06f7..8dddae58fb 100644 --- a/tests/languages/json/string_feature.test +++ b/tests/languages/json/string_feature.test @@ -24,4 +24,4 @@ ---------------------------------------------------- -Checks for strings. \ No newline at end of file +Checks for strings.