File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed
Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8+ ## Unreleased
9+
10+ ### Fixed
11+
12+ - Fixed highlighting of Windows paths in tracebacks. https://github.com/Textualize/rich/pull/3734
13+
814## [ 14.0.0] - 2025-03-30
915
1016### Added
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ The following people have contributed to the development of Rich:
4646- [ Paul McGuire] ( https://github.com/ptmcg )
4747- [ Antony Milne] ( https://github.com/AntonyMilneQB )
4848- [ Michael Milton] ( https://github.com/multimeric )
49+ - [ Zoltan Nagy] ( https://github.com/abesto )
4950- [ Martina Oefelein] ( https://github.com/oefe )
5051- [ Nathan Page] ( https://github.com/nathanrpage97 )
5152- [ Dave Pearson] ( https://github.com/davep/ )
Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ class Trace:
246246
247247
248248class PathHighlighter (RegexHighlighter ):
249- highlights = [r"(?P<dim>.*/ )(?P<bold>.+)" ]
249+ highlights = [r"(?P<dim>.*(/|\\) )(?P<bold>.+)" ]
250250
251251
252252class Traceback :
Original file line number Diff line number Diff line change 66import pytest
77
88from rich .console import Console
9+ from rich .text import Span
910from rich .theme import Theme
10- from rich .traceback import Traceback , install
11+ from rich .traceback import install , PathHighlighter , Traceback
1112
1213
1314def test_handler ():
@@ -373,3 +374,18 @@ def test_notes() -> None:
373374 traceback = Traceback ()
374375
375376 assert traceback .trace .stacks [0 ].notes == ["Hello" , "World" ]
377+
378+
379+ def test_path_highlighter () -> None :
380+ """Check that PathHighlighter correctly highlights both win32 and *nix paths"""
381+ path_highlighter = PathHighlighter ()
382+
383+ assert path_highlighter ("/foo/bar/baz" ).spans == [
384+ Span (0 , 9 , "dim" ),
385+ Span (9 , 12 , "bold" ),
386+ ]
387+
388+ assert path_highlighter ("'\\ \\ ?\\ C:\\ foo\\ bar\\ baz" ).spans == [
389+ Span (0 , 16 , "dim" ),
390+ Span (16 , 19 , "bold" ),
391+ ]
You can’t perform that action at this time.
0 commit comments