Skip to content

Commit dafdbde

Browse files
authoredNov 22, 2021
D: Added standard char token (#3196)
1 parent 1c88c7d commit dafdbde

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed
 

‎components/prism-d.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ Prism.languages.d = Prism.languages.extend('clike', {
3737
// eslint-disable-next-line regexp/strict
3838
/\bq"(.)[\s\S]*?\2"/.source,
3939

40-
// Characters
41-
// 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot'
42-
/'(?:\\(?:\W|\w+)|[^\\])'/.source,
43-
4440
// eslint-disable-next-line regexp/strict
4541
/(["`])(?:\\[\s\S]|(?!\3)[^\\])*\3[cwd]?/.source
4642
].join('|'), 'm'),
@@ -69,6 +65,12 @@ Prism.languages.d = Prism.languages.extend('clike', {
6965
'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/
7066
});
7167

68+
Prism.languages.insertBefore('d', 'string', {
69+
// Characters
70+
// 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot'
71+
'char': /'(?:\\(?:\W|\w+)|[^\\])'/
72+
});
73+
7274
Prism.languages.insertBefore('d', 'keyword', {
7375
'property': /\B@\w*/
7476
});

‎components/prism-d.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/languages/d/char_feature.test

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'a'
2+
'\''
3+
'\\'
4+
'\n'
5+
'\xFF'
6+
'\377'
7+
'\uFFFF'
8+
'\U0010FFFF'
9+
'\quot'
10+
11+
----------------------------------------------------
12+
13+
[
14+
["char", "'a'"],
15+
["char", "'\\''"],
16+
["char", "'\\\\'"],
17+
["char", "'\\n'"],
18+
["char", "'\\xFF'"],
19+
["char", "'\\377'"],
20+
["char", "'\\uFFFF'"],
21+
["char", "'\\U0010FFFF'"],
22+
["char", "'\\quot'"]
23+
]

‎tests/languages/d/string_feature.test

+1-15
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ bar/"
1919
q"|fo"o
2020
bar|"
2121

22-
'a' '\'' '\\' '\n' '\xFF' '\377' '\uFFFF' '\U0010FFFF' '\quot'
23-
2422
""
2523
"foo"c "bar"w "baz"d
2624
"fo\"o
@@ -50,20 +48,8 @@ q{ q{bar} }
5048
["string", "q\"/fo\"o\r\nbar/\""],
5149
["string", "q\"|fo\"o\r\nbar|\""],
5250

53-
["string", "'a'"],
54-
["string", "'\\''"],
55-
["string", "'\\\\'"],
56-
["string", "'\\n'"],
57-
["string", "'\\xFF'"],
58-
["string", "'\\377'"],
59-
["string", "'\\uFFFF'"],
60-
["string", "'\\U0010FFFF'"],
61-
["string", "'\\quot'"],
62-
6351
["string", "\"\""],
64-
["string", "\"foo\"c"],
65-
["string", "\"bar\"w"],
66-
["string", "\"baz\"d"],
52+
["string", "\"foo\"c"], ["string", "\"bar\"w"], ["string", "\"baz\"d"],
6753
["string", "\"fo\\\"o\r\nbar\""],
6854
["string", "`foo`"],
6955

0 commit comments

Comments
 (0)
Please sign in to comment.