runtime(python): Highlight t-strings

- Highlight t-strings
- Update comments
- Add tests

closes: #18679

Signed-off-by: Rob B <github@0x7e.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Rob B
2025-12-03 20:25:41 +00:00
committed by Christian Brabandt
parent 85fc83f849
commit 8d8c9074c3
17 changed files with 241 additions and 137 deletions

View File

@@ -99,6 +99,47 @@ and fields {1}, {2} and {1
+
2}"""
# Template string literals (t-strings)
# https://docs.python.org/3/reference/lexical_analysis.html#template-string-literals
test = t'T-string with escapes \' and \" and \t and fields {foo} and {bar}'
test = T"T-string with escapes \040 and \xFF and fields {foo} and {bar}"
test = t'T-string with escapes \u00A1 and \U00010605 and \N{INVERTED EXCLAMATION MARK} and fields {foo} and {bar}'
test = T"T-string with literal {{field}} and fields {foo} and {bar}"
test = t'''T-string with quotes ' and "
and escapes \t and \040 and \xFF
and escapes \u00A1 and \U00010605
and fields {1}, {2} and {1
+
2}'''
test = T"""T-string with quotes ' and "
and escapes \t and \040 and \xFF
and escapes \u00A1 and \U00010605
and fields {1}, {2} and {1
+
2}"""
# Raw template string literals
test = tr'Raw t-string with literal \' and \" and \t and fields {foo} and {bar}'
test = tR"Raw t-string with literal \040 and \xFF and fields {foo} and {bar}"
test = tr'Raw t-string with literal \u00A1 and \U00010605 and fields \N{FIELD, NOT, ESCAPE} and {foo} and {bar}'
test = tR"Raw t-string with literal {{field}} and fields {foo} and {bar}"
test = rt'Raw t-string with literal \' and \" and \t and fields {foo} and {bar}'
test = rT"Raw t-string with literal \040 and \xFF and fields {foo} and {bar}"
test = Rt'Raw t-string with literal \u00A1 and \U00010605 and fields \N{FIELD, NOT, ESCAPE} and {foo} and {bar}'
test = RT"Raw t-string with literal {{field}} and fields {foo} and {bar}"
test = tr'''Raw t-string with quotes ' and "
and literal \t and \040 and \xFF
and literal \u00A1 and \U00010605
and fields {1}, {2} and {1
+
2}'''
test = RT"""Raw t-string with quotes ' and "
and literal \t and \040 and \xFF
and literal \u00A1 and \U00010605
and fields {1}, {2} and {1
+
2}"""
# F-string replacement fields
test = f"String is {
"one plus "