Skip to content

Commit 4d386f8

Browse files
authored
fix(csharp) Support digit separators(#4258) (#4280)
1 parent f661c55 commit 4d386f8

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Core Grammars:
2222
- fix(diff) fix unified diff hunk header regex to allow unpaired numbers [Chris Wilson][]
2323
- enh(php) support single line and hash comments in attributes, constructor and functions [Antoine Musso][]
2424
- enh(json) add json5 support [Kerry Shetline][]
25+
- fix(csharp) Support digit separators [te-ing][]
2526

2627
Documentation:
2728

@@ -47,6 +48,7 @@ CONTRIBUTORS
4748
[Kerry Shetline]: https://github.com/kshetline
4849
[Twineee1]: https://github.com/Twineee1
4950
[hbgl]: https://github.com/hbgl
51+
[te-ing]: https://github.com/te-ing
5052
[Anthony Martin]: https://github.com/anthony-c-martin
5153

5254

src/languages/csharp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export default function(hljs) {
166166
variants: [
167167
{ begin: '\\b(0b[01\']+)' },
168168
{ begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)(u|U|l|L|ul|UL|f|F|b|B)' },
169-
{ begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)' }
169+
{ begin: '(-?)(\\b0[xX][a-fA-F0-9\'_]+|(\\b[\\d\'_]+(\\.[\\d\'_]*)?|\\.[\\d\'_]+)([eE][-+]?[\\d\'_]+)?)' }
170170
],
171171
relevance: 0
172172
};

test/markup/csharp/floats.expect.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<span class="hljs-built_in">float</span> test = <span class="hljs-number">1.0f</span>;
22
<span class="hljs-built_in">float</span> test2 = <span class="hljs-number">1.f</span>;
33
<span class="hljs-built_in">float</span> test3 = <span class="hljs-number">1.0</span>;
4-
<span class="hljs-built_in">float</span> test4 = <span class="hljs-number">1</span>;
4+
<span class="hljs-built_in">float</span> test4 = <span class="hljs-number">1</span>;
5+
<span class="hljs-built_in">float</span> test5 = <span class="hljs-number">1_000</span>;
6+

test/markup/csharp/floats.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
float test = 1.0f;
22
float test2 = 1.f;
33
float test3 = 1.0;
4-
float test4 = 1;
4+
float test4 = 1;
5+
float test5 = 1_000;

0 commit comments

Comments
 (0)