Skip to content

Commit

Permalink
Allows uppercase prefixes in JS number literals (#1151)
Browse files Browse the repository at this point in the history
JavaScript allows both lowercase and uppercase prefixes in number literals. With this commit, `0X`, `0B`, and `0O` are now supported as well.
  • Loading branch information
mariusschulz authored and LeaVerou committed Jul 2, 2017
1 parent 1d5047d commit d4ee904
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/prism-javascript.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Prism.languages.javascript = Prism.languages.extend('clike', {
'keyword': /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,
'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
'number': /\b-?(0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,
'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
Expand Down Expand Up @@ -45,4 +45,4 @@ if (Prism.languages.markup) {
});
}

Prism.languages.js = Prism.languages.javascript;
Prism.languages.js = Prism.languages.javascript;

0 comments on commit d4ee904

Please sign in to comment.