fixup! Put a 'reset' color in front of the highlighting

This commit is contained in:
Benjamin Schubert 2023-12-20 11:54:55 +00:00
parent e2880b7879
commit e16a67af87
1 changed files with 4 additions and 0 deletions

View File

@ -225,6 +225,10 @@ class TerminalWriter:
) )
if highlighted[-1] == "\n" and source[-1] != "\n": if highlighted[-1] == "\n" and source[-1] != "\n":
highlighted = highlighted[:-1] highlighted = highlighted[:-1]
# Some lexers will not set the initial color explicitly
# which may lead to the previous color being propagated to the
# start of the expression
return "\x1b[0m" + highlighted return "\x1b[0m" + highlighted
except pygments.util.ClassNotFound: except pygments.util.ClassNotFound:
raise UsageError( raise UsageError(