File tree 4 files changed +25
-2
lines changed 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.
5
5
The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
6
6
and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
7
7
8
+ ## Unreleased
9
+
10
+ ### Fixed
11
+
12
+ - Fixed highlighting of Windows paths in tracebacks. https://github.com/Textualize/rich/pull/3734
13
+
8
14
## [ 14.0.0] - 2025-03-30
9
15
10
16
### 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:
46
46
- [ Paul McGuire] ( https://github.com/ptmcg )
47
47
- [ Antony Milne] ( https://github.com/AntonyMilneQB )
48
48
- [ Michael Milton] ( https://github.com/multimeric )
49
+ - [ Zoltan Nagy] ( https://github.com/abesto )
49
50
- [ Martina Oefelein] ( https://github.com/oefe )
50
51
- [ Nathan Page] ( https://github.com/nathanrpage97 )
51
52
- [ Dave Pearson] ( https://github.com/davep/ )
Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ class Trace:
246
246
247
247
248
248
class PathHighlighter (RegexHighlighter ):
249
- highlights = [r"(?P<dim>.*/ )(?P<bold>.+)" ]
249
+ highlights = [r"(?P<dim>.*(/|\\) )(?P<bold>.+)" ]
250
250
251
251
252
252
class Traceback :
Original file line number Diff line number Diff line change 6
6
import pytest
7
7
8
8
from rich .console import Console
9
+ from rich .text import Span
9
10
from rich .theme import Theme
10
- from rich .traceback import Traceback , install
11
+ from rich .traceback import install , PathHighlighter , Traceback
11
12
12
13
13
14
def test_handler ():
@@ -373,3 +374,18 @@ def test_notes() -> None:
373
374
traceback = Traceback ()
374
375
375
376
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