From ce14a42c2c791694ed99c26c317373419cad88be Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 22 Jul 2024 20:30:58 -0700 Subject: [PATCH 1/3] Update Dart for digit-separators feature --- src/languages/dart.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/languages/dart.js b/src/languages/dart.js index 2b801255e4..d7a2065516 100644 --- a/src/languages/dart.js +++ b/src/languages/dart.js @@ -25,6 +25,15 @@ export default function(hljs) { keywords: 'true false null this is new super' }; + const NUMBER = { + className: 'number', + relevance: 0, + variants: [ + { begin: "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?([eE][+-]?[0-9][0-9_]*)?\\b" }, + { begin: "\\b0[xX][0-9A-Fa-f][0-9A-Fa-f_]*\\b" } + ] + }; + const STRING = { className: 'string', variants: [ @@ -87,7 +96,7 @@ export default function(hljs) { ] }; BRACED_SUBST.contains = [ - hljs.C_NUMBER_MODE, + NUMBER, STRING ]; @@ -248,7 +257,7 @@ export default function(hljs) { hljs.UNDERSCORE_TITLE_MODE ] }, - hljs.C_NUMBER_MODE, + NUMBER, { className: 'meta', begin: '@[A-Za-z]+' From 0ad4bf9c2accb5aba227f3de6f4cde7a6aa494fe Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 22 Jul 2024 20:39:43 -0700 Subject: [PATCH 2/3] changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index d84c96801a..7363f1b07a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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: From 12d034fdabace20a22fdd20e2437a4f90c995379 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Wed, 24 Jul 2024 09:57:31 -0700 Subject: [PATCH 3/3] feedback --- CHANGES.md | 1 + src/languages/dart.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7363f1b07a..8b1b9d3dc4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -34,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 diff --git a/src/languages/dart.js b/src/languages/dart.js index d7a2065516..32e4b43b2a 100644 --- a/src/languages/dart.js +++ b/src/languages/dart.js @@ -29,8 +29,8 @@ export default function(hljs) { className: 'number', relevance: 0, variants: [ - { begin: "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?([eE][+-]?[0-9][0-9_]*)?\\b" }, - { begin: "\\b0[xX][0-9A-Fa-f][0-9A-Fa-f_]*\\b" } + { 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/ } ] };