Skip to content
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

[json] Fix numbers to include negative numbers #1479

Merged
merged 1 commit into from
Jul 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/prism-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/prism-json.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions tests/languages/json/number_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
5.0e8
0.2E+2
47e-5
-1.23
-2.34E33
-4.34E-33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with the +?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a git diff, saying those lines were added :D

Copy link
Member

@RunDevelopment RunDevelopment Jul 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... Oops.
My bad


----------------------------------------------------

Expand All @@ -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.
Checks for numbers.
11 changes: 11 additions & 0 deletions tests/languages/json/operator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:

----------------------------------------------------

[
["operator", ":"]
]

----------------------------------------------------

Checks for all operators.
20 changes: 20 additions & 0 deletions tests/languages/json/punctuation_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{}
{ }
[]
],
},
,

----------------------------------------------------

[
["punctuation", "{"], ["punctuation", "}"],
["punctuation", "{"], ["punctuation", "}"],
["punctuation", "["], ["punctuation", "]"],
["punctuation", "]"], ["punctuation", ","],
["punctuation", "}"], ["punctuation", ","],
["punctuation", ","]
]
----------------------------------------------------

Checks for punctuation.
2 changes: 1 addition & 1 deletion tests/languages/json/string_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

----------------------------------------------------

Checks for strings.
Checks for strings.