Skip to content

Commit 2a2e79e

Browse files
C#: Fixed adjacent string interpolations (#2402)
1 parent 939a17c commit 2a2e79e

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

components/prism-csharp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
function createInterpolationInside(interpolation, interpolationRound) {
317317
return {
318318
'interpolation': {
319-
pattern: re(/([^{](?:\{\{)*)<<0>>/.source, [interpolation]),
319+
pattern: re(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [interpolation]),
320320
lookbehind: true,
321321
inside: {
322322
'format-string': {

components/prism-csharp.min.js

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

tests/languages/csharp/interpolation-string_feature.test

+26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
$"Hello, {{ {name} }}! Today is {date.DayOfWeek}, it's {date:HH:mm} now."
22
$"{a,5} and {b + "" /* foo ":} */:format} {h(a, b)}"
3+
$"{1}{2}{3}"
34

45
@$"
56
"
@@ -87,6 +88,31 @@ $@"{
8788
]],
8889
["string", "\""]
8990
]],
91+
["interpolation-string", [
92+
["string", "$\""],
93+
["interpolation", [
94+
["punctuation", "{"],
95+
["expression", [
96+
["number", "1"]
97+
]],
98+
["punctuation", "}"]
99+
]],
100+
["interpolation", [
101+
["punctuation", "{"],
102+
["expression", [
103+
["number", "2"]
104+
]],
105+
["punctuation", "}"]
106+
]],
107+
["interpolation", [
108+
["punctuation", "{"],
109+
["expression", [
110+
["number", "3"]
111+
]],
112+
["punctuation", "}"]
113+
]],
114+
["string", "\""]
115+
]],
90116
["interpolation-string", [
91117
["string", "@$\"\n\""]
92118
]],

0 commit comments

Comments
 (0)