Skip to content
Permalink
Browse files
D: Added standard char token (#3196)
  • Loading branch information
RunDevelopment committed Nov 22, 2021
1 parent 1c88c7d commit dafdbdecf5720e3ececb71ac399467f384f54918
Showing with 31 additions and 20 deletions.
  1. +6 −4 components/prism-d.js
  2. +1 −1 components/prism-d.min.js
  3. +23 −0 tests/languages/d/char_feature.test
  4. +1 −15 tests/languages/d/string_feature.test
@@ -37,10 +37,6 @@ Prism.languages.d = Prism.languages.extend('clike', {
// eslint-disable-next-line regexp/strict
/\bq"(.)[\s\S]*?\2"/.source,

// Characters
// 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot'
/'(?:\\(?:\W|\w+)|[^\\])'/.source,

// eslint-disable-next-line regexp/strict
/(["`])(?:\\[\s\S]|(?!\3)[^\\])*\3[cwd]?/.source
].join('|'), 'm'),
@@ -69,6 +65,12 @@ Prism.languages.d = Prism.languages.extend('clike', {
'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/
});

Prism.languages.insertBefore('d', 'string', {
// Characters
// 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot'
'char': /'(?:\\(?:\W|\w+)|[^\\])'/
});

Prism.languages.insertBefore('d', 'keyword', {
'property': /\B@\w*/
});

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,23 @@
'a'
'\''
'\\'
'\n'
'\xFF'
'\377'
'\uFFFF'
'\U0010FFFF'
'\quot'

----------------------------------------------------

[
["char", "'a'"],
["char", "'\\''"],
["char", "'\\\\'"],
["char", "'\\n'"],
["char", "'\\xFF'"],
["char", "'\\377'"],
["char", "'\\uFFFF'"],
["char", "'\\U0010FFFF'"],
["char", "'\\quot'"]
]
@@ -19,8 +19,6 @@ bar/"
q"|fo"o
bar|"

'a' '\'' '\\' '\n' '\xFF' '\377' '\uFFFF' '\U0010FFFF' '\quot'

""
"foo"c "bar"w "baz"d
"fo\"o
@@ -50,20 +48,8 @@ q{ q{bar} }
["string", "q\"/fo\"o\r\nbar/\""],
["string", "q\"|fo\"o\r\nbar|\""],

["string", "'a'"],
["string", "'\\''"],
["string", "'\\\\'"],
["string", "'\\n'"],
["string", "'\\xFF'"],
["string", "'\\377'"],
["string", "'\\uFFFF'"],
["string", "'\\U0010FFFF'"],
["string", "'\\quot'"],

["string", "\"\""],
["string", "\"foo\"c"],
["string", "\"bar\"w"],
["string", "\"baz\"d"],
["string", "\"foo\"c"], ["string", "\"bar\"w"], ["string", "\"baz\"d"],
["string", "\"fo\\\"o\r\nbar\""],
["string", "`foo`"],

0 comments on commit dafdbde

Please sign in to comment.