-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Open
Labels
Description
Describe the issue
Python 3.14 introduce template strings (t-strings) as defined in PEP 750. Template strings use the t
prefix (similar to f-strings' f
prefix) but are not currently recognized by Highlight.js. This results in incorrect syntax highlighting where the t
prefix and the template string syntax are not properly distinguished from regular strings.
Which language seems to have the issue?
python
Are you using highlight
or highlightAuto
?
Both highlight
and highlightAuto
are affected.
Sample Code to Reproduce
from string.templatelib import Template, Interpolation
# Basic template string
name = "World"
template = t"Hello {name}"
# Template string with conversion
message = t"Hello {name!r}"
# Template string with format spec
value = 42
formatted = t"Value: {value:.2f}"
# Raw template string
trade = 'shrubberies'
raw_template = rt'Did you say "{trade}"?\n'
# Debug specifier
debug_template = t"Hello {name=}"
# Template concatenation
combined = t"Hello " + t"{name}"
implicit = t"Hello " t"{name}"
Expected behavior
The syntax highlighting should recognize:
- The
t
andT
prefixes as valid string prefixes (similar tof
,r
,b
) - The combination
rt
andtr
prefixes for raw template strings - Template strings should be highlighted similarly to f-strings, with:
- The string prefix (
t
,T
,rt
,tr
) highlighted as a keyword - Interpolation expressions inside
{...}
properly highlighted - Support for conversion specifiers (
!r
,!s
,!a
) - Support for format specifiers (
:
followed by format spec) - Support for the debug specifier (
=
)
- The string prefix (
Additional context
- PEP 750: https://peps.python.org/pep-0750/
- Python version: 3.14
- The syntax is nearly identical to f-strings