Skip to content

Commit

Permalink
Add syntax highlighting support for numeric separators
Browse files Browse the repository at this point in the history
This applies @RunDevelopment’s patch from PrismJS/prism#1895. It can be removed once a new prism-js release is published to npm.

Closes #182.
  • Loading branch information
mathiasbynens committed May 19, 2019
1 parent 24989b5 commit 50078bd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions prism-languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

const installPrismLanguages = (Prism) => {

// Add support for numeric separators.
// TODO: Remove this once a `prism-js` version containing
// https://github.com/PrismJS/prism/pull/1895 is released.
Prism.languages.javascript.number = /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/;

// Based on the grammar defined at the bottom of:
// https://cs.chromium.org/chromium/src/v8/src/torque/torque-parser.cc
Prism.languages.torque = {
Expand Down

0 comments on commit 50078bd

Please sign in to comment.