Skip to content

Commit

Permalink
Merge pull request #2565 from davep/bug/2468/eager-pprint
Browse files Browse the repository at this point in the history
Make repr tag highlighting greedy
  • Loading branch information
davep committed Oct 11, 2022
2 parents 234d1ea + 4df597e commit b3bc0ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Bumped minimum Python version to 3.7 https://github.com/Textualize/rich/pull/2567
- Pretty-printing of "tagged" `__repr__` results is now greedy when matching tags https://github.com/Textualize/rich/pull/2565

## [12.6.0] - 2022-10-02

Expand Down
22 changes: 21 additions & 1 deletion tests/test_highlighter.py
Expand Up @@ -5,10 +5,10 @@
import pytest

from rich.highlighter import (
ISO8601Highlighter,
JSONHighlighter,
NullHighlighter,
ReprHighlighter,
ISO8601Highlighter,
)
from rich.text import Span, Text

Expand All @@ -30,6 +30,26 @@ def test_wrong_type():
Span(4, 5, "repr.tag_end"),
],
),
(
"<foo: 23>",
[
Span(0, 1, "repr.tag_start"),
Span(1, 5, "repr.tag_name"),
Span(5, 8, "repr.tag_contents"),
Span(8, 9, "repr.tag_end"),
Span(6, 8, "repr.number"),
],
),
(
"<foo: <bar: 23>>",
[
Span(0, 1, "repr.tag_start"),
Span(1, 5, "repr.tag_name"),
Span(5, 15, "repr.tag_contents"),
Span(15, 16, "repr.tag_end"),
Span(12, 14, "repr.number"),
],
),
(
"False True None",
[
Expand Down

0 comments on commit b3bc0ba

Please sign in to comment.