Skip to content

Commit

Permalink
enh(dart) add support for digit-separators (#4081)
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins authored Jul 28, 2024
1 parent bc9dfb9 commit e1fa2ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Core Grammars:
- enh(erlang) OTP 27 doc attribute [nixxquality][]
- enh(erlang) OTP 27 Sigil type [nixxquality][]
- enh(erlang) OTP25/27 maybe statement [nixxquality][]
- enh(dart) Support digit-separators in number literals [Sam Rawlins][]

New Grammars:

Expand All @@ -33,6 +34,7 @@ CONTRIBUTORS
[BaliBalo]: https://github.com/BaliBalo
[William Wilkinson]: https://github.com/wilkinson4
[nixxquality]: https://github.com/nixxquality
[srawlins]: https://github.com/srawlins


## Version 11.10.0
Expand Down
13 changes: 11 additions & 2 deletions src/languages/dart.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export default function(hljs) {
keywords: 'true false null this is new super'
};

const NUMBER = {
className: 'number',
relevance: 0,
variants: [
{ match: /\b[0-9][0-9_]*(\.[0-9][0-9_]*)?([eE][+-]?[0-9][0-9_]*)?\b/ },
{ match: /\b0[xX][0-9A-Fa-f][0-9A-Fa-f_]*\b/ }
]
};

const STRING = {
className: 'string',
variants: [
Expand Down Expand Up @@ -87,7 +96,7 @@ export default function(hljs) {
]
};
BRACED_SUBST.contains = [
hljs.C_NUMBER_MODE,
NUMBER,
STRING
];

Expand Down Expand Up @@ -248,7 +257,7 @@ export default function(hljs) {
hljs.UNDERSCORE_TITLE_MODE
]
},
hljs.C_NUMBER_MODE,
NUMBER,
{
className: 'meta',
begin: '@[A-Za-z]+'
Expand Down

0 comments on commit e1fa2ea

Please sign in to comment.